discourse/app/assets/javascripts/admin/addon/controllers/admin.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.2 KiB
JavaScript
Raw Normal View History

import Controller from "@ember/controller";
import { service } from "@ember/service";
import { dasherize } from "@ember/string";
import discourseComputed from "discourse-common/utils/decorators";
export default class AdminController extends Controller {
@service router;
@service currentUser;
@discourseComputed("currentUser.use_admin_sidebar")
showAdminSidebar() {
return this.currentUser.use_admin_sidebar;
}
@discourseComputed("siteSettings.enable_group_directory")
showGroups(enableGroupDirectory) {
return !enableGroupDirectory;
}
@discourseComputed("siteSettings.enable_badges")
showBadges(enableBadges) {
return this.currentUser.get("admin") && enableBadges;
}
@discourseComputed("router._router.currentPath")
adminContentsClassName(currentPath) {
2019-04-01 18:39:49 +08:00
let cssClasses = currentPath
.split(".")
.filter((segment) => {
return (
segment !== "index" &&
segment !== "loading" &&
segment !== "show" &&
segment !== "admin"
);
})
.map(dasherize)
.join(" ");
2019-04-01 18:39:49 +08:00
// this is done to avoid breaking css customizations
if (cssClasses.includes("dashboard")) {
cssClasses = `${cssClasses} dashboard-next`;
2019-04-01 18:39:49 +08:00
}
return cssClasses;
}
}