Skip to content

Commit 33d0d81

Browse files
committed
Merge pull request #28 from ParsePlatform/use-features-endpoin
Retrieve dashboard features from features endpoint
2 parents fc85d86 + 642b8cc commit 33d0d81

File tree

2 files changed

+51
-80
lines changed

2 files changed

+51
-80
lines changed

dashboard/Dashboard.js

Lines changed: 22 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import JobsForm from 'dashboard/Data/Jobs/JobsForm.react';
2828
import Loader from 'components/Loader/Loader.react';
2929
import Logs from './Data/Logs/Logs.react';
3030
import Migration from './Data/Migration/Migration.react';
31+
import ParseApp from 'lib/ParseApp';
3132
import Performance from './Analytics/Performance/Performance.react';
3233
import PushAudiencesIndex from './Push/PushAudiencesIndex.react';
3334
import PushDetails from './Push/PushDetails.react';
@@ -104,79 +105,35 @@ class Dashboard extends React.Component {
104105
cloudCode: {
105106
viewCode: true,
106107
},
107-
webhooks: {
108-
createWebhook: false,
109-
readWebhook: false,
110-
updateWebhook: false,
111-
deleteWebhook: false,
112-
}, //webhooks requires removal of heroku link code, then it should work.
113-
jobs: {
114-
startJob: false,
115-
scheduleJob: false,
116-
scheduleRecurringJob: false,
117-
}, //jobs still goes through rails
108+
hooks: {
109+
create: true,
110+
read: true,
111+
update: true,
112+
delete: true,
113+
},
118114
logs: {
119115
info: true,
120116
error: true,
121117
},
122-
config: {
123-
createConfig: true,
124-
readConfig: true,
125-
updateConfig: true,
126-
deleteConfig: true,
127-
},
128-
push: { //These all go through rails
129-
instantPush: false,
130-
scheduledPush: false,
131-
storedPushData: false,
132-
pushAudiences: false,
133-
},
134-
analytics: {
135-
slowQueries: false,
136-
performanceAnalysis: false,
137-
retentionAnalysis: false,
118+
globalConfig: {
119+
create: true,
120+
read: true,
121+
update: true,
122+
delete: true,
138123
},
139-
settings: {
140-
appName: {
141-
type: 'string',
142-
read: false,
143-
write: false,
144-
},
145-
// other settings can have arbitrary types and other info
146-
// someSetting: {
147-
// type: 'enum',
148-
// read: true,
149-
// write: true,
150-
// values: ['foo', 'bar', 'baz']
151-
// },
152-
// replyToAddress: {
153-
// type: 'emailAddress',
154-
// read: true,
155-
// write: true,
156-
// },
157-
// exportData: {
158-
// type: 'trigger',
159-
// dangerous: false,
160-
// },
161-
// deleteApp: {
162-
// type: 'trigger',
163-
// dangerous: true,
164-
// },
165-
}
166124
}
167125
AppsManager.addApp(app)
168126
} else {
169-
//get(app.serverURL + '/dashboard_features') TODO: un-stub this once the endpoint exists in parse-server, and adjust config loading success handling.
170-
app.enabledFeatures = {
171-
schemas: {
172-
addField: true,
173-
removeField: true,
174-
addClass: true,
175-
removeClass: true,
176-
clearAllDataFromClass: false,
177-
},
178-
}
179-
AppsManager.addApp(app)
127+
new ParseApp(app).apiRequest(
128+
'GET',
129+
'features',
130+
{},
131+
{ useMasterKey: true }
132+
).then(enabledFeatures => {
133+
app.enabledFeatures = enabledFeatures;
134+
AppsManager.addApp(app)
135+
this.forceUpdate();
136+
});
180137
}
181138
});
182139
this.setState({ configLoadingState: AsyncStatus.SUCCESS });

