DEV: Improve logic for showing/hiding the reports tab in group screens (#107)
Previously this was adding an extra AJAX request to check if the group had any queries available. Now a boolean is included in the group serializer, so there is no need for the extra request. Removing this ajax request will also stop other plugin JS integration tests from failing when the data-explorer plugin is installed. This commit also fixes the HTML markup of the tab, so that it doesn't have a <ul> nested inside the existing <ul>. Also adds an icon for good measure.
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
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);
|
||||
if (
|
||||
(this.get("currentUser.groups") || []).some(
|
||||
(g) => g.id === this.group.id
|
||||
) ||
|
||||
this.get("currentUser.admin")
|
||||
) {
|
||||
// User is a part of the group (or an admin). Now check if the group has reports
|
||||
this.checkForReports();
|
||||
}
|
||||
|
||||
this._super(args);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
shouldRender(args) {
|
||||
return args.group.has_visible_data_explorer_queries;
|
||||
},
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
{{#if showReportsTab}}
|
||||
<ul class ='nav-pills'>
|
||||
<li>
|
||||
{{#link-to 'group.reports'}}
|
||||
{{i18n 'group.reports'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
</ul>
|
||||
{{/if}}
|
||||
+3
-1
@@ -1 +1,3 @@
|
||||
{{group-reports-nav-item group = group}}
|
||||
{{#link-to 'group.reports'}}
|
||||
{{d-icon 'chart-bar'}}{{i18n 'group.reports'}}
|
||||
{{/link-to}}
|
||||
|
||||
Reference in New Issue
Block a user