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

Commit 9787c42

Browse files
committed
base going
1 parent 32e62f4 commit 9787c42

File tree

5 files changed

+148
-67
lines changed

5 files changed

+148
-67
lines changed

assets/javascripts/discourse/controllers/discourse-ai-bot-conversations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import SimpleTextareaInteractor from "../lib/simple-textarea-interactor";
66
export default class DiscourseAiBotConversations extends Controller {
77
@service aiBotConversationsHiddenSubmit;
88

9+
sidebarEnabled = true;
10+
showSidebar = true;
911
textareaInteractor = null;
1012

1113
@action
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
import { service } from "@ember/service";
12
import DiscourseRoute from "discourse/routes/discourse";
23

3-
export default class DiscourseAiBotConversationsRoute extends DiscourseRoute {}
4+
export default class DiscourseAiBotConversationsRoute extends DiscourseRoute {
5+
@service aiConversationsSidebarManager;
6+
7+
activate() {
8+
super.activate(...arguments);
9+
this.aiConversationsSidebarManager.forceCustomSidebar();
10+
}
11+
12+
deactivate() {
13+
super.deactivate(...arguments);
14+
this.aiConversationsSidebarManager.stopForcingCustomSidebar();
15+
}
16+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { alias } from "@ember/object/computed";
2+
import Service, { service } from "@ember/service";
3+
import { MAIN_PANEL } from "discourse/lib/sidebar/panels";
4+
5+
export default class AiConversationsSidebarManager extends Service {
6+
@service sidebarState;
7+
8+
@alias("sidebarState.isForcingSidebar") isForcingSidebar;
9+
10+
forceCustomSidebar() {
11+
// Set the panel to your custom panel
12+
this.sidebarState.setPanel("ai-conversations");
13+
14+
// Use separated mode to ensure independence from hamburger menu
15+
this.sidebarState.setSeparatedMode();
16+
17+
// Hide panel switching buttons to keep UI clean
18+
this.sidebarState.hideSwitchPanelButtons();
19+
20+
this.isForcingSidebar = true;
21+
return true;
22+
}
23+
24+
stopForcingCustomSidebar() {
25+
// This method is called when leaving your route
26+
// Only restore main panel if we previously forced ours
27+
if (this.isForcingSidebar) {
28+
this.sidebarState.setPanel(MAIN_PANEL); // Return to main sidebar panel
29+
this.isForcingSidebar = false;
30+
}
31+
}
32+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// discourse/initializers/your-custom-sidebar.js
2+
import { withPluginApi } from "discourse/lib/plugin-api";
3+
4+
export default {
5+
name: "ai-conversations-sidebar",
6+
7+
initialize() {
8+
withPluginApi("1.8.0", (api) => {
9+
// Step 1: Add a custom sidebar panel
10+
api.addSidebarPanel(
11+
(BaseCustomSidebarPanel) =>
12+
class AiConversationsSidebarPanel extends BaseCustomSidebarPanel {
13+
key = "ai-conversations";
14+
hidden = true; // Hide from panel switching UI
15+
displayHeader = true;
16+
expandActiveSection = true;
17+
18+
// Optional - customize if needed
19+
// switchButtonLabel = "Your Panel";
20+
// switchButtonIcon = "cog";
21+
}
22+
);
23+
24+
// Step 2: Add a custom section to your panel
25+
api.addSidebarSection(
26+
(BaseCustomSidebarSection, BaseCustomSidebarSectionLink) => {
27+
return class AiConversationsSidebarSection extends BaseCustomSidebarSection {
28+
name = "your-custom-section";
29+
text = "Your Section Title";
30+
31+
get links() {
32+
return [
33+
// Add your links here
34+
//new (class extends BaseCustomSidebarSectionLink {
35+
//name = "custom-link-1";
36+
//route = "some.route";
37+
//text = "First Custom Link";
38+
//prefixType = "icon";
39+
//prefixValue = "cog";
40+
//})(),
41+
//new (class extends BaseCustomSidebarSectionLink {
42+
//name = "custom-link-2";
43+
//route = "another.route";
44+
//text = "Second Custom Link";
45+
//prefixType = "icon";
46+
//prefixValue = "bell";
47+
//})()
48+
];
49+
}
50+
};
51+
},
52+
"ai-conversations" // Important: Attach to your panel
53+
);
54+
});
55+
},
56+
};

assets/stylesheets/modules/ai-bot-conversations/common.scss

Lines changed: 44 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,59 @@ body.discourse-ai-bot-conversations-page {
66
.ai-new-question-button {
77
display: block;
88
}
9+
.sidebar-wrapper {
10+
.sidebar-container {
11+
border: none;
12+
}
913

10-
#sidebar-section-content-community,
11-
[data-section-name="tags"],
12-
[data-section-name="categories"],
13-
[data-section-name="messages"],
14-
[data-section-name="user-threads"],
15-
[data-section-name="user-threads"],
16-
[data-section-name="chat-dms"],
17-
.sidebar-sections:not(.admin-panel)
18-
.sidebar-section-link
19-
.sidebar-section-link-prefix,
20-
.sidebar-footer-wrapper,
21-
.sidebar__panel-switch-button {
22-
display: none;
23-
}
24-
25-
.sidebar-wrapper .sidebar-container {
26-
border: none;
27-
}
28-
29-
// ai related sidebar content
14+
// ai related sidebar content
3015

31-
[data-section-name="custom-messages"] {
32-
.sidebar-section-header-wrapper {
33-
pointer-events: none;
34-
font-size: var(--font-down-1);
35-
.sidebar-section-header-caret {
36-
display: none;
37-
}
38-
.sidebar-section-header-text {
39-
letter-spacing: 0.5px;
16+
[data-section-name="custom-messages"] {
17+
.sidebar-section-header-wrapper {
18+
pointer-events: none;
19+
font-size: var(--font-down-1);
20+
.sidebar-section-header-caret {
21+
display: none;
22+
}
23+
.sidebar-section-header-text {
24+
letter-spacing: 0.5px;
25+
}
4026
}
4127
}
42-
}
4328

44-
[data-link-name="View All"] {
45-
align-content: stretch;
46-
.sidebar-section-link-prefix.icon {
47-
display: flex;
48-
font-size: var(--font-up-1);
49-
margin-left: -0.15em;
29+
[data-link-name="View All"] {
30+
align-content: stretch;
31+
.sidebar-section-link-prefix.icon {
32+
display: flex;
33+
font-size: var(--font-up-1);
34+
margin-left: -0.15em;
35+
}
5036
}
51-
}
5237

53-
.ai-new-question-button {
54-
margin: 1.25em 1em 2.65em 1.25em;
55-
}
38+
.ai-new-question-button {
39+
margin: 1.25em 1em 2.65em 1.25em;
40+
}
5641

57-
.sidebar-section-link-wrapper {
58-
.sidebar-section-link {
59-
height: unset;
60-
padding-block: 0.65em;
61-
font-size: var(--font-down-1);
62-
letter-spacing: 0.35px;
63-
border-radius: 0 var(--border-radius) var(--border-radius) 0;
64-
65-
.sidebar-section-link-content-text {
66-
white-space: normal;
67-
display: -webkit-box;
68-
-webkit-box-orient: vertical;
69-
-webkit-line-clamp: 2;
70-
overflow: hidden;
42+
.sidebar-section-link-wrapper {
43+
.sidebar-section-link {
44+
height: unset;
45+
padding-block: 0.65em;
46+
font-size: var(--font-down-1);
47+
letter-spacing: 0.35px;
48+
border-radius: 0 var(--border-radius) var(--border-radius) 0;
49+
50+
.sidebar-section-link-content-text {
51+
white-space: normal;
52+
display: -webkit-box;
53+
-webkit-box-orient: vertical;
54+
-webkit-line-clamp: 2;
55+
overflow: hidden;
56+
}
7157
}
7258
}
73-
}
74-
75-
.sidebar-section-link-prefix {
76-
align-self: start;
59+
.sidebar-section-link-prefix {
60+
align-self: start;
61+
}
7762
}
7863

7964
// topic elements
@@ -132,6 +117,7 @@ body.discourse-ai-bot-conversations-page {
132117

133118
#topic-footer-buttons {
134119
width: calc(100% - 6.5em);
120+
margin-top: 0;
135121
@media screen and (max-width: 924px) {
136122
max-width: unset;
137123
width: 100%;
@@ -140,7 +126,6 @@ body.discourse-ai-bot-conversations-page {
140126
width: 100%;
141127
max-width: 51em;
142128
}
143-
margin-top: 0;
144129
.topic-footer-main-buttons {
145130
justify-content: flex-end;
146131
@media screen and (min-width: 1180px) {
@@ -181,14 +166,7 @@ body.discourse-ai-bot-conversations-page {
181166
display: none;
182167
}
183168

184-
// narrow desktop slide-out sidebar
185-
186-
.hamburger-panel .revamped .sidebar-section-wrapper.sidebar-section ul {
187-
grid-template-columns: 1fr;
188-
}
189-
190169
// custom homepage
191-
192170
html.composer-open .custom-homepage #main-outlet {
193171
padding-bottom: 0;
194172
}

0 commit comments

Comments
 (0)