aboutsummaryrefslogtreecommitdiffstats
path: root/ui-react/src
diff options
context:
space:
mode:
authorxuegao <xg353y@intl.att.com>2020-01-13 10:27:54 +0100
committerxuegao <xg353y@intl.att.com>2020-01-13 10:28:09 +0100
commit8c2ce6065ddd8405ef3faa99969453e080b63f55 (patch)
tree910adbc730dfe27d83c61b05542a17ebc265621f /ui-react/src
parentc2f5de7aeefb5c8512e1eaa9583ed6524d501da3 (diff)
Update based on comment
Initialize the state attribute in the constructor. Issue-ID: CLAMP-569 Change-Id: Iabd739ce2c828d6e50720bfb2f29c365b8736bfa Signed-off-by: xuegao <xg353y@intl.att.com>
Diffstat (limited to 'ui-react/src')
-rw-r--r--ui-react/src/components/dialogs/Loop/DeployLoopModal.js36
1 files changed, 22 insertions, 14 deletions
diff --git a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js
index 9c9a16fe..6468e9f9 100644
--- a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js
+++ b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js
@@ -37,11 +37,9 @@ const FormStyled = styled(Form.Group)`
padding: .25rem 1.5rem;
`
export default class DeployLoopModal extends React.Component {
- state = {
- loopCache: this.props.loopCache,
- temporaryPropertiesJson: JSON.parse(JSON.stringify(this.props.loopCache.getGlobalProperties())),
- show: true
- };
+
+
+
constructor(props, context) {
super(props, context);
@@ -50,6 +48,24 @@ export default class DeployLoopModal extends React.Component {
this.handleChange = this.handleChange.bind(this);
this.refreshStatus = this.refreshStatus.bind(this);
this.renderDeployParam = this.renderDeployParam.bind(this);
+
+ const propertiesJson = JSON.parse(JSON.stringify(this.props.loopCache.getGlobalProperties()));
+ this.state = {
+ loopCache: this.props.loopCache,
+ temporaryPropertiesJson: propertiesJson,
+ show: true,
+ key: this.getInitialKeyValue(propertiesJson)
+ };
+ }
+ getInitialKeyValue(temporaryPropertiesJson) {
+ const deployJsonList = temporaryPropertiesJson["dcaeDeployParameters"];
+ let initialKey;
+ Object.keys(deployJsonList)
+ .filter((obj) => Object.keys(deployJsonList).indexOf(obj) === 0)
+ .map(obj =>
+ initialKey = obj
+ );
+ return initialKey;
}
componentWillReceiveProps(newProps) {
this.setState({
@@ -57,14 +73,7 @@ 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('/');
}
@@ -117,7 +126,6 @@ export default class DeployLoopModal extends React.Component {
);
return indents;
}
-
renderDeployParam(deployJson) {
var indents = [];
Object.keys(deployJson).map((item,key) =>