From 20f091ff4e0ed817e6ca41ec8e77beda72f3217c Mon Sep 17 00:00:00 2001 From: vakarisz Date: Mon, 4 Jul 2022 13:00:36 +0300 Subject: [PATCH] UI: Fix reset button in AdvancedMultiSelect.js Reset button will reset to all safe values --- .../ui-components/AdvancedMultiSelect.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js index ed112e68d..46c7d0fb6 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js @@ -93,8 +93,6 @@ class AdvancedMultiSelect extends React.Component { onChildCheckboxClick = (value) => { let selectValues = this.getSelectValuesAfterClick(value); this.onChange(selectValues); - - this.setHideResetState(selectValues); } getSelectValuesAfterClick(clickedValue) { @@ -128,15 +126,7 @@ class AdvancedMultiSelect extends React.Component { } onResetClick = () => { - this.onChange(this.defaultValues); - this.setHideResetState(this.defaultValues); - this.setPaneInfoToSafe(this.isUnsafeOptionSelected(this.defaultValues)); - } - - setHideResetState(selectValues) { - this.setState(() => ({ - hideReset: this.getHideResetState(selectValues) - })); + this.setPaneInfoToSafe(); } getHideResetState(selectValues) { @@ -168,9 +158,10 @@ class AdvancedMultiSelect extends React.Component { ); } - setPaneInfoToSafe(isUnsafeOptionSelected) { + setPaneInfoToSafe() { let safePluginNames = this.state.allPluginNames.filter(pluginName => this.isSafe(pluginName)); this.setState({selectedPluginNames: safePluginNames}); + this.onChange(safePluginNames); } render() { @@ -195,7 +186,7 @@ class AdvancedMultiSelect extends React.Component { checkboxState={this.getMasterCheckboxState( this.state.selectedPluginNames)} hideReset={this.getHideResetState( - this.state.allPluginNames)} + this.state.selectedPluginNames)} onResetClick={this.onResetClick}/>