ui: extract UnsafeOptionsConfirmationModal JSX invocation into a function

This commit is contained in:
Mike Salvatore 2021-02-26 11:19:33 -05:00
parent 5a9cb8b4af
commit 75bf30913a
1 changed files with 11 additions and 6 deletions

View File

@ -186,7 +186,6 @@ class ConfigurePageComponent extends AuthComponent {
}
configSubmit() {
// Submit monkey configuration
if (!this.canSafelySubmitConfig(this.state.configuration)) {
this.setState({showUnsafeOptionsConfirmation: true});
return;
@ -276,6 +275,16 @@ class ConfigurePageComponent extends AuthComponent {
</Modal>)
};
renderUnsafeOptionsConfirmationModal() {
return (
<UnsafeOptionsConfirmationModal
show={this.state.showUnsafeOptionsConfirmation}
onCancelClick={this.onUnsafeConfirmationCancelClick}
onContinueClick={this.onUnsafeConfirmationContinueClick}
/>
)
}
userChangedConfig() {
if (JSON.stringify(this.state.configuration) === JSON.stringify(this.initialConfig)) {
if (Object.keys(this.currentFormData).length === 0 ||
@ -504,11 +513,7 @@ class ConfigurePageComponent extends AuthComponent {
lg={{offset: 3, span: 8}} xl={{offset: 2, span: 8}}
className={'main'}>
{this.renderAttackAlertModal()}
<UnsafeOptionsConfirmationModal
show={this.state.showUnsafeOptionsConfirmation}
onCancelClick={this.onUnsafeConfirmationCancelClick}
onContinueClick={this.onUnsafeConfirmationContinueClick}
/>
{this.renderUnsafeOptionsConfirmationModal()}
<h1 className='page-title'>Monkey Configuration</h1>
{this.renderNav()}
{content}