diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index e86d03b356..c8daab42ff 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -1124,10 +1124,12 @@ class Browser extends DashboardView { columnsObject[column.name] = column }); // get ordered list of class columns + const columnPreferences = this.context.currentApp.columnPreference || {} const columns = ColumnPreferences.getOrder( columnsObject, this.context.currentApp.applicationId, - className + className, + columnPreferences[className] ); // extend columns with their type and targetClass properties columns.forEach(column => { diff --git a/src/dashboard/Data/Browser/DataBrowser.react.js b/src/dashboard/Data/Browser/DataBrowser.react.js index 096038b53a..5aace26c86 100644 --- a/src/dashboard/Data/Browser/DataBrowser.react.js +++ b/src/dashboard/Data/Browser/DataBrowser.react.js @@ -24,12 +24,13 @@ export default class DataBrowser extends React.Component { constructor(props, context) { super(props, context); + const columnPreferences = context.currentApp.columnPreference || {} let order = ColumnPreferences.getOrder( props.columns, context.currentApp.applicationId, - props.className + props.className, + columnPreferences[props.className] ); - this.state = { order: order, current: null, @@ -52,10 +53,12 @@ export default class DataBrowser extends React.Component { componentWillReceiveProps(props, context) { if (props.className !== this.props.className) { + const columnPreferences = context.currentApp.columnPreference || {} let order = ColumnPreferences.getOrder( props.columns, context.currentApp.applicationId, - props.className + props.className, + columnPreferences[props.className] ); this.setState({ order: order, @@ -65,10 +68,12 @@ export default class DataBrowser extends React.Component { }); } else if (Object.keys(props.columns).length !== Object.keys(this.props.columns).length || (props.isUnique && props.uniqueField !== this.props.uniqueField)) { + const columnPreferences = context.currentApp.columnPreference || {} let order = ColumnPreferences.getOrder( props.columns, context.currentApp.applicationId, - props.className + props.className, + columnPreferences[props.className] ); this.setState({ order }); } diff --git a/src/lib/ColumnPreferences.js b/src/lib/ColumnPreferences.js index e43768a620..667dcf576a 100644 --- a/src/lib/ColumnPreferences.js +++ b/src/lib/ColumnPreferences.js @@ -71,8 +71,12 @@ export function getColumnSort(sortBy, appId, className) { return currentSort; } -export function getOrder(cols, appId, className) { +export function getOrder(cols, appId, className, defaultPrefs) { + let prefs = getPreferences(appId, className) || [ { name: 'objectId', width: DEFAULT_WIDTH, visible: true } ]; + if (defaultPrefs) { + prefs = defaultPrefs; + } let order = [].concat(prefs); let seen = {}; for (let i = 0; i < order.length; i++) { @@ -83,7 +87,7 @@ export function getOrder(cols, appId, className) { for (let name in cols) { requested[name] = true; if (!seen[name]) { - order.push({ name: name, width: DEFAULT_WIDTH, visible: true }); + order.push({ name: name, width: DEFAULT_WIDTH, visible: !defaultPrefs }); seen[name] = true; updated = true; } diff --git a/src/lib/ParseApp.js b/src/lib/ParseApp.js index 0065109f06..6cf0881f2b 100644 --- a/src/lib/ParseApp.js +++ b/src/lib/ParseApp.js @@ -43,7 +43,8 @@ export default class ParseApp { secondaryBackgroundColor, supportedPushLocales, preventSchemaEdits, - graphQLServerURL + graphQLServerURL, + columnPreference }) { this.name = appName; this.createdAt = created_at ? new Date(created_at) : new Date(); @@ -69,6 +70,7 @@ export default class ParseApp { this.supportedPushLocales = supportedPushLocales ? supportedPushLocales : []; this.preventSchemaEdits = preventSchemaEdits || false; this.graphQLServerURL = graphQLServerURL; + this.columnPreference = columnPreference; if(!supportedPushLocales) { console.warn('Missing push locales for \'' + appName + '\', see this link for details on setting localizations up. https://github.com/parse-community/parse-dashboard#configuring-localized-push-notifications');