FEATURE: allows to limit visible reports and tabs in dashboard (#9598)

This commit is contained in:
Joffrey JAFFEUX
2020-04-30 17:31:04 +02:00
committed by GitHub
parent 71241a50f7
commit 1b2db44678
12 changed files with 478 additions and 314 deletions
@@ -1,6 +1,6 @@
import discourseComputed from "discourse-common/utils/decorators";
import { makeArray } from "discourse-common/lib/helpers";
import { alias, or, and, equal, notEmpty } from "@ember/object/computed";
import { alias, or, and, equal, notEmpty, not } from "@ember/object/computed";
import EmberObject, { computed, action } from "@ember/object";
import { next } from "@ember/runloop";
import Component from "@ember/component";
@@ -41,7 +41,12 @@ function collapseWeekly(data, average) {
}
export default Component.extend({
classNameBindings: ["isEnabled", "isLoading", "dasherizedDataSourceName"],
classNameBindings: [
"isVisible",
"isEnabled",
"isLoading",
"dasherizedDataSourceName"
],
classNames: ["admin-report"],
isEnabled: true,
disabledLabel: I18n.t("admin.dashboard.disabled"),
@@ -63,6 +68,7 @@ export default Component.extend({
showDatesOptions: alias("model.dates_filtering"),
showRefresh: or("showDatesOptions", "model.available_filters.length"),
shouldDisplayTrend: and("showTrend", "model.prev_period"),
isVisible: not("isHidden"),
init() {
this._super(...arguments);
@@ -70,6 +76,13 @@ export default Component.extend({
this._reports = [];
},
isHidden: computed("siteSettings.dashboard_hidden_reports", function() {
return (this.siteSettings.dashboard_hidden_reports || "")
.split("|")
.filter(Boolean)
.includes(this.dataSourceName);
}),
startDate: computed("filters.startDate", function() {
if (this.filters && isPresent(this.filters.startDate)) {
return moment(this.filters.startDate, "YYYY-MM-DD");