discourse-data-explorer/assets/javascripts/discourse/components/group-reports-nav-item.js.es6

25 lines
586 B
Plaintext
Raw Normal View History

import { ajax } from "discourse/lib/ajax";
export default Ember.Component.extend({
group: null,
showReportsTab: false,
checkForReports() {
return ajax(`/g/${this.group.name}/reports`).then(response => {
return this.set("showReportsTab", response.queries.length > 0);
});
},
init(args) {
this.set("group", args.group);
2019-09-16 14:35:45 -04:00
if (
(this.get("currentUser.groups") || []).some(g => g.id === this.group.id)
) {
// User is a part of the group. Now check if the group has reports
this.checkForReports();
}
2019-09-16 14:35:45 -04:00
this._super(args);
}
});