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