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 new file mode 100644 index 000000000..637a128f3 --- /dev/null +++ b/monkey/monkey_island/cc/ui/src/components/configuration-components/UISchemaManipulators.tsx @@ -0,0 +1,21 @@ + +const manipulatorList = [ransomwareDirManipulator] + +function applyUiSchemaManipulators(selectedSection, + formData, + uiSchema) { + for(let i = 0; i < manipulatorList.length; i++){ + manipulatorList[i](selectedSection, formData, uiSchema); + } +} + +function ransomwareDirManipulator(selectedSection, + formData, + uiSchema) { + if (selectedSection === 'ransomware'){ + uiSchema.encryption.directories = + {'ui:disabled': !formData['encryption']['enabled']}; + } +} + +export default applyUiSchemaManipulators; 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 19dae5fbc..310555408 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -16,6 +16,7 @@ import UnsafeOptionsWarningModal from '../configuration-components/UnsafeOptions import isUnsafeOptionSelected from '../utils/SafeOptionValidator.js'; import ConfigExportModal from '../configuration-components/ExportConfigModal'; import ConfigImportModal from '../configuration-components/ImportConfigModal'; +import applyUiSchemaManipulators from '../configuration-components/UISchemaManipulators.tsx'; const ATTACK_URL = '/api/attack'; const CONFIG_URL = '/api/configuration/island'; @@ -417,6 +418,10 @@ class ConfigurePageComponent extends AuthComponent { formProperties['className'] = 'config-form'; formProperties['liveValidate'] = true; + applyUiSchemaManipulators(this.state.selectedSection, + formProperties['formData'], + formProperties['uiSchema']); + if (this.state.selectedSection === 'internal') { return () } else {