From 8d024b900248d94cee76ec79f0dd66befeb7efbf Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 14 Jan 2021 08:37:52 -0500 Subject: [PATCH] ui: separate MasterCheckbox and ChildCheckbox into their own files --- .../ui-components/AdvancedMultiSelect.js | 65 ++----------------- .../components/ui-components/ChildCheckbox.js | 30 +++++++++ .../ui-components/MasterCheckbox.js | 41 ++++++++++++ 3 files changed, 76 insertions(+), 60 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/ui-components/ChildCheckbox.js create mode 100644 monkey/monkey_island/cc/ui/src/components/ui-components/MasterCheckbox.js 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 5dca8e86e..9d82a1b8d 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 @@ -1,20 +1,13 @@ -import React from "react"; -import {Card, Button, Form} from 'react-bootstrap'; -import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; -import {faCheckSquare} from '@fortawesome/free-solid-svg-icons'; -import {faMinusSquare} from '@fortawesome/free-solid-svg-icons'; -import {faSquare} from '@fortawesome/free-regular-svg-icons'; +import React from 'react'; +import {Form} from 'react-bootstrap'; + import {cloneDeep} from 'lodash'; import {getComponentHeight} from './utils/HeightCalculator'; import {resolveObjectPath} from './utils/ObjectPathResolver'; import InfoPane from './InfoPane'; - -const MasterCheckboxState = { - NONE: 0, - MIXED: 1, - ALL: 2 -} +import {MasterCheckbox, MasterCheckboxState} from './MasterCheckbox'; +import ChildCheckbox from './ChildCheckbox'; function getFullDefinitionByKey(refString, registry, itemKey) { let fullArray = getFullDefinitionsFromRegistry(refString, registry); @@ -143,52 +136,4 @@ class AdvancedMultiSelect extends React.Component { } } -function MasterCheckbox(props) { - const { - title, - disabled, - onClick, - checkboxState - } = props; - - let newCheckboxIcon = faCheckSquare; - - if (checkboxState === MasterCheckboxState.NONE) { - newCheckboxIcon = faSquare; - } else if (checkboxState === MasterCheckboxState.MIXED) { - newCheckboxIcon = faMinusSquare; - } - - return ( - - - {title} - - ); -} - -function ChildCheckbox(props) { - const { - onPaneClick, - onClick, - value, - disabled, - label, - checkboxState - } = props; - - return ( - onPaneClick(value)}> - - - {label} - - - ); -} - export default AdvancedMultiSelect; diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/ChildCheckbox.js b/monkey/monkey_island/cc/ui/src/components/ui-components/ChildCheckbox.js new file mode 100644 index 000000000..353da4b22 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/ChildCheckbox.js @@ -0,0 +1,30 @@ +import React from 'react'; +import {Button, Form} from 'react-bootstrap'; + +import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; +import {faCheckSquare} from '@fortawesome/free-solid-svg-icons'; +import {faSquare} from '@fortawesome/free-regular-svg-icons'; + +function ChildCheckbox(props) { + const { + onPaneClick, + onClick, + value, + disabled, + label, + checkboxState + } = props; + + return ( + onPaneClick(value)}> + + + {label} + + + ); +} + +export default ChildCheckbox; diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/MasterCheckbox.js b/monkey/monkey_island/cc/ui/src/components/ui-components/MasterCheckbox.js new file mode 100644 index 000000000..0485e64eb --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/MasterCheckbox.js @@ -0,0 +1,41 @@ +import React from 'react'; +import {Card, Button} from 'react-bootstrap'; + +import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; +import {faCheckSquare} from '@fortawesome/free-solid-svg-icons'; +import {faMinusSquare} from '@fortawesome/free-solid-svg-icons'; +import {faSquare} from '@fortawesome/free-regular-svg-icons'; + +const MasterCheckboxState = { + NONE: 0, + MIXED: 1, + ALL: 2 +} + +function MasterCheckbox(props) { + const { + title, + disabled, + onClick, + checkboxState + } = props; + + let newCheckboxIcon = faCheckSquare; + + if (checkboxState === MasterCheckboxState.NONE) { + newCheckboxIcon = faSquare; + } else if (checkboxState === MasterCheckboxState.MIXED) { + newCheckboxIcon = faMinusSquare; + } + + return ( + + + {title} + + ); +} + +export {MasterCheckboxState, MasterCheckbox};