2019-09-11 10:09:41 -04:00
|
|
|
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)
|
|
|
|
) {
|
2019-09-11 10:09:41 -04:00
|
|
|
// User is a part of the group. Now check if the group has reports
|
|
|
|
this.checkForReports();
|
|
|
|
}
|
2019-09-16 14:35:45 -04:00
|
|
|
|
2019-09-11 10:09:41 -04:00
|
|
|
this._super(args);
|
|
|
|
}
|
|
|
|
});
|