mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 16:04:55 +08:00
8180770e7b
This commit fixes an issue where the following happens: 1. You open /admin as a member of the admin_sidebar_enabled_groups 1. You then click the chat icon in the header when you prefer to have drawer open, or if you just minimise chat into drawer after it opens fullscreen 1. You lose the admin sidebar panel, and are reset instead to the main panel Also included is a bit of refactoring to make it so the forcing of admin sidebar state is in one place.
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import { service } from "@ember/service";
|
|
import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
|
|
import DiscourseURL from "discourse/lib/url";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
import I18n from "discourse-i18n";
|
|
|
|
export default class AdminRoute extends DiscourseRoute {
|
|
@service siteSettings;
|
|
@service currentUser;
|
|
@service sidebarState;
|
|
@service adminSidebarStateManager;
|
|
|
|
titleToken() {
|
|
return I18n.t("admin_title");
|
|
}
|
|
|
|
activate() {
|
|
if (!this.currentUser.use_admin_sidebar) {
|
|
return DiscourseURL.redirectTo("/admin");
|
|
}
|
|
|
|
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.sidebarState.setPanel(MAIN_PANEL);
|
|
}
|
|
}
|
|
}
|
|
}
|