@@ -58,12 +58,14 @@ class Config extends TableView {
58
58
this . loadData ( ) ;
59
59
}
60
60
61
- loadData ( ) {
61
+ async loadData ( ) {
62
62
this . setState ( { loading : true } ) ;
63
- this . props . config . dispatch ( ActionTypes . FETCH ) . finally ( ( ) => {
63
+ try {
64
+ await this . props . config . dispatch ( ActionTypes . FETCH ) ;
64
65
this . cacheData = new Map ( this . props . config . data ) ;
66
+ } finally {
65
67
this . setState ( { loading : false } ) ;
66
- } ) ;
68
+ }
67
69
}
68
70
69
71
renderToolbar ( ) {
@@ -133,8 +135,8 @@ class Config extends TableView {
133
135
return extras ;
134
136
}
135
137
136
- renderRow ( data ) {
137
- let value = data . value ;
138
+ parseValueForModal ( dataValue ) {
139
+ let value = dataValue ;
138
140
let modalValue = value ;
139
141
let type = typeof value ;
140
142
@@ -149,11 +151,11 @@ class Config extends TableView {
149
151
} else if ( value instanceof Parse . GeoPoint ) {
150
152
type = 'GeoPoint' ;
151
153
value = `(${ value . latitude } , ${ value . longitude } )` ;
152
- modalValue = data . value . toJSON ( ) ;
153
- } else if ( data . value instanceof Parse . File ) {
154
+ modalValue = dataValue . toJSON ( ) ;
155
+ } else if ( dataValue instanceof Parse . File ) {
154
156
type = 'File' ;
155
157
value = (
156
- < a target = "_blank" href = { data . value . url ( ) } rel = "noreferrer" >
158
+ < a target = "_blank" href = { dataValue . url ( ) } rel = "noreferrer" >
157
159
Open in new window
158
160
</ a >
159
161
) ;
@@ -168,14 +170,53 @@ class Config extends TableView {
168
170
}
169
171
type = type . substr ( 0 , 1 ) . toUpperCase ( ) + type . substr ( 1 ) ;
170
172
}
171
- const openModal = ( ) =>
173
+
174
+ return {
175
+ value : value ,
176
+ modalValue : modalValue ,
177
+ type : type ,
178
+ } ;
179
+ }
180
+
181
+ renderRow ( data ) {
182
+ // Parse modal data
183
+ const { value, modalValue, type } = this . parseValueForModal ( data . value ) ;
184
+
185
+ /**
186
+ * Opens the modal dialog to edit the Config parameter.
187
+ */
188
+ const openModal = async ( ) => {
189
+
190
+ // Show dialog
172
191
this . setState ( {
192
+ loading : true ,
173
193
modalOpen : true ,
174
194
modalParam : data . param ,
175
195
modalType : type ,
176
196
modalValue : modalValue ,
177
197
modalMasterKeyOnly : data . masterKeyOnly ,
178
198
} ) ;
199
+
200
+ // Fetch config data
201
+ await this . loadData ( ) ;
202
+
203
+ // Get latest param values
204
+ const fetchedParams = this . props . config . data . get ( 'params' ) ;
205
+ const fetchedValue = fetchedParams . get ( this . state . modalParam ) ;
206
+ const fetchedMasterKeyOnly = this . props . config . data . get ( 'masterKeyOnly' ) ?. get ( this . state . modalParam ) || false ;
207
+
208
+ // Parse fetched data
209
+ const { modalValue : fetchedModalValue } = this . parseValueForModal ( fetchedValue ) ;
210
+
211
+ // Update dialog
212
+ this . setState ( {
213
+ modalValue : fetchedModalValue ,
214
+ modalMasterKeyOnly : fetchedMasterKeyOnly ,
215
+ loading : false ,
216
+ } ) ;
217
+ } ;
218
+
219
+ // Define column styles
179
220
const columnStyleLarge = { width : '30%' , cursor : 'pointer' } ;
180
221
const columnStyleSmall = { width : '15%' , cursor : 'pointer' } ;
181
222
0 commit comments