Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add missing features to sidebar href links (#37537)

Rafael dos Santos Silva55e56fb092f2
diff --git a/frontend/discourse/app/components/sidebar/section-link.gjs b/frontend/discourse/app/components/sidebar/section-link.gjs
index fd9e99914c9..9c60cc49c5b 100644
--- a/frontend/discourse/app/components/sidebar/section-link.gjs
+++ b/frontend/discourse/app/components/sidebar/section-link.gjs
@@ -213,9 +213,55 @@ export default class SectionLink extends Component {
@prefixBadge={{@prefixBadge}}
/>
- <span class="sidebar-section-link-content-text">
+ <span
+ class={{concatClass
+ "sidebar-section-link-content-text"
+ @contentCSSClass
+ }}
+ >
{{@content}}
+ <@contentComponent />
</span>
+
+ {{#if @badgeText}}
+ <span class="sidebar-section-link-content-badge">
+ {{@badgeText}}
+ </span>
+ {{/if}}
+
+ {{#if @suffixComponent}}
+ <@suffixComponent @suffixArgs={{@suffixArgs}} />
+ {{/if}}
+
+ {{#if @suffixValue}}
+ <span
+ class={{concatClass
+ "sidebar-section-link-suffix"
+ @suffixType
+ @suffixCSSClass
+ }}
+ >
+ {{#if (eq @suffixType "icon")}}
+ {{icon @suffixValue}}
+ {{/if}}
+ </span>
+ {{/if}}
+
+ {{! template-lint-disable no-nested-interactive }}
+ {{#if @hoverValue}}
+ <span class="sidebar-section-link-hover">
+ <button
+ {{on "click" this.runHoverAction}}
+ type="button"
+ title={{@hoverTitle}}
+ class="sidebar-section-hover-button btn-flat"
+ >
+ {{#if (eq @hoverType "icon")}}
+ {{icon @hoverValue class="hover-icon"}}
+ {{/if}}
+ </button>
+ </span>
+ {{/if}}
</a>
{{else}}
<LinkTo
diff --git a/frontend/discourse/tests/acceptance/sidebar-plugin-api-test.gjs b/frontend/discourse/tests/acceptance/sidebar-plugin-api-test.gjs
index 882871830d4..2f12f9c2546 100644
--- a/frontend/discourse/tests/acceptance/sidebar-plugin-api-test.gjs
+++ b/frontend/discourse/tests/acceptance/sidebar-plugin-api-test.gjs
@@ -96,6 +96,10 @@ acceptance("Sidebar - Plugin API", function (needs) {
href = "https://www.discourse.org";
title = "Homepage";
text = "Homepage";
+ hoverType = "icon";
+ hoverValue = "trash-can";
+ hoverAction = () => {};
+ hoverTitle = "href hover button title";
})(),
];
willDestroy = () => (sectionDestroy = "section test");
@@ -250,11 +254,23 @@ acceptance("Sidebar - Plugin API", function (needs) {
);
assert
- .dom(".sidebar-section-link-hover button")
+ .dom(
+ ".sidebar-section-link[data-link-name='fun-channel'] .sidebar-section-link-hover button"
+ )
.hasAttribute(
"title",
"hover button title attribute",
- "displays hover button with correct title"
+ "displays hover button for route link"
+ );
+
+ assert
+ .dom(
+ ".sidebar-section-link[data-link-name='homepage'] .sidebar-section-link-hover button"
+ )
+ .hasAttribute(
+ "title",
+ "href hover button title",
+ "displays hover button for href link"
);
await click(".btn-sidebar-toggle");