From cb1360f5af54180aae604ca3e4d8a2cc9ec40949 Mon Sep 17 00:00:00 2001 From: vakarisz Date: Fri, 1 Jul 2022 17:26:11 +0300 Subject: [PATCH] UI: AdvancedMultiSelect.js make option list depend on props --- .../components/ui-components/AdvancedMultiSelect.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 a00f7c9d9..3588c0303 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 @@ -34,7 +34,6 @@ class AdvancedMultiSelect extends React.Component { super(props); this.infoPaneRefString = props.schema.items.$ref; this.registry = props.registry; - this.enumOptions = props.options.enumOptions.sort(this.compareOptions); this.pluginNames = props.value.map(v => v.name); this.state = { @@ -50,6 +49,10 @@ class AdvancedMultiSelect extends React.Component { }; } + getOptionList = () => { + return this.props.options.enumOptions.sort(this.compareOptions); + } + onChange = (strValues) => { let newValues = []; for (let j = 0; j < strValues.length; j++) { @@ -88,7 +91,7 @@ class AdvancedMultiSelect extends React.Component { if (checkboxState === MasterCheckboxState.ALL) { var newValues = []; } else { - newValues = this.enumOptions.map(({value}) => value); + newValues = this.getOptionList().map(({value}) => value); } this.onChange(newValues); @@ -124,7 +127,7 @@ class AdvancedMultiSelect extends React.Component { return MasterCheckboxState.NONE; } - if (selectValues.length !== this.enumOptions.length) { + if (selectValues.length !== this.getOptionList().length) { return MasterCheckboxState.MIXED; } @@ -152,6 +155,7 @@ class AdvancedMultiSelect extends React.Component { } isSafe = (itemKey) => { + console.log(getFullDefinitionByKey(this.infoPaneRefString, this.registry, itemKey)) return getFullDefinitionByKey(this.infoPaneRefString, this.registry, itemKey).safe; } @@ -201,7 +205,7 @@ class AdvancedMultiSelect extends React.Component { onPaneClick={this.setPaneInfo} onCheckboxClick={this.onChildCheckboxClick} selectedValues={this.state.pluginNames} - enumOptions={this.enumOptions}/> + enumOptions={this.getOptionList()}/>