Skip to content

Commit

Permalink
Merge pull request #893 from pradnya-orchestral/ReRun_Action_Bug
Browse files Browse the repository at this point in the history
Secret parameters value cleared instead of asterisks and default values will be passed during Rerun action
  • Loading branch information
m4dcoder committed Jul 1, 2021
2 parents 30097ab + 077793c commit 2180581
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/st2-history/history-details.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class HistoryDetails extends React.Component {
}

setTitle([ execution.action.ref, 'History' ]);

return (
<PanelDetails data-test="details">
<DetailsHeader
Expand Down
29 changes: 28 additions & 1 deletion apps/st2-history/history-popup.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export default class HistoryPopup extends React.Component {
payload: {
...props.payload,
},
payloadCopy: {
...props.payload, // Here first made copy of data for later comparison
},
...state,
};
}
Expand All @@ -59,8 +62,32 @@ export default class HistoryPopup extends React.Component {
}

handleSubmit(e) {
// 1. Whenever user changes any parameter,it is stored into payload.So we get changed data into payload.
// 2. We have copy of original data without any parameter change in payloadCopy object on line no 49.
// 3. Here we are first identifying key name of secret parameter, payloadKey is key variable name for
// payload object and payloadCopyKey is variable name for payloadCopy object.
// 4. Once we get both key, we are checking value of that key in both object.
// 5. So if user change secret parameter data, it will get in payload.
// 6. When user does not change secret parameter,in payload secret parameter value is *** and in
// payloadCopyKey object it is always *** because we are getting changed value in payload object only.
// 7. If data in both key same, then there is no any change and if data is not same in both key
// i.e payloadKey and payloadCopyKey, data is changed and we will send changed data to API.
e.preventDefault();

const hasValue = Object.values(this.state.payload).includes('********');
let payLoadKey;
if (hasValue === true) {
payLoadKey = Object.keys(this.state.payload).find(key => this.state.payload[key] === '********');
}

const isValue = Object.values(this.state.payloadCopy).includes('********');
let payloadCopyKey ;
if (isValue === true) {
payloadCopyKey = Object.keys(this.state.payloadCopy).find(key => this.state.payloadCopy[key] === '********');
}

if (this.state.payload[payLoadKey] === this.state.payloadCopy[payloadCopyKey]) {
delete this.state.payload[payLoadKey];
}
this.props.onSubmit(this.state.payload);
}

Expand Down

0 comments on commit 2180581

Please sign in to comment.