2024-02-21 12:44:09 +08:00
|
|
|
import { tracked } from "@glimmer/tracking";
|
2023-11-02 08:34:37 +08:00
|
|
|
import { inject as service } from "@ember/service";
|
2024-02-28 09:33:59 +08:00
|
|
|
import { ADMIN_PANEL, MAIN_PANEL } from "discourse/lib/sidebar/panels";
|
2019-10-22 21:46:10 +08:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2023-10-18 18:07:09 +08:00
|
|
|
import I18n from "discourse-i18n";
|
2019-10-22 21:46:10 +08:00
|
|
|
|
2023-03-15 21:17:51 +08:00
|
|
|
export default class AdminRoute extends DiscourseRoute {
|
2023-11-02 08:34:37 +08:00
|
|
|
@service sidebarState;
|
2023-12-18 09:48:25 +08:00
|
|
|
@service siteSettings;
|
2024-01-09 07:06:27 +08:00
|
|
|
@service currentUser;
|
2024-02-21 12:44:09 +08:00
|
|
|
@tracked initialSidebarState;
|
2023-11-02 08:34:37 +08:00
|
|
|
|
2015-08-08 00:06:55 +08:00
|
|
|
titleToken() {
|
|
|
|
return I18n.t("admin_title");
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
2015-08-08 00:06:55 +08:00
|
|
|
|
|
|
|
activate() {
|
2024-02-09 10:52:22 +08:00
|
|
|
if (this.currentUser.use_admin_sidebar) {
|
2023-12-18 09:48:25 +08:00
|
|
|
this.sidebarState.setPanel(ADMIN_PANEL);
|
|
|
|
this.sidebarState.setSeparatedMode();
|
|
|
|
this.sidebarState.hideSwitchPanelButtons();
|
|
|
|
}
|
|
|
|
|
2015-08-08 00:06:55 +08:00
|
|
|
this.controllerFor("application").setProperties({
|
|
|
|
showTop: false,
|
|
|
|
});
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
2015-08-08 00:06:55 +08:00
|
|
|
|
2023-12-18 09:48:25 +08:00
|
|
|
deactivate(transition) {
|
2015-08-08 00:06:55 +08:00
|
|
|
this.controllerFor("application").set("showTop", true);
|
2023-12-18 09:48:25 +08:00
|
|
|
|
2024-02-09 10:52:22 +08:00
|
|
|
if (this.currentUser.use_admin_sidebar) {
|
2023-12-18 09:48:25 +08:00
|
|
|
if (!transition?.to.name.startsWith("admin")) {
|
|
|
|
this.sidebarState.setPanel(MAIN_PANEL);
|
|
|
|
}
|
|
|
|
}
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
|
|
|
}
|