Skip to content

Retrieve dashboard features from features endpoint #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 22 additions & 65 deletions dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 });
Expand Down
44 changes: 29 additions & 15 deletions dashboard/DashboardView.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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',
Expand All @@ -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({
Expand Down