cc: Get configuration tabs' order based on Island mode

This commit is contained in:
Shreya 2021-07-14 18:22:19 +05:30 committed by Mike Salvatore
parent 035ce6c8b0
commit 917d7dfb15
1 changed files with 46 additions and 3 deletions

View File

@ -23,15 +23,23 @@ const ATTACK_URL = '/api/attack';
const CONFIG_URL = '/api/configuration/island'; const CONFIG_URL = '/api/configuration/island';
export const API_PBA_LINUX = '/api/fileUpload/PBAlinux'; export const API_PBA_LINUX = '/api/fileUpload/PBAlinux';
export const API_PBA_WINDOWS = '/api/fileUpload/PBAwindows'; 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 { class ConfigurePageComponent extends AuthComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.currentSection = 'attack';
this.initialConfig = {}; this.initialConfig = {};
this.initialAttackConfig = {}; this.initialAttackConfig = {};
this.sectionsOrder = ['attack', 'basic', 'basic_network', 'ransomware', 'monkey', 'internal']; this.sectionsOrder = this.getSectionsOrder();
this.currentSection = this.sectionsOrder[0];
this.state = { this.state = {
attackConfig: {}, attackConfig: {},
@ -41,7 +49,7 @@ class ConfigurePageComponent extends AuthComponent {
lastAction: 'none', lastAction: 'none',
schema: {}, schema: {},
sections: [], sections: [],
selectedSection: 'attack', selectedSection: this.currentSection,
showAttackAlert: false, showAttackAlert: false,
showUnsafeOptionsConfirmation: false, showUnsafeOptionsConfirmation: false,
showUnsafeAttackOptionsWarning: 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) { setInitialConfig(config) {
// Sets a reference to know if config was changed // Sets a reference to know if config was changed
this.initialConfig = JSON.parse(JSON.stringify(config)); this.initialConfig = JSON.parse(JSON.stringify(config));