From c0514e13593651e3ffb05f2bb7b4b2429b89ce24 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 14 Jul 2021 14:26:14 -0400 Subject: [PATCH] Island: Pass island mode as a prop to ConfigurePageComponent --- .../cc/ui/src/components/Main.js | 1 + .../ui/src/components/pages/ConfigurePage.js | 20 +++++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/Main.js b/monkey/monkey_island/cc/ui/src/components/Main.js index c068b9caf..7a7851af8 100644 --- a/monkey/monkey_island/cc/ui/src/components/Main.js +++ b/monkey/monkey_island/cc/ui/src/components/Main.js @@ -155,6 +155,7 @@ class AppComponent extends AuthComponent { true)} {this.renderRoute('/configure', )} {this.renderRoute('/run-monkey', 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 26141b22c..4f1df6bab 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -31,8 +31,7 @@ class ConfigurePageComponent extends AuthComponent { super(props); this.initialConfig = {}; this.initialAttackConfig = {}; - this.sectionsOrder = this.getSectionsOrder(); - this.currentSection = this.sectionsOrder[0]; + this.currentSection = this.getSectionsOrder()[0]; this.state = { attackConfig: {}, @@ -51,18 +50,9 @@ 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 mode = 'ransomware'; - let mode = 'advanced'; - return CONFIGURATION_TABS_PER_MODE[mode]; + getSectionsOrder() { + let islandMode = this.props.islandMode ? this.props.islandMode : 'advanced' + return CONFIGURATION_TABS_PER_MODE[islandMode]; } setInitialConfig(config) { @@ -85,7 +75,7 @@ class ConfigurePageComponent extends AuthComponent { let monkeyConfig = data[0]; this.setInitialConfig(monkeyConfig.configuration); this.setInitialAttackConfig(attackConfig.configuration); - for (let sectionKey of this.sectionsOrder) { + for (let sectionKey of this.getSectionsOrder()) { if (sectionKey === 'attack') { sections.push({key: sectionKey, title: 'ATT&CK'}) } else {