From 9f12702c3e835f90171a0d474d760015fb71ca53 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 1 Feb 2021 06:57:04 -0500 Subject: [PATCH] ui: code readability improvements --- .../components/ui-components/ChildCheckbox.js | 9 +--- .../src/components/ui-components/InfoPane.js | 41 ++++++++++--------- 2 files changed, 23 insertions(+), 27 deletions(-) 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 index 47a86dab6..6ebe69985 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/ChildCheckbox.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/ChildCheckbox.js @@ -52,18 +52,13 @@ function ChildCheckbox(props) { safe } = props; - let displayLabel = [{label}]; - - if (!safe) { - displayLabel.push() - } - return ( onPaneClick(value)}> - {displayLabel} + {label} + {!safe && } ); } diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/InfoPane.js b/monkey/monkey_island/cc/ui/src/components/ui-components/InfoPane.js index e6476d3a2..21e71e29f 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/InfoPane.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/InfoPane.js @@ -60,37 +60,38 @@ function getSubtitle(props) { } function getBody(props) { - let body = [{props.body}]; - - if (props.warningType !== WarningType.NONE) { - body.push(getWarning(props.warningType)); - } - return ( - {body} + {props.body} + {props.warningType !== WarningType.NONE && getWarning(props.warningType)} ) } function getWarning(warningType) { - if (warningType === WarningType.SINGLE) { - var warning = This option may cause a system to become unstable or - may change a system's state in undesirable ways. Therefore, this option - is not recommended for use in production or other sensitive - environments.; - } else { - warning = Some options have been selected that may cause a system - to become unstable or may change a system's state in undesirable ways. - Running Infection Monkey in a production or other sensitive environment - with this configuration is not recommended.; - } - return (
- {warning} + {warningType === WarningType.SINGLE ? getSingleOptionWarning() : getMultipleOptionsWarning()}
); } +function getSingleOptionWarning() { + return ( + This option may cause a system to become unstable or + may change a system's state in undesirable ways. Therefore, this option + is not recommended for use in production or other sensitive + environments. + ); +} + +function getMultipleOptionsWarning() { + return ( + Some options have been selected that may cause a system + to become unstable or may change a system's state in undesirable ways. + Running Infection Monkey in a production or other sensitive environment + with this configuration is not recommended. + ); +} + export {getDefaultPaneParams, InfoPane, WarningType}