Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit d2d46f0

Browse files
committed
DEV: Ensure we don't remove the admin sidebar accidently
1 parent 731fb4e commit d2d46f0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { tracked } from "@glimmer/tracking";
2-
import { alias } from "@ember/object/computed";
32
import Service, { service } from "@ember/service";
4-
import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
3+
import { ADMIN_PANEL, MAIN_PANEL } from "discourse/lib/sidebar/panels";
54

65
export const AI_CONVERSATIONS_PANEL = "ai-conversations";
76

87
export default class AiConversationsSidebarManager extends Service {
98
@service sidebarState;
109

1110
@tracked newTopicForceSidebar = false;
12-
@alias("sidebarState.isForcingSidebar") isForcingSidebar;
1311

1412
forceCustomSidebar() {
1513
// Set the panel to your custom panel
@@ -21,7 +19,7 @@ export default class AiConversationsSidebarManager extends Service {
2119
// Hide panel switching buttons to keep UI clean
2220
this.sidebarState.hideSwitchPanelButtons();
2321

24-
this.isForcingSidebar = true;
22+
this.sidebarState.isForcingSidebar = true;
2523
document.body.classList.add("has-ai-conversations-sidebar");
2624
return true;
2725
}
@@ -30,9 +28,13 @@ export default class AiConversationsSidebarManager extends Service {
3028
// This method is called when leaving your route
3129
// Only restore main panel if we previously forced ours
3230
document.body.classList.remove("has-ai-conversations-sidebar");
33-
if (this.isForcingSidebar) {
31+
const isadminsidebaractive =
32+
this.sidebarState.currentPanel?.key === ADMIN_PANEL;
33+
// only restore main panel if we previously forced our sidebar
34+
// and not if we are in admin sidebar
35+
if (this.sidebarState.isForcingSidebar && !isadminsidebaractive) {
3436
this.sidebarState.setPanel(MAIN_PANEL); // Return to main sidebar panel
35-
this.isForcingSidebar = false;
37+
this.sidebarState.isForcingSidebar = false;
3638
}
3739
}
3840
}

0 commit comments

Comments
 (0)