Skip to content

Commit 4286cda

Browse files
committed
Merge pull request #13 from ParsePlatform/features-from-app
Enable app sidebar settings based on app
2 parents e11bf37 + 284e337 commit 4286cda

File tree

4 files changed

+192
-65
lines changed

4 files changed

+192
-65
lines changed

dashboard/Dashboard.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,45 @@ class Dashboard extends React.Component {
9090
componentDidMount() {
9191
let promise = get('/parse-dashboard-config.json');
9292
promise.then(({ apps }) => {
93-
AppsManager.seed(apps)
93+
apps.forEach(app => {
94+
if (app.serverURL.startsWith('https://api.parse.com/1')) {
95+
//api.parse.com doesn't have feature availability endpoint, fortunately we know which features
96+
//it supports and can hard code them
97+
app.enabledFeatures = {
98+
dataBrowser: true,
99+
cloudCode: true,
100+
webhooks: false, //webhooks requires removal of heroku link code, then it should work.
101+
jobs: false, //jobs still goes through rails
102+
logs: true,
103+
config: true,
104+
apiConsole: false, //api console needs to be modified to use server url of the app
105+
//Other features would be much harder to add, although push console should just need the hiding
106+
//of scheduled push related stuff
107+
pushConsole: false,
108+
pushIndex: false,
109+
pushAudiences: false,
110+
//Analytics is probably gone for good, but maybe someone will come up with something eventually
111+
analyticsOverview: false,
112+
explorer: false,
113+
retention: false,
114+
performance: false,
115+
slowQueryTool: false,
116+
//Settings seems reasonable to add although it will probably require brand-new endpoints
117+
generalSettings: false,
118+
keysSettings: false,
119+
usersSettings: false,
120+
pushSettings: false,
121+
hostingEmailsSettings: false,
122+
}
123+
AppsManager.addApp(app)
124+
} else {
125+
//get(app.serverURL + '/dashboard_features') TODO: un-stub this once the endpoint exists in parse-server, and adjust config loading success handling.
126+
app.enabledFeatures = {
127+
dataBrowser: true,
128+
}
129+
AppsManager.addApp(app)
130+
}
131+
});
94132
this.setState({ configLoadingState: AsyncStatus.SUCCESS });
95133
}).fail(error => {
96134
if (typeof error === 'string') {

dashboard/DashboardView.react.js

Lines changed: 149 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,104 +26,191 @@ export default class DashboardView extends React.Component {
2626
this.context.currentApp.getMigrations().promise.then(() => this.forceUpdate());
2727
}
2828

29-
let coreSubsections = [
30-
{
29+
let coreSubsections = []
30+
31+
if (this.context.currentApp.enabledFeatures.dataBrowser) {
32+
coreSubsections.push({
3133
name: 'Browser',
3234
link: '/browser'
33-
}, {
35+
});
36+
}
37+
38+
if (this.context.currentApp.enabledFeatures.cloudCode) {
39+
coreSubsections.push({
3440
name: 'Cloud Code',
3541
link: '/cloud_code'
36-
}, {
42+
});
43+
}
44+
45+
if (this.context.currentApp.enabledFeatures.webhooks) {
46+
coreSubsections.push({
3747
name: 'Webhooks',
3848
link: '/webhooks'
39-
}, {
49+
});
50+
}
51+
52+
if (this.context.currentApp.enabledFeatures.jobs) {
53+
coreSubsections.push({
4054
name: 'Jobs',
4155
link: '/jobs'
42-
}, {
56+
});
57+
}
58+
59+
if (this.context.currentApp.enabledFeatures.logs) {
60+
coreSubsections.push({
4361
name: 'Logs',
4462
link: '/logs'
45-
}, {
63+
});
64+
}
65+
66+
if (this.context.currentApp.enabledFeatures.config) {
67+
coreSubsections.push({
4668
name: 'Config',
4769
link: '/config'
48-
}, {
70+
});
71+
}
72+
73+
if (this.context.currentApp.enabledFeatures.apiConsole) {
74+
coreSubsections.push({
4975
name: 'API Console',
5076
link: '/api_console'
51-
},
52-
];
77+
});
78+
}
5379

5480
if (this.context.currentApp.migration) {
5581
coreSubsections.push({
5682
name: 'Migration',
5783
link: '/migration',
5884
});
5985
}
86+
let pushSubsections = [];
6087

61-
let appSidebarSections = [
62-
{
88+
if (this.context.currentApp.enabledFeatures.push) {
89+
pushSubsections.push({
90+
name: 'Activity',
91+
link: '/push/activity'
92+
});
93+
}
94+
95+
if (this.context.currentApp.enabledFeatures.pushAudiences) {
96+
pushSubsections.push({
97+
name: 'Audiences',
98+
link: '/push/audiences'
99+
});
100+
}
101+
102+
let analyticsSidebarSections = [];
103+
104+
if (this.context.currentApp.enabledFeatures.analyticsOverview) {
105+
analyticsSidebarSections.push({
106+
name: 'Overview',
107+
link: '/analytics/overview'
108+
});
109+
}
110+
111+
if (this.context.currentApp.enabledFeatures.explorer) {
112+
analyticsSidebarSections.push({
113+
name: 'Explorer',
114+
link: '/analytics/explorer'
115+
});
116+
}
117+
118+
if (this.context.currentApp.enabledFeatures.retention) {
119+
analyticsSidebarSections.push({
120+
name: 'Retention',
121+
link: '/analytics/retention'
122+
});
123+
}
124+
125+
if (this.context.currentApp.enabledFeatures.performance) {
126+
analyticsSidebarSections.push({
127+
name: 'Performance',
128+
link: '/analytics/performance'
129+
});
130+
}
131+
132+
if (this.context.currentApp.enabledFeatures.slowQueryTool) {
133+
analyticsSidebarSections.push({
134+
name: 'Slow Queries',
135+
link: '/analytics/slow_queries'
136+
});
137+
}
138+
139+
let settingsSections = [];
140+
141+
if (this.context.currentApp.enabledFeatures.generalSettings) {
142+
settingsSections.push({
143+
name: 'General',
144+
link: '/settings/general'
145+
});
146+
}
147+
148+
if (this.context.currentApp.enabledFeatures.keysSettings) {
149+
settingsSections.push({
150+
name: 'Security & Keys',
151+
link: '/settings/keys'
152+
});
153+
}
154+
155+
if (this.context.currentApp.enabledFeatures.usersSettings) {
156+
settingsSections.push({
157+
name: 'Users',
158+
link: '/settings/users'
159+
})
160+
}
161+
162+
if (this.context.currentApp.enabledFeatures.pushSettings) {
163+
settingsSections.push({
164+
name: 'Push',
165+
link: '/settings/push'
166+
});
167+
}
168+
169+
if (this.context.currentApp.enabledFeatures.hostingEmailsSettings) {
170+
settingsSections.push({
171+
name: 'Hosting and Emails',
172+
link: '/settings/hosting'
173+
});
174+
}
175+
176+
let appSidebarSections = []
177+
178+
if (coreSubsections.length > 0) {
179+
appSidebarSections.push({
63180
name: 'Core',
64181
icon: 'core',
65182
link: '/browser',
66183
subsections: coreSubsections,
67-
}, {
184+
});
185+
}
186+
187+
if (pushSubsections.length > 0) {
188+
appSidebarSections.push({
68189
name: 'Push',
69190
icon: 'push-outline',
70191
link: '/push',
71192
style: {paddingLeft: '16px'},
72-
subsections: [
73-
{
74-
name: 'Activity',
75-
link: '/push/activity'
76-
}, {
77-
name: 'Audiences',
78-
link: '/push/audiences'
79-
}
80-
]
81-
}, {
193+
subsections: pushSubsections,
194+
});
195+
}
196+
197+
if (analyticsSidebarSections.length > 0) {
198+
appSidebarSections.push({
82199
name: 'Analytics',
83200
icon: 'analytics-outline',
84201
link: '/analytics',
85-
subsections: [
86-
{
87-
name: 'Overview',
88-
link: '/analytics/overview'
89-
}, {
90-
name: 'Explorer',
91-
link: '/analytics/explorer'
92-
}, {
93-
name: 'Retention',
94-
link: '/analytics/retention'
95-
}, {
96-
name: 'Performance',
97-
link: '/analytics/performance'
98-
}, {
99-
name: 'Slow Queries',
100-
link: '/analytics/slow_queries'
101-
}
102-
]
103-
}, {
202+
subsections: analyticsSidebarSections
203+
});
204+
}
205+
206+
if (settingsSections.length > 0) {
207+
appSidebarSections.push({
104208
name: 'App Settings',
105209
icon: 'gear-solid',
106210
link: '/settings',
107-
subsections: [
108-
{
109-
name: 'General',
110-
link: '/settings/general'
111-
}, {
112-
name: 'Security & Keys',
113-
link: '/settings/keys'
114-
}, {
115-
name: 'Users',
116-
link: '/settings/users'
117-
}, {
118-
name: 'Push',
119-
link: '/settings/push'
120-
}, {
121-
name: 'Hosting and Emails',
122-
link: '/settings/hosting'
123-
},
124-
]
125-
}
126-
];
211+
subsections: settingsSections
212+
});
213+
};
127214

128215
let sidebar = (
129216
<Sidebar

lib/AppsManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { unescape } from 'lib/StringEscaping';
1212
let appsStore = [];
1313

1414
const AppsManager = {
15-
seed(rawApps) {
16-
appsStore = rawApps.map(raw => new ParseApp(raw));
15+
addApp(raw) {
16+
appsStore.push(new ParseApp(raw));
1717
},
1818

1919
apps() {

lib/ParseApp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default class ParseApp {
4747
api_key,
4848
apiKey,
4949
serverURL,
50+
enabledFeatures,
5051
...params,
5152
}) {
5253
this.name = name || appName;
@@ -66,6 +67,7 @@ export default class ParseApp {
6667
this.fileKey = api_key || apiKey;
6768
this.production = !!params['is_production?'];
6869
this.serverURL = serverURL;
70+
this.enabledFeatures = enabledFeatures;
6971

7072
this.settings = {
7173
fields: {},

0 commit comments

Comments
 (0)