From 917d7dfb1530ddc01484f914f9237eede9333e50 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 14 Jul 2021 18:22:19 +0530 Subject: [PATCH] cc: Get configuration tabs' order based on Island mode --- .../ui/src/components/pages/ConfigurePage.js | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) 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 1cdf7d001..00deb8e60 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -23,15 +23,23 @@ 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 { constructor(props) { super(props); - this.currentSection = 'attack'; this.initialConfig = {}; this.initialAttackConfig = {}; - this.sectionsOrder = ['attack', 'basic', 'basic_network', 'ransomware', 'monkey', 'internal']; + this.sectionsOrder = this.getSectionsOrder(); + this.currentSection = this.sectionsOrder[0]; this.state = { attackConfig: {}, @@ -41,7 +49,7 @@ class ConfigurePageComponent extends AuthComponent { lastAction: 'none', schema: {}, sections: [], - selectedSection: 'attack', + selectedSection: this.currentSection, showAttackAlert: false, showUnsafeOptionsConfirmation: false, showUnsafeAttackOptionsWarning: false, @@ -50,6 +58,41 @@ class ConfigurePageComponent extends AuthComponent { }; } + getSectionsOrder() { // TODO: Fetch mode from API endpoint + // let mode = ""; + // this.authFetch('/api/mode') + // .then(res => res.json()) + // .then(res => { + // mode = res.mode + // } + // ); + + 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; + } + } + setInitialConfig(config) { // Sets a reference to know if config was changed this.initialConfig = JSON.parse(JSON.stringify(config));