From 436fba39edd3bcc912958673ea2ac6f9ba3678c7 Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Thu, 19 Sep 2024 17:42:51 -0700 Subject: [PATCH] Add validate all tabs func on mount --- .../389-console/src/lib/server/settings.jsx | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/cockpit/389-console/src/lib/server/settings.jsx b/src/cockpit/389-console/src/lib/server/settings.jsx index f309c8b4e..ca1ed375c 100644 --- a/src/cockpit/389-console/src/lib/server/settings.jsx +++ b/src/cockpit/389-console/src/lib/server/settings.jsx @@ -178,6 +178,7 @@ export class ServerSettings extends React.Component { ]; this.validatePaths = this.validatePaths.bind(this); + this.validateAllTabs = this.validateAllTabs.bind(this); this.handleChange = this.handleChange.bind(this); this.loadConfig = this.loadConfig.bind(this); this.handleSaveConfig = this.handleSaveConfig.bind(this); @@ -218,7 +219,7 @@ export class ServerSettings extends React.Component { this.loadConfig(); } else { this.props.enableTree(); - // TODO: this.validateSaveBtn() on all tabs? test this + this.validateAllTabs(); } } @@ -377,6 +378,30 @@ export class ServerSettings extends React.Component { }, () => { this.validateSaveBtn(nav_tab, attr, value) }); } + validateAllTabs() { + const tabs = ['config', 'rootdn', 'diskmon', 'adv']; + tabs.forEach(tab => { + let attrs; + switch (tab) { + case 'config': + attrs = general_attrs; + break; + case 'rootdn': + attrs = rootdn_attrs; + break; + case 'diskmon': + attrs = disk_attrs; + break; + case 'adv': + attrs = adv_attrs; + break; + } + attrs.forEach(attr => { + this.validateSaveBtn(tab, attr, this.state[attr]); + }); + }); + } + loadConfig() { const attrs = this.state.attrs; // Handle the checkbox values