From 36e4987f95c780c78f96beecab5be36c618a6eb5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 27 Apr 2025 20:23:48 +1000 Subject: [PATCH 1/3] feat: confirmation on config param update --- src/dashboard/Data/Browser/Browser.scss | 4 ++ src/dashboard/Data/Config/Config.react.js | 49 ++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/dashboard/Data/Browser/Browser.scss b/src/dashboard/Data/Browser/Browser.scss index 331e444ea4..e47ff5ac5c 100644 --- a/src/dashboard/Data/Browser/Browser.scss +++ b/src/dashboard/Data/Browser/Browser.scss @@ -270,4 +270,8 @@ body:global(.expanded) { .noScroll { overflow-x: hidden; +} + +.confimConfig { + padding: 10px 20px; } \ No newline at end of file diff --git a/src/dashboard/Data/Config/Config.react.js b/src/dashboard/Data/Config/Config.react.js index 005cc032c3..56f9125c23 100644 --- a/src/dashboard/Data/Config/Config.react.js +++ b/src/dashboard/Data/Config/Config.react.js @@ -21,6 +21,7 @@ import TableView from 'dashboard/TableView.react'; import Toolbar from 'components/Toolbar/Toolbar.react'; import browserStyles from 'dashboard/Data/Browser/Browser.scss'; import { CurrentApp } from 'context/currentApp'; +import Modal from 'components/Modal/Modal.react'; @subscribeTo('Config', 'config') class Config extends TableView { @@ -38,6 +39,7 @@ class Config extends TableView { modalValue: '', modalMasterKeyOnly: false, loading: false, + confirmModalOpen: false, }; } @@ -58,6 +60,7 @@ class Config extends TableView { loadData() { this.setState({ loading: true }); this.props.config.dispatch(ActionTypes.FETCH).finally(() => { + this.cacheData = new Map(this.props.config.data); this.setState({ loading: false }); }); } @@ -101,6 +104,30 @@ class Config extends TableView { /> ); } + + if (this.state.confirmModalOpen) { + extras = ( + this.setState({ confirmModalOpen: false })} + onConfirm={() => { + this.setState({ confirmModalOpen: false }); + this.saveParam({ + ...this.confirmData, + override: true, + }); + }} + > +
+ The parameter you are trying to edit has been modified by another user. Do you want to continue? +
+
+ ); + } return extras; } @@ -244,7 +271,27 @@ class Config extends TableView { return data; } - saveParam({ name, value, type, masterKeyOnly }) { + async saveParam({ name, value, type, masterKeyOnly, override }) { + const cachedParams = this.cacheData.get('params'); + const cachedValue = cachedParams.get(name); + + await this.props.config.dispatch(ActionTypes.FETCH); + const fetchedParams = this.props.config.data.get('params'); + + if (cachedValue !== fetchedParams.get(name) && !override) { + this.setState({ + confirmModalOpen: true, + modalOpen: false, + }); + this.confirmData = { + name, + value, + type, + masterKeyOnly, + }; + return; + } + this.props.config .dispatch(ActionTypes.SET, { param: name, From 880c3e38731a8aa4ab570b1863efc5d559811186 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Tue, 29 Apr 2025 02:29:03 +0100 Subject: [PATCH 2/3] fix typo Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com> --- src/dashboard/Data/Browser/Browser.scss | 2 +- src/dashboard/Data/Config/Config.react.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dashboard/Data/Browser/Browser.scss b/src/dashboard/Data/Browser/Browser.scss index e47ff5ac5c..705580ce9d 100644 --- a/src/dashboard/Data/Browser/Browser.scss +++ b/src/dashboard/Data/Browser/Browser.scss @@ -272,6 +272,6 @@ body:global(.expanded) { overflow-x: hidden; } -.confimConfig { +.confirmConfig { padding: 10px 20px; } \ No newline at end of file diff --git a/src/dashboard/Data/Config/Config.react.js b/src/dashboard/Data/Config/Config.react.js index 56f9125c23..f02a85c28c 100644 --- a/src/dashboard/Data/Config/Config.react.js +++ b/src/dashboard/Data/Config/Config.react.js @@ -122,7 +122,7 @@ class Config extends TableView { }); }} > -
+
The parameter you are trying to edit has been modified by another user. Do you want to continue?
From aea4d1fbd55411f86be3ccedb1ba55a8546bacee Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Tue, 29 Apr 2025 02:55:49 +0100 Subject: [PATCH 3/3] rephrase dialog Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com> --- src/dashboard/Data/Config/Config.react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dashboard/Data/Config/Config.react.js b/src/dashboard/Data/Config/Config.react.js index f02a85c28c..88ebcf82ea 100644 --- a/src/dashboard/Data/Config/Config.react.js +++ b/src/dashboard/Data/Config/Config.react.js @@ -123,7 +123,7 @@ class Config extends TableView { }} >
- The parameter you are trying to edit has been modified by another user. Do you want to continue? + The parameter you are trying to save has been modified while you were editing it. This means your edit is not based on the current parameter value. Do you want to continue and overwrite the other changes?
);