2019-10-24 01:06:54 +08:00
|
|
|
import Controller from "@ember/controller";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { inject as service } from "@ember/service";
|
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";
|
2017-10-31 02:13:49 +08:00
|
|
|
|
2023-03-15 17:42:12 +08:00
|
|
|
export default class AdminController extends Controller {
|
|
|
|
@service router;
|
2024-01-09 07:06:27 +08:00
|
|
|
@service currentUser;
|
2017-10-31 02:13:49 +08:00
|
|
|
|
2024-02-09 10:52:22 +08:00
|
|
|
@discourseComputed("currentUser.use_admin_sidebar")
|
2024-01-09 07:06:27 +08:00
|
|
|
showAdminSidebar() {
|
2024-02-09 10:52:22 +08:00
|
|
|
return this.currentUser.use_admin_sidebar;
|
2024-01-09 07:06:27 +08:00
|
|
|
}
|
2023-12-18 09:48:25 +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;
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
2018-10-12 07:34:47 +08:00
|
|
|
|
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;
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
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;
|
2023-03-15 17:42:12 +08:00
|
|
|
}
|
|
|
|
}
|