Skip to content

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

DEV: Add welcome-banner-display-for-route value transformer (#37836)

Martin Brennan08484ffbc9f6
diff --git a/frontend/discourse/app/components/welcome-banner.gjs b/frontend/discourse/app/components/welcome-banner.gjs
index 4c532359afd..77abc7d8706 100644
--- a/frontend/discourse/app/components/welcome-banner.gjs
+++ b/frontend/discourse/app/components/welcome-banner.gjs
@@ -10,6 +10,7 @@ import bodyClass from "discourse/helpers/body-class";
import concatClass from "discourse/helpers/concat-class";
import { prioritizeNameFallback } from "discourse/lib/settings";
import { sanitize } from "discourse/lib/text";
+import { applyValueTransformer } from "discourse/lib/transformer";
import { defaultHomepage, escapeExpression } from "discourse/lib/utilities";
import I18n, { i18n } from "discourse-i18n";
@@ -76,6 +77,28 @@ export default class WelcomeBanner extends Component {
const { currentRouteName } = this.router;
const { top_menu, welcome_banner_page_visibility } = this.siteSettings;
+ const shouldDisplayForRoute = this.#shouldDisplayForRoute(
+ welcome_banner_page_visibility,
+ top_menu,
+ currentRouteName
+ );
+
+ return applyValueTransformer(
+ "welcome-banner-display-for-route",
+ shouldDisplayForRoute,
+ {
+ welcomeBannerPageVisibility: welcome_banner_page_visibility,
+ currentRouteName,
+ homepage: `discovery.${defaultHomepage()}`,
+ }
+ );
+ }
+
+ #shouldDisplayForRoute(
+ welcome_banner_page_visibility,
+ top_menu,
+ currentRouteName
+ ) {
switch (welcome_banner_page_visibility) {
case "top_menu_pages":
return top_menu
diff --git a/frontend/discourse/app/lib/transformer/registry.js b/frontend/discourse/app/lib/transformer/registry.js
index 451fe813729..a80f8d11efd 100644
--- a/frontend/discourse/app/lib/transformer/registry.js
+++ b/frontend/discourse/app/lib/transformer/registry.js
@@ -89,4 +89,5 @@ export const VALUE_TRANSFORMERS = Object.freeze([
"user-field-components",
"user-menu-notification-item-acting-user-avatar",
"user-notes-modal-subtitle",
+ "welcome-banner-display-for-route",
]);