FIX: Show error message, not exception page, to mods

This commit is contained in:
Kane York 2015-09-21 11:19:31 -07:00
parent d4d541747e
commit 9145e32162
3 changed files with 134 additions and 129 deletions

View File

@ -6,18 +6,17 @@ export default Discourse.Route.extend({
model() {
const p1 = this.store.findAll('query');
const p2 = Discourse.ajax('/admin/plugins/explorer/schema.json', {cache: true});
return p1.then(function(model) {
model.forEach(function(query) {
query.markNotDirty();
});
return p2.then(function(schema) {
return { content: model, schema: schema };
});
return p1.then(model => {
model.forEach(query => query.markNotDirty());
return p2.then(schema => {return {model, schema};});
}).catch(() => {
p2.catch(() => {});
return { model: null, schema: null, disallow: true };
});
},
setupController: function(controller, model) {
controller.set('model', model.content);
controller.set('schema', model.schema);
controller.setProperties(model);
}
});

View File

@ -1,3 +1,6 @@
{{#if disallow}}
<h2>{{i18n "explorer.admins_only"}}</h2>
{{else}}
<div class="query-list">
{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" content=content castInteger="true" nameChanges="true"}}
{{d-button action="showCreate" icon="plus" class="no-text"}}
@ -129,3 +132,5 @@
{{/unless}}
<div class="explorer-pad-bottom"></div>
{{/if}}

View File

@ -22,6 +22,7 @@ en:
no_semicolons: "Remove the semicolons from the query."
dirty: "You must save the query before running."
explorer:
admins_only: "The data explorer is only available to admins."
title: "Data Explorer"
create: "Create New"
create_placeholder: "Query name..."