dashboard/DashboardView.react.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,56 @@ export default class DashboardView extends React.Component {
2727

2828
let features = this.context.currentApp.enabledFeatures;
2929

30-
let anyTruthyKeys = object => typeof object == 'object' && Object.keys(object).some(key => object[key]);
31-
3230
let coreSubsections = [];
33-
if (anyTruthyKeys(features.schemas)) {
31+
if (features.schemas &&
32+
features.schemas.addField &&
33+
features.schemas.removeField &&
34+
features.schemas.addClass &&
35+
features.schemas.removeClass) {
3436
coreSubsections.push({
3537
name: 'Browser',
3638
link: '/browser'
3739
});
3840
}
3941

40-
if (anyTruthyKeys(features.cloudCode)) {
42+
if (features.cloudCode && features.cloudCode.viewCode) {
4143
coreSubsections.push({
4244
name: 'Cloud Code',
4345
link: '/cloud_code'
4446
});
4547
}
4648

47-
if (anyTruthyKeys(features.webhooks)) {
49+
//webhooks requires removal of heroku link code, then it should work.
50+
/*
51+
if (features.hooks && features.hooks.create && features.hooks.read && features.hooks.update && features.hooks.delete) {
4852
coreSubsections.push({
4953
name: 'Webhooks',
5054
link: '/webhooks'
5155
});
5256
}
57+
*/
5358

54-
if (anyTruthyKeys(features.jobs)) {
59+
/* Jobs not supported
60+
if (...) {
5561
coreSubsections.push({
5662
name: 'Jobs',
5763
link: '/jobs'
5864
});
5965
}
66+
*/
6067

61-
if (anyTruthyKeys(features.logs)) {
68+
if (features.logs && features.logs.info && features.logs.error) {
6269
coreSubsections.push({
6370
name: 'Logs',
6471
link: '/logs'
6572
});
6673
}
6774

68-
if (anyTruthyKeys(features.config)) {
75+
if (features.globalConfig &&
76+
features.globalConfig.create &&
77+
features.globalConfig.read &&
78+
features.globalConfig.update &&
79+
features.globalConfig.delete) {
6980
coreSubsections.push({
7081
name: 'Config',
7182
link: '/config'
@@ -85,8 +96,9 @@ export default class DashboardView extends React.Component {
8596
}
8697
let pushSubsections = [];
8798

88-
// The current UI requires instant and scheduled push (and other stuff)
89-
if (features.push && features.push.instantPush && features.push.scheduledPush) {
99+
// The push UI requires immediate and scheduled push (and some ruby endpoints that we will have to remove)
100+
/*
101+
if (features.push && features.push.immediatePush && features.push.scheduledPush) {
90102
pushSubsections({
91103
name: 'Send New Push',
92104
link: '/push/activity'
@@ -105,27 +117,28 @@ export default class DashboardView extends React.Component {
105117
name: 'Audiences',
106118
link: '/push/audiences'
107119
});
108-
}
120+
}*/
109121

110122
let analyticsSidebarSections = [];
111123

112124
//These analytics pages may never make it into parse server
113125
/*
114-
if (features.analyticsOverview) {
126+
if (...) {
115127
analyticsSidebarSections.push({
116128
name: 'Overview',
117129
link: '/analytics/overview'
118130
});
119131
}
120132
121-
if (features.explorer) {
133+
if (...) {
122134
analyticsSidebarSections.push({
123135
name: 'Explorer',
124136
link: '/analytics/explorer'
125137
});
126138
}*/
127139

128-
//These ones might
140+
//These ones might, but require some endpoints to added to Parse Server
141+
/*
129142
if (features.analytics && features.analytics.retentionAnalysis) {
130143
analyticsSidebarSections.push({
131144
name: 'Retention',
@@ -146,10 +159,11 @@ export default class DashboardView extends React.Component {
146159
link: '/analytics/slow_queries'
147160
});
148161
}
162+
*/
149163

150164
let settingsSections = [];
151165

152-
// Settings - nothing remotely like this in parse-server yet.
166+
// Settings - nothing remotely like this in parse-server yet. Maybe it will arrive soon.
153167
/*
154168
if (features.generalSettings) {
155169
settingsSections.push({

0 commit comments

Comments
 (0)