Skip to content

Enable API Console for all apps as it relies on no optional features #14

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 2 commits into from
Feb 25, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ You can also manage your apps that are hosted on Parse.com from the same dashboa
"appId": "myAppId",
"masterKey": "myMasterKey",
"javascriptKey": "myJavascriptKey",
"appName": "My App"
"appName": "My Parse.Com App"
},
{
"serverURL": "http://localhost:1337/parse",
"appId": "myAppId",
"masterKey": "myMasterKey",
"appName": "My Parse.Com App"
"appName": "My Parse Server App"
}
]
}
Expand Down
1 change: 0 additions & 1 deletion dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class Dashboard extends React.Component {
jobs: false, //jobs still goes through rails
logs: true,
config: true,
apiConsole: false, //api console needs to be modified to use server url of the app
//Other features would be much harder to add, although push console should just need the hiding
//of scheduled push related stuff
pushConsole: false,
Expand Down
10 changes: 4 additions & 6 deletions dashboard/DashboardView.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ export default class DashboardView extends React.Component {
});
}

if (this.context.currentApp.enabledFeatures.apiConsole) {
coreSubsections.push({
name: 'API Console',
link: '/api_console'
});
}
coreSubsections.push({
name: 'API Console',
link: '/api_console'
});

if (this.context.currentApp.migration) {
coreSubsections.push({
Expand Down
10 changes: 6 additions & 4 deletions dashboard/Data/ApiConsole/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import Parse from 'parse';
export default function request(app, method, path, body, options) {
let xhr = new XMLHttpRequest();
let promise = new Parse.Promise();
if (path[0] === '/') {
if (path.startsWith('/') && app.serverURL.endsWith('/')) {
path = path.substr(1);
}
let url = location.protocol + '//' + location.host + '/1/' + path;
xhr.open(method, url, true);
if (!path.startsWith('/') && !app.serverURL.endsWith('/')) {
path = '/' + path;
}
xhr.open(method, app.serverURL + path, true);
xhr.setRequestHeader('X-Parse-Application-Id', app.applicationId);
if (options.useMasterKey) {
xhr.setRequestHeader('X-Parse-Master-Key', app.masterKey);
} else {
} else if (app.restKey) {
xhr.setRequestHeader('X-Parse-REST-API-Key', app.restKey);
}
if (options.sessionToken) {
Expand Down
33 changes: 11 additions & 22 deletions lib/ParseApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,37 @@ function setEnablePushSource(setting, enable) {

export default class ParseApp {
constructor({
name,
appName,
created_at,
key,
applicationId,
clientKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soo much cleaner 👍

appId,
friendly_id,
appNameForURL,
dashboardURL,
secret,
clientKey,
javascript_key,
javascriptKey,
push_key,
masterKey,
rest_api_key,
restKey,
windows_key,
windowsKey,
webhook_key,
webhookKey,
api_key,
apiKey,
serverURL,
enabledFeatures,
...params,
}) {
this.name = name || appName;
this.name = appName;
this.createdAt = created_at ? new Date(created_at) : new Date();
this.applicationId = appId || key || applicationId;
this.slug = friendly_id || appNameForURL || appName;
this.applicationId = appId;
this.slug = appNameForURL || appName;
if (!this.slug && dashboardURL) {
let pieces = dashboardURL.split('/');
this.slug = pieces[pieces.length - 1];
}
this.clientKey = secret || clientKey;
this.javascriptKey = javascript_key || javascriptKey;
this.masterKey = push_key || masterKey;
this.restKey = rest_api_key || restKey;
this.windowsKey = windows_key || windowsKey;
this.webhookKey = webhook_key || webhookKey;
this.fileKey = api_key || apiKey;
this.clientKey = clientKey;
this.javascriptKey = javascriptKey;
this.masterKey = masterKey;
this.restKey = restKey;
this.windowsKey = windowsKey;
this.webhookKey = webhookKey;
this.fileKey = apiKey;
this.production = !!params['is_production?'];
this.serverURL = serverURL;
this.enabledFeatures = enabledFeatures;
Expand Down