From 07180f091e9ffabc5d759d857cf25e35ad8fb4a1 Mon Sep 17 00:00:00 2001 From: Kaveesha Mihirangi Date: Fri, 20 Mar 2020 06:25:30 +0000 Subject: [PATCH] Payload improvements in add new policy feature in React App --- .../components/PublishDevices/index.js | 2 +- .../Policies/components/AddPolicy/index.js | 16 ++++++++-------- .../type/template/config/SubFormList.java | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/PublishDevices/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/PublishDevices/index.js index af7de28dd4..58bda03064 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/PublishDevices/index.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/PublishDevices/index.js @@ -30,7 +30,7 @@ class PublishDevices extends React.Component { this.props.form.validateFields((err, values) => { if (!err) { if (isPublish) { - Object.assign(values, { active: isPublish }); + values = { ...values, ...{ active: isPublish } }; } this.props.getPolicyPayloadData(formName, values); } diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js index 908c110cf0..c0e1169445 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/index.js @@ -65,14 +65,14 @@ class AddPolicy extends React.Component { devicetype: selectedPlatformData.deviceType, }; - let payload = Object.assign( - newPolicyPayload, - publishDevicesData, - policyProfile, - policyTypeData, - groupData, - { profile: profile }, - ); + let payload = { + ...newPolicyPayload, + ...publishDevicesData, + ...policyProfile, + ...policyTypeData, + ...groupData, + ...{ profile: profile }, + }; console.log(payload); }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/SubFormList.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/SubFormList.java index d4a020e823..5e394dbc20 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/SubFormList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/config/SubFormList.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.carbon.device.mgt.extensions.device.type.template.config; import javax.xml.bind.annotation.XmlAttribute;