2019-10-24 01:06:54 +08:00
|
|
|
import Controller from "@ember/controller";
|
2019-11-06 02:43:49 +08:00
|
|
|
import { dasherize } from "@ember/string";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-30 01:31:44 +08:00
|
|
|
import { inject as service } from "@ember/service";
|
2017-10-31 02:13:49 +08:00
|
|
|
|
2019-10-24 01:06:54 +08:00
|
|
|
export default Controller.extend({
|
2019-10-30 01:29:08 +08:00
|
|
|
router: service(),
|
2017-10-31 02:13:49 +08:00
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("siteSettings.enable_group_directory")
|
2018-10-12 07:34:47 +08:00
|
|
|
showGroups(enableGroupDirectory) {
|
|
|
|
return !enableGroupDirectory;
|
|
|
|
},
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("siteSettings.enable_badges")
|
2018-10-12 07:34:47 +08:00
|
|
|
showBadges(enableBadges) {
|
|
|
|
return this.currentUser.get("admin") && enableBadges;
|
2017-10-31 02:13:49 +08:00
|
|
|
},
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed("router._router.currentPath")
|
2017-10-31 02:13:49 +08:00
|
|
|
adminContentsClassName(currentPath) {
|
2019-04-01 18:39:49 +08:00
|
|
|
let cssClasses = currentPath
|
2017-10-31 02:13:49 +08:00
|
|
|
.split(".")
|
|
|
|
.filter((segment) => {
|
|
|
|
return (
|
|
|
|
segment !== "index" &&
|
|
|
|
segment !== "loading" &&
|
|
|
|
segment !== "show" &&
|
2019-07-19 05:00:39 +08:00
|
|
|
segment !== "admin"
|
2017-10-31 02:13:49 +08:00
|
|
|
);
|
|
|
|
})
|
2019-11-06 02:43:49 +08:00
|
|
|
.map(dasherize)
|
2017-10-31 02:13:49 +08:00
|
|
|
.join(" ");
|
2019-04-01 18:39:49 +08:00
|
|
|
|
|
|
|
// this is done to avoid breaking css customizations
|
2019-07-19 05:00:39 +08:00
|
|
|
if (cssClasses.includes("dashboard")) {
|
|
|
|
cssClasses = `${cssClasses} dashboard-next`;
|
2019-04-01 18:39:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return cssClasses;
|
2017-10-31 02:13:49 +08:00
|
|
|
},
|
2014-03-19 12:18:04 +08:00
|
|
|
});
|