2023-10-19 12:23:41 +08:00
|
|
|
import { inject as service } from "@ember/service";
|
|
|
|
import DiscourseURL from "discourse/lib/url";
|
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
|
|
import { ADMIN_PANEL, MAIN_PANEL } from "discourse/services/sidebar-state";
|
|
|
|
import I18n from "discourse-i18n";
|
|
|
|
|
|
|
|
export default class AdminRoute extends DiscourseRoute {
|
|
|
|
@service siteSettings;
|
|
|
|
@service currentUser;
|
|
|
|
@service sidebarState;
|
|
|
|
|
|
|
|
titleToken() {
|
|
|
|
return I18n.t("admin_title");
|
|
|
|
}
|
|
|
|
|
|
|
|
activate() {
|
|
|
|
if (
|
2023-10-25 09:45:10 +08:00
|
|
|
!this.siteSettings.userInAnyGroups(
|
|
|
|
"enable_experimental_admin_ui_groups",
|
|
|
|
this.currentUser
|
2023-10-19 12:23:41 +08:00
|
|
|
)
|
|
|
|
) {
|
|
|
|
return DiscourseURL.redirectTo("/admin");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.sidebarState.setPanel(ADMIN_PANEL);
|
|
|
|
this.sidebarState.setSeparatedMode();
|
|
|
|
this.sidebarState.hideSwitchPanelButtons();
|
|
|
|
|
|
|
|
this.controllerFor("application").setProperties({
|
|
|
|
showTop: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
deactivate() {
|
|
|
|
this.controllerFor("application").set("showTop", true);
|
|
|
|
this.sidebarState.setPanel(MAIN_PANEL);
|
|
|
|
}
|
|
|
|
}
|