diff --git a/dashboard/Dashboard.js b/dashboard/Dashboard.js index 81e2d1e690..76726ae371 100644 --- a/dashboard/Dashboard.js +++ b/dashboard/Dashboard.js @@ -28,6 +28,7 @@ import JobsForm from 'dashboard/Data/Jobs/JobsForm.react'; import Loader from 'components/Loader/Loader.react'; import Logs from './Data/Logs/Logs.react'; import Migration from './Data/Migration/Migration.react'; +import ParseApp from 'lib/ParseApp'; import Performance from './Analytics/Performance/Performance.react'; import PushAudiencesIndex from './Push/PushAudiencesIndex.react'; import PushDetails from './Push/PushDetails.react'; @@ -104,79 +105,35 @@ class Dashboard extends React.Component { cloudCode: { viewCode: true, }, - webhooks: { - createWebhook: false, - readWebhook: false, - updateWebhook: false, - deleteWebhook: false, - }, //webhooks requires removal of heroku link code, then it should work. - jobs: { - startJob: false, - scheduleJob: false, - scheduleRecurringJob: false, - }, //jobs still goes through rails + hooks: { + create: true, + read: true, + update: true, + delete: true, + }, logs: { info: true, error: true, }, - config: { - createConfig: true, - readConfig: true, - updateConfig: true, - deleteConfig: true, - }, - push: { //These all go through rails - instantPush: false, - scheduledPush: false, - storedPushData: false, - pushAudiences: false, - }, - analytics: { - slowQueries: false, - performanceAnalysis: false, - retentionAnalysis: false, + globalConfig: { + create: true, + read: true, + update: true, + delete: true, }, - settings: { - appName: { - type: 'string', - read: false, - write: false, - }, - // other settings can have arbitrary types and other info - // someSetting: { - // type: 'enum', - // read: true, - // write: true, - // values: ['foo', 'bar', 'baz'] - // }, - // replyToAddress: { - // type: 'emailAddress', - // read: true, - // write: true, - // }, - // exportData: { - // type: 'trigger', - // dangerous: false, - // }, - // deleteApp: { - // type: 'trigger', - // dangerous: true, - // }, - } } AppsManager.addApp(app) } else { - //get(app.serverURL + '/dashboard_features') TODO: un-stub this once the endpoint exists in parse-server, and adjust config loading success handling. - app.enabledFeatures = { - schemas: { - addField: true, - removeField: true, - addClass: true, - removeClass: true, - clearAllDataFromClass: false, - }, - } - AppsManager.addApp(app) + new ParseApp(app).apiRequest( + 'GET', + 'features', + {}, + { useMasterKey: true } + ).then(enabledFeatures => { + app.enabledFeatures = enabledFeatures; + AppsManager.addApp(app) + this.forceUpdate(); + }); } }); this.setState({ configLoadingState: AsyncStatus.SUCCESS }); diff --git a/dashboard/DashboardView.react.js b/dashboard/DashboardView.react.js index c05793f00e..1db04ebb23 100644 --- a/dashboard/DashboardView.react.js +++ b/dashboard/DashboardView.react.js @@ -27,45 +27,56 @@ export default class DashboardView extends React.Component { let features = this.context.currentApp.enabledFeatures; - let anyTruthyKeys = object => typeof object == 'object' && Object.keys(object).some(key => object[key]); - let coreSubsections = []; - if (anyTruthyKeys(features.schemas)) { + if (features.schemas && + features.schemas.addField && + features.schemas.removeField && + features.schemas.addClass && + features.schemas.removeClass) { coreSubsections.push({ name: 'Browser', link: '/browser' }); } - if (anyTruthyKeys(features.cloudCode)) { + if (features.cloudCode && features.cloudCode.viewCode) { coreSubsections.push({ name: 'Cloud Code', link: '/cloud_code' }); } - if (anyTruthyKeys(features.webhooks)) { + //webhooks requires removal of heroku link code, then it should work. + /* + if (features.hooks && features.hooks.create && features.hooks.read && features.hooks.update && features.hooks.delete) { coreSubsections.push({ name: 'Webhooks', link: '/webhooks' }); } + */ - if (anyTruthyKeys(features.jobs)) { + /* Jobs not supported + if (...) { coreSubsections.push({ name: 'Jobs', link: '/jobs' }); } + */ - if (anyTruthyKeys(features.logs)) { + if (features.logs && features.logs.info && features.logs.error) { coreSubsections.push({ name: 'Logs', link: '/logs' }); } - if (anyTruthyKeys(features.config)) { + if (features.globalConfig && + features.globalConfig.create && + features.globalConfig.read && + features.globalConfig.update && + features.globalConfig.delete) { coreSubsections.push({ name: 'Config', link: '/config' @@ -85,8 +96,9 @@ export default class DashboardView extends React.Component { } let pushSubsections = []; - // The current UI requires instant and scheduled push (and other stuff) - if (features.push && features.push.instantPush && features.push.scheduledPush) { + // The push UI requires immediate and scheduled push (and some ruby endpoints that we will have to remove) + /* + if (features.push && features.push.immediatePush && features.push.scheduledPush) { pushSubsections({ name: 'Send New Push', link: '/push/activity' @@ -105,27 +117,28 @@ export default class DashboardView extends React.Component { name: 'Audiences', link: '/push/audiences' }); - } + }*/ let analyticsSidebarSections = []; //These analytics pages may never make it into parse server /* - if (features.analyticsOverview) { + if (...) { analyticsSidebarSections.push({ name: 'Overview', link: '/analytics/overview' }); } - if (features.explorer) { + if (...) { analyticsSidebarSections.push({ name: 'Explorer', link: '/analytics/explorer' }); }*/ - //These ones might + //These ones might, but require some endpoints to added to Parse Server + /* if (features.analytics && features.analytics.retentionAnalysis) { analyticsSidebarSections.push({ name: 'Retention', @@ -146,10 +159,11 @@ export default class DashboardView extends React.Component { link: '/analytics/slow_queries' }); } + */ let settingsSections = []; - // Settings - nothing remotely like this in parse-server yet. + // Settings - nothing remotely like this in parse-server yet. Maybe it will arrive soon. /* if (features.generalSettings) { settingsSections.push({