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.
This commit is contained in:
parent
078d363510
commit
979eca99d5
|
@ -4,6 +4,7 @@ import DiscourseURL from "discourse/lib/url";
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "discourse-i18n";
|
||||
|
||||
// DEPRECATED: (martin) This route is deprecated and will be removed in the near future.
|
||||
export default class AdminRoute extends DiscourseRoute {
|
||||
@service siteSettings;
|
||||
@service currentUser;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { tracked } from "@glimmer/tracking";
|
||||
import { service } from "@ember/service";
|
||||
import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "discourse-i18n";
|
||||
|
||||
|
@ -31,7 +30,7 @@ export default class AdminRoute extends DiscourseRoute {
|
|||
|
||||
if (this.adminSidebarStateManager.currentUserUsingAdminSidebar) {
|
||||
if (!transition?.to.name.startsWith("admin")) {
|
||||
this.sidebarState.setPanel(MAIN_PANEL);
|
||||
this.adminSidebarStateManager.stopForcingAdminSidebar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { alias } from "@ember/object/computed";
|
||||
import Service, { service } from "@ember/service";
|
||||
import KeyValueStore from "discourse/lib/key-value-store";
|
||||
import { ADMIN_PANEL } from "discourse/lib/sidebar/panels";
|
||||
import { ADMIN_PANEL, MAIN_PANEL } from "discourse/lib/sidebar/panels";
|
||||
|
||||
export default class AdminSidebarStateManager extends Service {
|
||||
@service sidebarState;
|
||||
@service currentUser;
|
||||
@alias("sidebarState.currentUserUsingAdminSidebar")
|
||||
currentUserUsingAdminSidebar;
|
||||
@alias("sidebarState.isForcingAdminSidebar") isForcingAdminSidebar;
|
||||
|
||||
keywords = {};
|
||||
|
||||
|
@ -37,10 +41,6 @@ export default class AdminSidebarStateManager extends Service {
|
|||
this.store.setObject({ key: "navConfig", value });
|
||||
}
|
||||
|
||||
get currentUserUsingAdminSidebar() {
|
||||
return this.currentUser?.use_admin_sidebar;
|
||||
}
|
||||
|
||||
maybeForceAdminSidebar(opts = {}) {
|
||||
opts.onlyIfAlreadyActive ??= true;
|
||||
|
||||
|
@ -48,6 +48,7 @@ export default class AdminSidebarStateManager extends Service {
|
|||
this.sidebarState.currentPanel?.key === ADMIN_PANEL;
|
||||
|
||||
if (!this.currentUserUsingAdminSidebar) {
|
||||
this.isForcingAdminSidebar = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -58,14 +59,21 @@ export default class AdminSidebarStateManager extends Service {
|
|||
if (isAdminSidebarActive) {
|
||||
return this.#forceAdminSidebar();
|
||||
} else {
|
||||
this.isForcingAdminSidebar = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
stopForcingAdminSidebar() {
|
||||
this.sidebarState.setPanel(MAIN_PANEL);
|
||||
this.isForcingAdminSidebar = false;
|
||||
}
|
||||
|
||||
#forceAdminSidebar() {
|
||||
this.sidebarState.setPanel(ADMIN_PANEL);
|
||||
this.sidebarState.setSeparatedMode();
|
||||
this.sidebarState.hideSwitchPanelButtons();
|
||||
this.isForcingAdminSidebar = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ export default Controller.extend({
|
|||
|
||||
// Always show sidebar for admin if user can see the admin sidbar
|
||||
if (
|
||||
this.router.currentRouteName.startsWith("admin") &&
|
||||
this.currentUser?.use_admin_sidebar
|
||||
this.sidebarState.isForcingAdminSidebar &&
|
||||
this.sidebarState.currentUserUsingAdminSidebar
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ export default class SidebarState extends Service {
|
|||
@tracked mode = COMBINED_MODE;
|
||||
@tracked displaySwitchPanelButtons = false;
|
||||
@tracked filter = "";
|
||||
@tracked isForcingAdminSidebar = false;
|
||||
|
||||
panels = panels;
|
||||
collapsedSections = new TrackedSet();
|
||||
|
@ -122,9 +123,13 @@ export default class SidebarState extends Service {
|
|||
return this.currentPanelKey === MAIN_PANEL;
|
||||
}
|
||||
|
||||
get currentUserUsingAdminSidebar() {
|
||||
return this.currentUser?.use_admin_sidebar;
|
||||
}
|
||||
|
||||
get adminSidebarAllowedWithLegacyNavigationMenu() {
|
||||
return (
|
||||
this.currentUser?.use_admin_sidebar &&
|
||||
this.currentUserUsingAdminSidebar &&
|
||||
this.siteSettings.navigation_menu === "header dropdown"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue