diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js index 8d3539854a4..90fb75fcd31 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/index.js @@ -42,6 +42,8 @@ import Roles from './scenes/Home/scenes/Roles'; import DeviceTypes from './scenes/Home/scenes/DeviceTypes'; import Certificates from './scenes/Home/scenes/Configurations/scenes/Certificates'; import Devices from './scenes/Home/scenes/Devices'; +import ViewPolicy from './scenes/Home/scenes/Policies/scenes/ViewPolicy'; +import EditSelectedPolicy from './scenes/Home/scenes/Policies/scenes/EditSelectedPolicy'; const routes = [ { @@ -94,6 +96,16 @@ const routes = [ component: AddNewPolicy, exact: true, }, + { + path: '/entgra/policy/view/:policyId', + component: ViewPolicy, + exact: true, + }, + { + path: '/entgra/policy/edit/:policyId', + component: EditSelectedPolicy, + exact: true, + }, { path: '/entgra/roles', component: Roles, diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/AssignGroups/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/AssignGroups/index.js index 533d23ab118..e90d0fa9dd4 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/AssignGroups/index.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/AssignGroups/index.js @@ -52,12 +52,17 @@ class AssignGroups extends React.Component { onHandleContinue = (e, formName) => { this.props.form.validateFields((err, values) => { if (!err) { + if (typeof values.roles === 'string') { + values.roles = [values.roles]; + } if (!values.users) { delete values.users; } + if (values.deviceGroups === 'NONE') { delete values.deviceGroups; } + this.props.getPolicyPayloadData(formName, values); this.props.getNextStep(); } diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js index 7d0d45c27c4..9e6fedb7e92 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/src/scenes/Home/scenes/Policies/components/AddPolicy/components/ConfigureProfile/index.js @@ -45,6 +45,8 @@ const { TabPane } = Tabs; const { Option } = Select; const { TextArea } = Input; +const subPanelpayloadAttributes = {}; + class ConfigureProfile extends React.Component { constructor(props) { super(props); @@ -54,6 +56,8 @@ class ConfigureProfile extends React.Component { isDisplayMain: 'none', activePanelKeys: [], activeSubPanelKeys: [], + subFormList: [], + subPanelpayloadAttributes: {}, count: 0, dataArray: [], customInputDataArray: [], @@ -297,17 +301,64 @@ class ConfigureProfile extends React.Component { // generate payload by adding policy configurations onHandleContinue = (e, formname) => { - this.props.form.validateFields((err, values) => { + const allFields = this.props.form.getFieldsValue(); + let activeFields = []; + // get currently active field list + for (let i = 0; i < this.state.activePanelKeys.length; i++) { + Object.keys(allFields).map(key => { + if (key.includes(`${this.state.activePanelKeys[i]}-`)) { + if ( + subPanelpayloadAttributes.hasOwnProperty( + `${this.state.activePanelKeys[i]}`, + ) + ) { + Object.keys( + subPanelpayloadAttributes[this.state.activePanelKeys[i]], + ).map(subPanel => { + if (`${this.state.activePanelKeys[i]}-${subPanel}` === true) { + if (key.includes(`-${subPanel}-`)) { + activeFields.push(key); + } + } else if (!key.includes(`-${subPanel}-`)) { + activeFields.push(key); + } + }); + } else { + activeFields.push(key); + } + } + }); + } + // validate fields and get profile features list + this.props.form.validateFields(activeFields, (err, values) => { if (!err) { - this.props.getPolicyPayloadData(formname, values); + let profileFeaturesList = []; + for (let i = 0; i < this.state.activePanelKeys.length; i++) { + let content = {}; + Object.entries(values).map(([key, value]) => { + if (key.includes(`${this.state.activePanelKeys[i]}-`)) { + content[ + key.replace(`${this.state.activePanelKeys[i]}-`, '') + ] = value; + } + }); + let feature = { + featureCode: this.state.activePanelKeys[i], + deviceType: 'android', + content: content, + }; + profileFeaturesList.push(feature); + } + this.props.getPolicyPayloadData(formname, profileFeaturesList); this.props.getNextStep(); } }); }; // generate form items - getPanelItems = panel => { + getPanelItems = (panel, panelId) => { const { getFieldDecorator } = this.props.form; + const subPanelList = {}; return panel.map((item, k) => { switch (item.type) { case 'select': @@ -407,7 +458,6 @@ class ConfigureProfile extends React.Component { style={{ display: 'block' }} > {getFieldDecorator(`${item.id}`, { - // valuePropName: 'option', initialValue: item.optional.initialDataIndex, })(