Hide the input fields for directories to be encrypted if "Should encrypt" option is disabled

This change will enhance the UX by hiding the irrelevant inputs. This also allows us to add further logic to dynamically hide/show or otherwise modify uiSchema
This commit is contained in:
VakarisZ 2021-06-30 15:53:40 +03:00
parent 889df554ae
commit 16f97f2811
2 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -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 (<InternalConfig {...formProperties}/>)
} else {