From 9047defa7549ebd9a84cef3e10bbfd90f068097b Mon Sep 17 00:00:00 2001 From: xuegao Date: Fri, 13 Dec 2019 11:50:24 +0100 Subject: Update deploymentParameters Update deploymentParameters to allow a map of instead of a single deploymentParam Issue-ID: CLAMP-569, CLAMP-570 Change-Id: I6abc4fe193157644bd6abe1c893a1416cadec988 Signed-off-by: xuegao --- .../src/components/dialogs/Loop/DeployLoopModal.js | 35 ++++++++--- .../dialogs/Loop/DeployLoopModal.test.js | 9 +-- .../__snapshots__/DeployLoopModal.test.js.snap | 68 +++++++++++++--------- 3 files changed, 73 insertions(+), 39 deletions(-) (limited to 'ui-react/src') diff --git a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js index 34304d611..9c9a16feb 100644 --- a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js @@ -26,6 +26,8 @@ import LoopService from '../../../api/LoopService'; import Button from 'react-bootstrap/Button'; import Modal from 'react-bootstrap/Modal'; import Form from 'react-bootstrap/Form'; +import Tabs from 'react-bootstrap/Tabs'; +import Tab from 'react-bootstrap/Tab'; import styled from 'styled-components'; const ModalStyled = styled(Modal)` @@ -55,6 +57,14 @@ export default class DeployLoopModal extends React.Component { show: true }); } + componentDidMount() { + const deployJsonList = this.state.temporaryPropertiesJson["dcaeDeployParameters"]; + Object.keys(deployJsonList) + .filter((obj) => Object.keys(deployJsonList).indexOf(obj) === 0) + .map(obj => + this.setState({key: obj}) + ); + } handleClose(){ this.props.history.push('/'); } @@ -89,34 +99,43 @@ export default class DeployLoopModal extends React.Component { } handleChange(event) { let deploymentParam = this.state.temporaryPropertiesJson["dcaeDeployParameters"]; - deploymentParam[event.target.name] = event.target.value; + deploymentParam[this.state.key][event.target.name] = event.target.value; this.setState({temporaryPropertiesJson:{dcaeDeployParameters: deploymentParam}}); } - renderDeployParam() { + renderDeployParamTabs() { if (typeof (this.state.temporaryPropertiesJson) === "undefined") { return ""; } - const deployJson = this.state.temporaryPropertiesJson["dcaeDeployParameters"]; + const deployJsonList = this.state.temporaryPropertiesJson["dcaeDeployParameters"]; + var indents = []; + Object.keys(deployJsonList).map((item,key) => + indents.push( + {this.renderDeployParam(deployJsonList[item])} + ) + ); + return indents; + } + + renderDeployParam(deployJson) { var indents = []; Object.keys(deployJson).map((item,key) => indents.push( {item} )); - - return indents; + return indents; } - - render() { return ( Deployment parameters - {this.renderDeployParam()} + this.setState({ key })}> + {this.renderDeployParamTabs()} + diff --git a/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js b/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js index 2ebb8c067..5f1dcd5fc 100644 --- a/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js +++ b/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js @@ -32,8 +32,10 @@ describe('Verify DeployLoopModal', () => { "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca", "globalPropertiesJson": { "dcaeDeployParameters": { - "location_id": "", - "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" + "testMs": { + "location_id": "", + "policy_id": "TCA_h2NMX_v1_0_ResourceInstanceName1_tca" + } } } }); @@ -101,10 +103,9 @@ describe('Verify DeployLoopModal', () => { it('Onchange event', () => { const event = { target: { name: "location_id", value: "testLocation"} }; const component = shallow(); - const forms = component.find('StateManager'); component.find('[name="location_id"]').simulate('change', event); component.update(); - expect(component.state('temporaryPropertiesJson').dcaeDeployParameters.location_id).toEqual("testLocation"); + expect(component.state('temporaryPropertiesJson').dcaeDeployParameters.testMs.location_id).toEqual("testLocation"); }); }); \ No newline at end of file diff --git a/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap b/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap index bf06965be..0f86aa340 100644 --- a/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap +++ b/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap @@ -14,34 +14,48 @@ exports[`Verify DeployLoopModal Test the render method 1`] = ` Deployment parameters - - - location_id - - - - - + - policy_id - - - + + + location_id + + + + + + policy_id + + + + +