Skip to content
4 changes: 4 additions & 0 deletions src/dashboard/Data/Browser/Browser.scss
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,8 @@ body:global(.expanded) {

.noScroll {
overflow-x: hidden;
}

.confirmConfig {
padding: 10px 20px;
}
49 changes: 48 additions & 1 deletion src/dashboard/Data/Config/Config.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -38,6 +39,7 @@ class Config extends TableView {
modalValue: '',
modalMasterKeyOnly: false,
loading: false,
confirmModalOpen: false,
};
}

Expand All @@ -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 });
});
}
Expand Down Expand Up @@ -101,6 +104,30 @@ class Config extends TableView {
/>
);
}

if (this.state.confirmModalOpen) {
extras = (
<Modal
type={Modal.Types.INFO}
icon="warn-outline"
title={'Are you sure?'}
confirmText="Continue"
cancelText="Cancel"
onCancel={() => this.setState({ confirmModalOpen: false })}
onConfirm={() => {
this.setState({ confirmModalOpen: false });
this.saveParam({
...this.confirmData,
override: true,
});
}}
>
<div className={[browserStyles.confirmConfig]}>
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?
</div>
</Modal>
);
}
return extras;
}

Expand Down Expand Up @@ -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,
Expand Down
Loading