From 7170efbf0dc300636571aba84e83c422dd0458f1 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 14 Jul 2021 18:42:26 +0530 Subject: [PATCH] cc: Extract configuration tabs' order to a separate file and modify how the order is fetched --- .../ConfigurationTabs.js | 30 ++++++++++++++++ .../ui/src/components/pages/ConfigurePage.js | 36 +++---------------- 2 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 monkey/monkey_island/cc/ui/src/components/configuration-components/ConfigurationTabs.js diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/ConfigurationTabs.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/ConfigurationTabs.js new file mode 100644 index 000000000..7701959cf --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/ConfigurationTabs.js @@ -0,0 +1,30 @@ +const CONFIGURATION_TABS = { + ATTACK: 'attack', + BASIC: 'basic', + BASIC_NETWORK: 'basic_network', + RANSOMWARE: 'ransomware', + MONKEY: 'monkey', + INTERNAL: 'internal' +}; + +const advancedModeConfigTabs = [ + CONFIGURATION_TABS.ATTACK, + CONFIGURATION_TABS.BASIC, + CONFIGURATION_TABS.BASIC_NETWORK, + CONFIGURATION_TABS.RANSOMWARE, + CONFIGURATION_TABS.MONKEY, + CONFIGURATION_TABS.INTERNAL +]; + +const ransomwareModeConfigTabs = [ + CONFIGURATION_TABS.BASIC, + CONFIGURATION_TABS.BASIC_NETWORK, + CONFIGURATION_TABS.RANSOMWARE +]; + +const CONFIGURATION_TABS_PER_MODE = { + 'advanced': advancedModeConfigTabs, + 'ransomware': ransomwareModeConfigTabs +}; + +export default CONFIGURATION_TABS_PER_MODE; diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index 594b0ad08..26141b22c 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -18,19 +18,12 @@ import ConfigExportModal from '../configuration-components/ExportConfigModal'; import ConfigImportModal from '../configuration-components/ImportConfigModal'; import applyUiSchemaManipulators from '../configuration-components/UISchemaManipulators.tsx'; import HtmlFieldDescription from '../configuration-components/HtmlFieldDescription.js'; +import CONFIGURATION_TABS_PER_MODE from '../configuration-components/ConfigurationTabs.js'; const ATTACK_URL = '/api/attack'; const CONFIG_URL = '/api/configuration/island'; export const API_PBA_LINUX = '/api/fileUpload/PBAlinux'; export const API_PBA_WINDOWS = '/api/fileUpload/PBAwindows'; -const CONFIGURATION_TABS = { - ATTACK: 'attack', - BASIC: 'basic', - BASIC_NETWORK: 'basic_network', - RANSOMWARE: 'ransomware', - MONKEY: 'monkey', - INTERNAL: 'internal' -}; class ConfigurePageComponent extends AuthComponent { @@ -67,30 +60,9 @@ class ConfigurePageComponent extends AuthComponent { // } // ); - let advancedModeConfigTabs = [ - CONFIGURATION_TABS.ATTACK, - CONFIGURATION_TABS.BASIC, - CONFIGURATION_TABS.BASIC_NETWORK, - CONFIGURATION_TABS.RANSOMWARE, - CONFIGURATION_TABS.MONKEY, - CONFIGURATION_TABS.INTERNAL - ] - - let ransomwareModeConfigTabs = [ - CONFIGURATION_TABS.BASIC, - CONFIGURATION_TABS.BASIC_NETWORK, - CONFIGURATION_TABS.RANSOMWARE - ] - - let mode = 'ransomware'; - // let mode = ''; - - if (mode === 'ransomware') { - return ransomwareModeConfigTabs; - } - else { - return advancedModeConfigTabs; - } + // let mode = 'ransomware'; + let mode = 'advanced'; + return CONFIGURATION_TABS_PER_MODE[mode]; } setInitialConfig(config) {