2024-02-21 12:44:09 +08:00
|
|
|
import { tracked } from "@glimmer/tracking";
|
2024-03-07 01:05:11 +08:00
|
|
|
import { service } from "@ember/service";
|
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-03-14 09:28:08 +08:00
|
|
|
@service store;
|
2024-01-09 07:06:27 +08:00
|
|
|
@service currentUser;
|
2024-03-14 09:28:08 +08:00
|
|
|
@service adminSidebarStateManager;
|
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-03-20 07:20:06 +08:00
|
|
|
this.adminSidebarStateManager.maybeForceAdminSidebar({
|
|
|
|
onlyIfAlreadyActive: false,
|
|
|
|
});
|
2023-12-18 09:48:25 +08:00
|
|
|
|
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-03-20 07:20:06 +08:00
|
|
|
if (this.adminSidebarStateManager.currentUserUsingAdminSidebar) {
|
2023-12-18 09:48:25 +08:00
|
|
|
if (!transition?.to.name.startsWith("admin")) {
|
2024-05-30 10:55:25 +08:00
|
|
|
this.adminSidebarStateManager.stopForcingAdminSidebar();
|
2023-12-18 09:48:25 +08:00
|
|
|
}
|
|
|
|
}
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
|
|
|
}
|