From 06a4aba54db5f3b6439bb266b0007537a74c30cb Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Tue, 20 Aug 2019 16:33:16 +0200 Subject: [PATCH 1/5] add master key only UI --- src/dashboard/Data/Config/Config.react.js | 35 +++++++++++-------- .../Data/Config/ConfigDialog.react.js | 16 ++++++++- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/dashboard/Data/Config/Config.react.js b/src/dashboard/Data/Config/Config.react.js index 2cf56d3691..d69dd7f70a 100644 --- a/src/dashboard/Data/Config/Config.react.js +++ b/src/dashboard/Data/Config/Config.react.js @@ -30,7 +30,8 @@ class Config extends TableView { modalOpen: false, modalParam: '', modalType: 'String', - modalValue: '' + modalValue: '', + modalMasterKeyOnly: false }; } @@ -64,7 +65,8 @@ class Config extends TableView { onCancel={() => this.setState({ modalOpen: false })} param={this.state.modalParam} type={this.state.modalType} - value={this.state.modalValue} /> + value={this.state.modalValue} + masterKeyOnly={this.state.modalMasterKeyOnly} /> ); } @@ -103,9 +105,11 @@ class Config extends TableView { modalOpen: true, modalParam: data.param, modalType: type, - modalValue: modalValue + modalValue: modalValue, + modalMasterKeyOnly: data.masterKeyOnly }); - let columnStyle = { width: '30%', cursor: 'pointer' }; + let columnStyleLarge = { width: '30%', cursor: 'pointer' }; + let columnStyleSmall = { width: '15%', cursor: 'pointer' }; let openModalValueColumn = () => { if (data.value instanceof Parse.File) { @@ -116,9 +120,10 @@ class Config extends TableView { return ( - {data.param} - {type} - {value} + {data.param} + {type} + {value} + {data.masterKeyOnly.toString()} @@ -131,8 +136,9 @@ class Config extends TableView { renderHeaders() { return [ Parameter, - Type, - Value + Type, + Value, + Master key only ]; } @@ -151,20 +157,20 @@ class Config extends TableView { let data = undefined; if (this.props.config.data) { let params = this.props.config.data.get('params'); + let masterKeyOnlyParams = this.props.config.data.get('masterKeyOnly'); if (params) { data = []; params.forEach((value, param) => { let type = typeof value; + let masterKeyOnly = masterKeyOnlyParams !== undefined && masterKeyOnlyParams.includes(value); if (type === 'object' && value.__type == 'File') { value = Parse.File.fromJSON(value); } else if (type === 'object' && value.__type == 'GeoPoint') { value = new Parse.GeoPoint(value); } - - data.push({ param: param, value: value }) + data.push({ param: param, value: value, masterKeyOnly: masterKeyOnly }) }); - data.sort((object1, object2) => { return object1.param.localeCompare(object2.param); }); @@ -176,7 +182,7 @@ class Config extends TableView { saveParam({ name, value }) { this.props.config.dispatch( ActionTypes.SET, - { param: name, value: value } + { param: name, value: value, masterKeyOnly: masterKeyOnly } ).then(() => { this.setState({ modalOpen: false }); }, () => { @@ -196,7 +202,8 @@ class Config extends TableView { modalOpen: true, modalParam: '', modalType: 'String', - modalValue: '' + modalValue: '', + modalMasterKeyOnly: false }); } } diff --git a/src/dashboard/Data/Config/ConfigDialog.react.js b/src/dashboard/Data/Config/ConfigDialog.react.js index 75d73d147d..bb23233b85 100644 --- a/src/dashboard/Data/Config/ConfigDialog.react.js +++ b/src/dashboard/Data/Config/ConfigDialog.react.js @@ -108,13 +108,15 @@ export default class ConfigDialog extends React.Component { this.state = { value: null, type: 'String', - name: '' + name: '', + masterKeyOnly: false }; if (props.param.length > 0) { this.state = { name: props.param, type: props.type, value: props.value, + masterKeyOnly: props.masterKeyOnly }; } } @@ -228,6 +230,18 @@ export default class ConfigDialog extends React.Component { description='Use this to configure your app. You can change it at any time.' /> } input={EDITORS[this.state.type](this.state.value, (value) => { this.setState({ value }) })} /> + + } + input={ + this.setState({ masterKeyOnly })} /> + } /> ); } From 4849c85be95888237d7e8853cd5f88dd1416fdc4 Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Tue, 20 Aug 2019 19:06:58 +0200 Subject: [PATCH 2/5] added saving, retrieving --- src/dashboard/Data/Config/Config.react.js | 6 +++--- src/dashboard/Data/Config/ConfigDialog.react.js | 1 + src/lib/stores/ConfigStore.js | 11 +++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/dashboard/Data/Config/Config.react.js b/src/dashboard/Data/Config/Config.react.js index d69dd7f70a..b3b37f2a03 100644 --- a/src/dashboard/Data/Config/Config.react.js +++ b/src/dashboard/Data/Config/Config.react.js @@ -157,12 +157,12 @@ class Config extends TableView { let data = undefined; if (this.props.config.data) { let params = this.props.config.data.get('params'); - let masterKeyOnlyParams = this.props.config.data.get('masterKeyOnly'); + let masterKeyOnlyParams = this.props.config.data.get('masterKeyOnly') || {}; if (params) { data = []; params.forEach((value, param) => { + let masterKeyOnly = masterKeyOnlyParams.get(param) || false; let type = typeof value; - let masterKeyOnly = masterKeyOnlyParams !== undefined && masterKeyOnlyParams.includes(value); if (type === 'object' && value.__type == 'File') { value = Parse.File.fromJSON(value); } @@ -179,7 +179,7 @@ class Config extends TableView { return data; } - saveParam({ name, value }) { + saveParam({ name, value, masterKeyOnly }) { this.props.config.dispatch( ActionTypes.SET, { param: name, value: value, masterKeyOnly: masterKeyOnly } diff --git a/src/dashboard/Data/Config/ConfigDialog.react.js b/src/dashboard/Data/Config/ConfigDialog.react.js index bb23233b85..efaa97cb6f 100644 --- a/src/dashboard/Data/Config/ConfigDialog.react.js +++ b/src/dashboard/Data/Config/ConfigDialog.react.js @@ -178,6 +178,7 @@ export default class ConfigDialog extends React.Component { this.props.onConfirm({ name: this.state.name, value: GET_VALUE[this.state.type](this.state.value), + masterKeyOnly: this.state.masterKeyOnly }); } diff --git a/src/lib/stores/ConfigStore.js b/src/lib/stores/ConfigStore.js index 340e7f0ea4..d30907b800 100644 --- a/src/lib/stores/ConfigStore.js +++ b/src/lib/stores/ConfigStore.js @@ -16,6 +16,7 @@ export const ActionTypes = keyMirror(['FETCH', 'SET', 'DELETE']); // Config state should be an Immutable Map with the following fields: // - lastFetch: the last time all data was fetched from the server // - params: An Immutable Map of parameter strings to values +// - masterKeyOnly: An Immutable Map of parameter properties for read with master key only function ConfigStore(state, action) { action.app.setParseKeys(); @@ -27,22 +28,24 @@ function ConfigStore(state, action) { {}, { useMasterKey: true } ).then((result) => { - return Map({ lastFetch: new Date(), params: Map(result.params) }); + return Map({ lastFetch: new Date(), params: Map(result.params), masterKeyOnly: Map(result.masterKeyOnly) }); }); case ActionTypes.SET: return Parse._request( 'PUT', 'config', - { params: { [action.param]: Parse._encode(action.value) } }, + { params: { [action.param]: Parse._encode(action.value) }, masterKeyOnly: { [action.param]: action.masterKeyOnly} }, { useMasterKey: true } ).then(() => { - return state.setIn(['params', action.param], action.value); + return state + .setIn(['params', action.param], action.value) + .setIn(['masterKeyOnly', action.param], action.masterKeyOnly); }); case ActionTypes.DELETE: return Parse._request( 'PUT', 'config', - { params: { [action.param]: { __op: 'Delete' } } }, + { params: { [action.param]: { __op: 'Delete' } }, masterKeyOnly: { [action.param]: { __op: 'Delete' } } }, { useMasterKey: true } ).then(() => { return state.deleteIn(['params', action.param]); From e0f2e567683bd9cb0606726f30b99784c354179e Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Wed, 21 Aug 2019 12:11:31 +0200 Subject: [PATCH 3/5] fixed style and wording --- src/dashboard/Data/Config/ConfigDialog.react.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dashboard/Data/Config/ConfigDialog.react.js b/src/dashboard/Data/Config/ConfigDialog.react.js index efaa97cb6f..5db6e4bd9e 100644 --- a/src/dashboard/Data/Config/ConfigDialog.react.js +++ b/src/dashboard/Data/Config/ConfigDialog.react.js @@ -18,6 +18,7 @@ import React from 'react'; import TextInput from 'components/TextInput/TextInput.react'; import Toggle from 'components/Toggle/Toggle.react'; import validateNumeric from 'lib/validateNumeric'; +import styles from 'dashboard/Data/Browser/Browser.scss'; const PARAM_TYPES = [ 'Boolean', @@ -234,15 +235,18 @@ export default class ConfigDialog extends React.Component { } input={ this.setState({ masterKeyOnly })} /> - } /> + onChange={(masterKeyOnly) => this.setState({ masterKeyOnly })} + additionalStyles={{ margin: '0px' }} /> + } + className={styles.addColumnToggleWrapper} + /> ); } From 2ff23288e1c283cb07dd35a3adc608c81a98a70e Mon Sep 17 00:00:00 2001 From: Manuel Date: Wed, 21 Aug 2019 14:38:48 +0200 Subject: [PATCH 4/5] Improved parameter explanation Co-Authored-By: Tom Fox --- src/dashboard/Data/Config/ConfigDialog.react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dashboard/Data/Config/ConfigDialog.react.js b/src/dashboard/Data/Config/ConfigDialog.react.js index 5db6e4bd9e..8060086d3f 100644 --- a/src/dashboard/Data/Config/ConfigDialog.react.js +++ b/src/dashboard/Data/Config/ConfigDialog.react.js @@ -236,7 +236,7 @@ export default class ConfigDialog extends React.Component { label={