discourse/app/assets/javascripts/admin/addon/routes/admin.js
Martin Brennan 979eca99d5
FIX: More header dropdown admin sidebar fixes (#27241)
Followup 73c6bb2593

The admin sidebar was also disappearing on another
child admin route (in this case the docker_manager
plugin update page). Instead of relying on the route
name which is flaky, we can set a boolean when the
sidebar is forced in the root admin route, then
turn it off when leaving admin.
2024-05-30 12:55:25 +10:00

38 lines
958 B
JavaScript

import { tracked } from "@glimmer/tracking";
import { service } from "@ember/service";
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "discourse-i18n";
export default class AdminRoute extends DiscourseRoute {
@service sidebarState;
@service siteSettings;
@service store;
@service currentUser;
@service adminSidebarStateManager;
@tracked initialSidebarState;
titleToken() {
return I18n.t("admin_title");
}
activate() {
this.adminSidebarStateManager.maybeForceAdminSidebar({
onlyIfAlreadyActive: false,
});
this.controllerFor("application").setProperties({
showTop: false,
});
}
deactivate(transition) {
this.controllerFor("application").set("showTop", true);
if (this.adminSidebarStateManager.currentUserUsingAdminSidebar) {
if (!transition?.to.name.startsWith("admin")) {
this.adminSidebarStateManager.stopForcingAdminSidebar();
}
}
}
}