A platform for community discussion. Free, open, simple.
DEV: add transformer to change new topic draft menu classes (#39888)
Kris487b589e3935
diff --git a/frontend/discourse/app/components/create-topic-button.gjs b/frontend/discourse/app/components/create-topic-button.gjsindex 6d8a93f9d89..e600b7a89fe 100644--- a/frontend/discourse/app/components/create-topic-button.gjs+++ b/frontend/discourse/app/components/create-topic-button.gjs@@ -34,16 +34,20 @@ export default class CreateTopicButton extends Component {return this.args.btnTypeClass || "btn-default";}+ get transformerContext() {+ return {+ disabled: this.args.disabled,+ canCreateTopic: this.args.canCreateTopic,+ category: this.router.currentRoute?.attributes?.category,+ tag: this.router.currentRoute?.attributes?.tag,+ };+ }+get btnClasses() {const additionalClasses = applyValueTransformer("create-topic-button-class",[],- {- disabled: this.args.disabled,- canCreateTopic: this.args.canCreateTopic,- category: this.router.currentRoute?.attributes?.category,- tag: this.router.currentRoute?.attributes?.tag,- }+ this.transformerContext);return dConcatClass(@@ -53,6 +57,16 @@ export default class CreateTopicButton extends Component {);}+ get draftMenuClasses() {+ const additionalClasses = applyValueTransformer(+ "create-topic-button-draft-menu-class",+ [],+ this.transformerContext+ );++ return concatClass(this.btnTypeClass, ...additionalClasses);+ }+<template>{{#if @canCreateTopic}}<TopicDraftsDropdown@@ -60,7 +74,7 @@ export default class CreateTopicButton extends Component {@label={{this.label}}@btnId={{this.btnId}}@btnClasses={{this.btnClasses}}- @btnTypeClass={{this.btnTypeClass}}+ @draftMenuClasses={{this.draftMenuClasses}}@showDrafts={{@showDrafts}}...attributes/>diff --git a/frontend/discourse/app/components/topic-drafts-dropdown.gjs b/frontend/discourse/app/components/topic-drafts-dropdown.gjsindex e9a7bb7b205..95a44672fb8 100644--- a/frontend/discourse/app/components/topic-drafts-dropdown.gjs+++ b/frontend/discourse/app/components/topic-drafts-dropdown.gjs@@ -121,7 +121,7 @@ export default class TopicDraftsDropdown extends Component {@onRegisterApi={{this.onRegisterApi}}@modalForMobile={{true}}aria-label={{i18n "drafts.dropdown.title"}}- class={{@btnTypeClass}}+ class={{@draftMenuClasses}}><DDropdownMenu as |dropdown|>{{#each this.drafts as |draft|}}diff --git a/frontend/discourse/app/lib/registry/transformers.js b/frontend/discourse/app/lib/registry/transformers.jsindex a1b0dc179c1..4f9508b8c2f 100644--- a/frontend/discourse/app/lib/registry/transformers.js+++ b/frontend/discourse/app/lib/registry/transformers.js@@ -52,6 +52,7 @@ export const VALUE_TRANSFORMERS = Object.freeze(["composer-service-cannot-submit-post","composer-toggles-class","create-topic-button-class",+ "create-topic-button-draft-menu-class","create-topic-label","flag-button-disabled-state","flag-button-dynamic-class",