* [WIP] group ids saving on new reports * Add groups to default queries, and added tab connector * group_ids set to empty array for default queries * group reports route (in & and) action * [WIP] created group reports show route/controller * Find correct query in show route * Removed empty array for group_ids in query file * Add report show view, where users can run queries * Removed unneeded commas from queries.rb * Allow non-admin group members to access reports * query-result component dynamic download url based on location * Removed accidental changes, and corrected tab size * Group members can add params to queries * Specs for new QueryController actions * remove "Inlude query plan" from group reports * Run prettier * return and return -> return render Co-Authored-By: Robin Ward <[email protected]> * [WIP] changes from review * Remove weird [-1] group_ids logic, for a simply check for [] in query update action * Added integration tests for group report access * Using guardian for securing endpoints, and much improved specs * Update assets/javascripts/discourse/components/group-reports-nav-item.js.es6 Co-Authored-By: Robin Ward <[email protected]>
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import { ajax } from "discourse/lib/ajax";
|
|
|
|
export default Discourse.Route.extend({
|
|
controllerName: "admin-plugins-explorer",
|
|
|
|
model() {
|
|
const groupPromise = this.store.findAll("group");
|
|
const schemaPromise = ajax("/admin/plugins/explorer/schema.json", { cache: true });
|
|
const queryPromise = this.store.findAll("query");
|
|
|
|
return groupPromise
|
|
.then(groups => {
|
|
let groupNames = {};
|
|
groups.forEach(g => {
|
|
groupNames[g.id] = g.name;
|
|
});
|
|
return schemaPromise.then(schema => {
|
|
return queryPromise.then(model => {
|
|
model.forEach(query => {
|
|
query.markNotDirty();
|
|
query.set(
|
|
"group_names",
|
|
query.group_ids
|
|
.map(id => groupNames[id])
|
|
.filter(n => n)
|
|
.join(", ")
|
|
);
|
|
});
|
|
return { model, schema, groups };
|
|
});
|
|
});
|
|
})
|
|
.catch(() => {
|
|
schemaPromise.catch(() => {});
|
|
queryPromise.catch(() => {});
|
|
return { model: null, schema: null, disallow: true, groups: null };
|
|
});
|
|
},
|
|
|
|
setupController(controller, model) {
|
|
controller.setProperties(model);
|
|
},
|
|
|
|
actions: {
|
|
refreshModel() {
|
|
this.refresh();
|
|
return false;
|
|
}
|
|
}
|
|
});
|