Skip to content

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

FIX: Horizon > Apply `create-topic-label` transformer to Horizon sidebar button (#40730)

chapoi28d4adf0dbea
diff --git a/themes/horizon/javascripts/discourse/components/sidebar-new-topic-button.gjs b/themes/horizon/javascripts/discourse/components/sidebar-new-topic-button.gjs
index 7894a7a40b2..8b92c634683 100644
--- a/themes/horizon/javascripts/discourse/components/sidebar-new-topic-button.gjs
+++ b/themes/horizon/javascripts/discourse/components/sidebar-new-topic-button.gjs
@@ -8,12 +8,14 @@ import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
import { service } from "@ember/service";
import CreateTopicButton from "discourse/components/create-topic-button";
import bodyClass from "discourse/helpers/body-class";
+import { applyValueTransformer } from "discourse/lib/transformer";
import { gt } from "discourse/truth-helpers";
export default class SidebarNewTopicButton extends Component {
@service composer;
@service currentUser;
@service siteSettings;
+ @service site;
@service router;
@service header;
@service appEvents;
@@ -38,6 +40,36 @@ export default class SidebarNewTopicButton extends Component {
return this.currentUser?.get("draft_count");
}
+ get createTopicLabel() {
+ const defaultKey = "topic.create";
+ let value = defaultKey;
+
+ if (
+ this.site.shared_drafts_category_id &&
+ this.category?.id === this.site.shared_drafts_category_id
+ ) {
+ value = "topic.create_shared_draft";
+ }
+
+ return applyValueTransformer("create-topic-label", value, {
+ site: this.site,
+ defaultKey,
+ category: this.category,
+ currentUser: this.currentUser,
+ });
+ }
+
+ get createTopicIcon() {
+ const defaultIcon = "far-pen-to-square";
+
+ return applyValueTransformer("create-topic-icon", defaultIcon, {
+ site: this.site,
+ defaultIcon,
+ category: this.category,
+ currentUser: this.currentUser,
+ });
+ }
+
get createTopicTargetCategory() {
let subcategory;
@@ -91,7 +123,8 @@ export default class SidebarNewTopicButton extends Component {
{{willDestroy this.stopWatchingForComposer}}
@canCreateTopic={{this.canCreateTopic}}
@action={{this.createNewTopic}}
- @label="topic.create"
+ @label={{this.createTopicLabel}}
+ @icon={{this.createTopicIcon}}
@btnClass="sidebar-new-topic-button"
@btnTypeClass="btn-primary"
@showDrafts={{gt this.draftCount 0}}
diff --git a/themes/horizon/scss/sidebar.scss b/themes/horizon/scss/sidebar.scss
index e3d37a1b7fa..2efb2b57134 100644
--- a/themes/horizon/scss/sidebar.scss
+++ b/themes/horizon/scss/sidebar.scss
@@ -88,10 +88,6 @@ body.has-full-page-chat .sidebar-wrapper,
.sidebar-new-topic-button__wrapper {
margin: 0 var(--space-2) var(--space-4) var(--space-4);
-
- .sidebar-new-topic-button .d-icon {
- display: none;
- }
}
// put the draft menu above the slide-out hamburger on small desktop screens