From 3bbbca783dc2ecbe1edf116e2a0ff3c836b60c6f Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 4 Jul 2022 15:04:30 +0200 Subject: [PATCH] UI: Fix UiSchema manipulators to use payloads section --- .../configuration-components/UISchemaManipulators.tsx | 2 +- .../src/components/configuration-components/UiSchema.js | 9 +++++++++ .../cc/ui/src/components/pages/ConfigurePage.js | 7 +++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UISchemaManipulators.tsx b/monkey/monkey_island/cc/ui/src/components/configuration-components/UISchemaManipulators.tsx index 637a128f3..34ceb4ab4 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UISchemaManipulators.tsx +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UISchemaManipulators.tsx @@ -12,7 +12,7 @@ function applyUiSchemaManipulators(selectedSection, function ransomwareDirManipulator(selectedSection, formData, uiSchema) { - if (selectedSection === 'ransomware'){ + if (selectedSection === 'payloads'){ uiSchema.encryption.directories = {'ui:disabled': !formData['encryption']['enabled']}; } diff --git a/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js b/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js index 43423263f..d70a6f32c 100644 --- a/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UiSchema.js @@ -74,9 +74,18 @@ export default function UiSchema(props) { info_box : { 'ui:field': InfoBox }, + directories: { + // Directory inputs are dynamically hidden + }, text_box: { 'ui:field': TextBox + }, + enabled: { + 'ui:widget': 'hidden' } + }, + other_behaviors : { + 'ui:widget': 'hidden' } }, custom_pbas: { 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 f12e95a1c..23e21bf1a 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -74,6 +74,9 @@ class ConfigurePageComponent extends AuthComponent { .then(data => { let sections = []; let monkeyConfig = data[0]; + // TODO: Fix when we add plugins + monkeyConfig['payloads'] = monkeyConfig['payloads'][0]['options']; + this.setInitialConfig(monkeyConfig); for (let sectionKey of this.getSectionsOrder()) { sections.push({ @@ -269,10 +272,6 @@ class ConfigurePageComponent extends AuthComponent { this.currentSection = key; let selectedSectionData = this.state.configuration[key]; - if(key == 'payloads') { - selectedSectionData = this.state.configuration[key][0]['options']; - } - this.setState({ selectedSection: key, currentFormData: selectedSectionData