ui: fix race in unsafe confirmation modal dialog

This commit is contained in:
Mike Salvatore 2021-02-25 19:41:36 -05:00
parent 8fd1582909
commit ff28509d0d
1 changed files with 15 additions and 7 deletions

View File

@ -86,9 +86,9 @@ class ConfigurePageComponent extends AuthComponent {
{unsafeOptionsConfirmed: true, showUnsafeOptionsConfirmation: false}, {unsafeOptionsConfirmed: true, showUnsafeOptionsConfirmation: false},
() => { () => {
if (this.state.lastAction == 'submit_attempt') { if (this.state.lastAction == 'submit_attempt') {
this.onSubmit(); this.attemptConfigSubmit();
} else if (this.state.lastAction == 'import_attempt') { } else if (this.state.lastAction == 'import_attempt') {
this.setConfigFromCandidateJson(this.state.candidateConfigJson); this.attemptSetConfigFromCandidateJson(this.state.candidateConfigJson);
} }
} }
); );
@ -107,7 +107,7 @@ class ConfigurePageComponent extends AuthComponent {
if (this.state.selectedSection === 'attack') { if (this.state.selectedSection === 'attack') {
this.matrixSubmit() this.matrixSubmit()
} else { } else {
this.configSubmit() this.attemptConfigSubmit()
} }
}; };
@ -180,11 +180,13 @@ class ConfigurePageComponent extends AuthComponent {
}); });
}; };
configSubmit = () => { attemptConfigSubmit() {
// Submit monkey configuration
this.setState({lastAction: 'submit_attempt'});
this.updateConfigSection(); this.updateConfigSection();
this.setState({lastAction: 'submit_attempt'}, this.configSubmit());
}
configSubmit() {
// Submit monkey configuration
if (!this.canSafelySubmitConfig(this.state.configuration)) { if (!this.canSafelySubmitConfig(this.state.configuration)) {
this.setState({showUnsafeOptionsConfirmation: true}); this.setState({showUnsafeOptionsConfirmation: true});
return; return;
@ -348,7 +350,13 @@ class ConfigurePageComponent extends AuthComponent {
} }
setConfigOnImport = (event) => { setConfigOnImport = (event) => {
this.setConfigFromCandidateJson(event.target.result); this.attemptSetConfigFromCandidateJson(event.target.result);
}
attemptSetConfigFromCandidateJson(newConfigCandidateJson){
this.setState({lastAction: 'import_attempt', candidateConfigJson: newConfigCandidateJson},
this.setConfigFromCandidateJson(newConfigCandidateJson)
);
} }
setConfigFromCandidateJson(newConfigCandidateJson){ setConfigFromCandidateJson(newConfigCandidateJson){