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 b875a6426..7507f234f 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
@@ -10,17 +10,6 @@ import {resolveObjectPath} from './utils/ObjectPathResolver';
import InfoPane from './InfoPane';
-function getSelectValuesAfterClick(valueArray, clickedValue) {
- if (valueArray.includes(clickedValue)) {
- return valueArray.filter((e) => {
- return e !== clickedValue;
- });
- } else {
- valueArray.push(clickedValue);
- return valueArray;
- }
-}
-
// Definitions passed to components only contains value and label,
// custom fields like "info" or "links" must be pulled from registry object using this function
function getFullDefinitionsFromRegistry(refString, registry) {
@@ -56,95 +45,129 @@ function MasterCheckbox(props) {
{title}
);
}
+function ChildCheckbox(props) {
+ const {
+ onPaneClick,
+ onClick,
+ value,
+ disabled,
+ label,
+ checkboxState
+ } = props;
+
+ return (
+
onPaneClick(value)}>
+
+
+ {label}
+
+
+ );
+}
+
class AdvancedMultiSelect extends React.Component {
- constructor(props) {
- super(props)
- this.state = {masterCheckbox: true, infoPaneParams: getDefaultPaneParams(props.schema.items.$ref, props.registry)};
- this.onMasterCheckboxClick = this.onMasterCheckboxClick.bind(this);
+ constructor(props) {
+ super(props)
+ this.state = {masterCheckbox: true, infoPaneParams: getDefaultPaneParams(props.schema.items.$ref, props.registry)};
+ this.onMasterCheckboxClick = this.onMasterCheckboxClick.bind(this);
+ this.onChildCheckboxClick = this.onChildCheckboxClick.bind(this);
+ this.setPaneInfo = this.setPaneInfo.bind(this, props.schema.items.$ref, props.registry);
+ }
+
+ onMasterCheckboxClick() {
+ if (this.state.masterCheckbox) {
+ this.props.onChange([]);
+ } else {
+ this.props.onChange(this.props.schema.default);
}
- onMasterCheckboxClick() {
- if (this.state.masterCheckbox) {
- this.props.onChange([]);
- } else {
- this.props.onChange(this.props.schema.default);
- }
+ this.toggleMasterCheckbox();
+ }
- this.toggleMasterCheckbox();
+ onChildCheckboxClick(value) {
+ this.props.onChange(this.getSelectValuesAfterClick(value));
+ }
+
+ getSelectValuesAfterClick(clickedValue) {
+ const valueArray = cloneDeep(this.props.value);
+
+ if (valueArray.includes(clickedValue)) {
+ return valueArray.filter((e) => {
+ return e !== clickedValue;
+ });
+ } else {
+ valueArray.push(clickedValue);
+ return valueArray;
}
+ }
- toggleMasterCheckbox() {
- this.setState((state) => ({
- masterCheckbox: !state.masterCheckbox
- }));
- }
+ toggleMasterCheckbox() {
+ this.setState((state) => ({
+ masterCheckbox: !state.masterCheckbox
+ }));
+ }
- setPaneInfo(refString, registry, itemKey) {
- let definitionObj = getFullDefinitionByKey(refString, registry, itemKey);
- this.setState({infoPaneParams: {title: definitionObj.title, content: definitionObj.info, link: definitionObj.link}});
- }
+ setPaneInfo(refString, registry, itemKey) {
+ let definitionObj = getFullDefinitionByKey(refString, registry, itemKey);
+ this.setState({infoPaneParams: {title: definitionObj.title, content: definitionObj.info, link: definitionObj.link}});
+ }
- render() {
- const {
- schema,
- id,
- options,
- value,
- required,
- disabled,
- readonly,
- multiple,
- autofocus,
- onChange,
- registry
- } = this.props;
- const {enumOptions} = options;
- getDefaultPaneParams(schema.items.$ref, registry);
- const selectValue = cloneDeep(value);
- return (
-
-
-
- {
- enumOptions.map(({value, label}, i) => {
- return (
- this.setPaneInfo(schema.items.$ref, registry, value)}>
+ render() {
+ const {
+ schema,
+ id,
+ options,
+ value,
+ required,
+ disabled,
+ readonly,
+ multiple,
+ autofocus,
+ onChange,
+ registry
+ } = this.props;
-
-
- {label}
-
-
- );
- }
- )}
-
-
-
- );
- }
+ return (
+
+
+
+ {
+ enumOptions.map(({value, label}, i) => {
+ return (
+
+ );
+ }
+ )}
+
+
+
+ );
+ }
}
export default AdvancedMultiSelect;