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 e303a6bc1..5dca8e86e 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 @@ -41,6 +41,8 @@ class AdvancedMultiSelect extends React.Component { constructor(props) { super(props) + this.enumOptions = props.options.enumOptions; + this.state = { masterCheckboxState: this.getMasterCheckboxState(props.value), infoPaneParams: getDefaultPaneParams(props.schema.items.$ref, props.registry) @@ -52,10 +54,10 @@ class AdvancedMultiSelect extends React.Component { } onMasterCheckboxClick() { - let newValues = this.props.options.enumOptions.map(({value}) => value); - - if (this.state.masterCheckboxState == MasterCheckboxState.ALL) { - newValues = []; + if (this.state.masterCheckboxState === MasterCheckboxState.ALL) { + var newValues = []; + } else { + newValues = this.enumOptions.map(({value}) => value); } this.props.onChange(newValues); @@ -87,11 +89,11 @@ class AdvancedMultiSelect extends React.Component { } getMasterCheckboxState(selectValues) { - if (selectValues.length == 0) { + if (selectValues.length === 0) { return MasterCheckboxState.NONE; } - if (selectValues.length != this.props.options.enumOptions.length) { + if (selectValues.length != this.enumOptions.length) { return MasterCheckboxState.MIXED; } @@ -107,8 +109,6 @@ class AdvancedMultiSelect extends React.Component { const { schema, id, - options, - value, required, disabled, readonly, @@ -116,19 +116,17 @@ class AdvancedMultiSelect extends React.Component { autofocus } = this.props; - const {enumOptions} = options; - return (
- { - enumOptions.map(({value, label}, i) => { + this.enumOptions.map(({value, label}, i) => { return ( - {title}