@@ -21,6 +21,7 @@ import TableView from 'dashboard/TableView.react';
21
21
import Toolbar from 'components/Toolbar/Toolbar.react' ;
22
22
import browserStyles from 'dashboard/Data/Browser/Browser.scss' ;
23
23
import { CurrentApp } from 'context/currentApp' ;
24
+ import Modal from 'components/Modal/Modal.react' ;
24
25
25
26
@subscribeTo ( 'Config' , 'config' )
26
27
class Config extends TableView {
@@ -38,6 +39,7 @@ class Config extends TableView {
38
39
modalValue : '' ,
39
40
modalMasterKeyOnly : false ,
40
41
loading : false ,
42
+ confirmModalOpen : false ,
41
43
} ;
42
44
}
43
45
@@ -58,6 +60,7 @@ class Config extends TableView {
58
60
loadData ( ) {
59
61
this . setState ( { loading : true } ) ;
60
62
this . props . config . dispatch ( ActionTypes . FETCH ) . finally ( ( ) => {
63
+ this . cacheData = new Map ( this . props . config . data ) ;
61
64
this . setState ( { loading : false } ) ;
62
65
} ) ;
63
66
}
@@ -101,6 +104,30 @@ class Config extends TableView {
101
104
/>
102
105
) ;
103
106
}
107
+
108
+ if ( this . state . confirmModalOpen ) {
109
+ extras = (
110
+ < Modal
111
+ type = { Modal . Types . INFO }
112
+ icon = "warn-outline"
113
+ title = { 'Are you sure?' }
114
+ confirmText = "Continue"
115
+ cancelText = "Cancel"
116
+ onCancel = { ( ) => this . setState ( { confirmModalOpen : false } ) }
117
+ onConfirm = { ( ) => {
118
+ this . setState ( { confirmModalOpen : false } ) ;
119
+ this . saveParam ( {
120
+ ...this . confirmData ,
121
+ override : true ,
122
+ } ) ;
123
+ } }
124
+ >
125
+ < div className = { [ browserStyles . confimConfig ] } >
126
+ The parameter you are trying to edit has been modified by another user. Do you want to continue?
127
+ </ div >
128
+ </ Modal >
129
+ ) ;
130
+ }
104
131
return extras ;
105
132
}
106
133
@@ -244,7 +271,27 @@ class Config extends TableView {
244
271
return data ;
245
272
}
246
273
247
- saveParam ( { name, value, type, masterKeyOnly } ) {
274
+ async saveParam ( { name, value, type, masterKeyOnly, override } ) {
275
+ const cachedParams = this . cacheData . get ( 'params' ) ;
276
+ const cachedValue = cachedParams . get ( name ) ;
277
+
278
+ await this . props . config . dispatch ( ActionTypes . FETCH ) ;
279
+ const fetchedParams = this . props . config . data . get ( 'params' ) ;
280
+
281
+ if ( cachedValue !== fetchedParams . get ( name ) && ! override ) {
282
+ this . setState ( {
283
+ confirmModalOpen : true ,
284
+ modalOpen : false ,
285
+ } ) ;
286
+ this . confirmData = {
287
+ name,
288
+ value,
289
+ type,
290
+ masterKeyOnly,
291
+ } ;
292
+ return ;
293
+ }
294
+
248
295
this . props . config
249
296
. dispatch ( ActionTypes . SET , {
250
297
param : name ,
0 commit comments