Skip to content

Commit 2180581

Browse files
authored
Merge pull request #893 from pradnya-orchestral/ReRun_Action_Bug
Secret parameters value cleared instead of asterisks and default values will be passed during Rerun action
2 parents 30097ab + 077793c commit 2180581

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

apps/st2-history/history-details.component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default class HistoryDetails extends React.Component {
112112
}
113113

114114
setTitle([ execution.action.ref, 'History' ]);
115-
115+
116116
return (
117117
<PanelDetails data-test="details">
118118
<DetailsHeader

apps/st2-history/history-popup.component.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export default class HistoryPopup extends React.Component {
4646
payload: {
4747
...props.payload,
4848
},
49+
payloadCopy: {
50+
...props.payload, // Here first made copy of data for later comparison
51+
},
4952
...state,
5053
};
5154
}
@@ -59,8 +62,32 @@ export default class HistoryPopup extends React.Component {
5962
}
6063

6164
handleSubmit(e) {
65+
// 1. Whenever user changes any parameter,it is stored into payload.So we get changed data into payload.
66+
// 2. We have copy of original data without any parameter change in payloadCopy object on line no 49.
67+
// 3. Here we are first identifying key name of secret parameter, payloadKey is key variable name for
68+
// payload object and payloadCopyKey is variable name for payloadCopy object.
69+
// 4. Once we get both key, we are checking value of that key in both object.
70+
// 5. So if user change secret parameter data, it will get in payload.
71+
// 6. When user does not change secret parameter,in payload secret parameter value is *** and in
72+
// payloadCopyKey object it is always *** because we are getting changed value in payload object only.
73+
// 7. If data in both key same, then there is no any change and if data is not same in both key
74+
// i.e payloadKey and payloadCopyKey, data is changed and we will send changed data to API.
6275
e.preventDefault();
63-
76+
const hasValue = Object.values(this.state.payload).includes('********');
77+
let payLoadKey;
78+
if (hasValue === true) {
79+
payLoadKey = Object.keys(this.state.payload).find(key => this.state.payload[key] === '********');
80+
}
81+
82+
const isValue = Object.values(this.state.payloadCopy).includes('********');
83+
let payloadCopyKey ;
84+
if (isValue === true) {
85+
payloadCopyKey = Object.keys(this.state.payloadCopy).find(key => this.state.payloadCopy[key] === '********');
86+
}
87+
88+
if (this.state.payload[payLoadKey] === this.state.payloadCopy[payloadCopyKey]) {
89+
delete this.state.payload[payLoadKey];
90+
}
6491
this.props.onSubmit(this.state.payload);
6592
}
6693

0 commit comments

Comments
 (0)