From 73dd8ddcc97da1156fa09793051ffec6651d8d40 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 13 Jan 2021 07:35:03 -0500 Subject: [PATCH] ui: Minor readability and style changes for AdvancedMultiSelect --- .../ui-components/AdvancedMultiSelect.js | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 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 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}