File tree Expand file tree Collapse file tree 9 files changed +117
-15
lines changed
assets/javascripts/discourse
tests/integration/components Expand file tree Collapse file tree 9 files changed +117
-15
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import SearchMenu from "discourse/components/search-menu";
9
9
import bodyClass from " discourse/helpers/body-class" ;
10
10
import concatClass from " discourse/helpers/concat-class" ;
11
11
import { prioritizeNameFallback } from " discourse/lib/settings" ;
12
+ import { defaultHomepage } from " discourse/lib/utilities" ;
12
13
import I18n , { i18n } from " discourse-i18n" ;
13
14
14
15
export default class WelcomeBanner extends Component {
@@ -49,11 +50,25 @@ export default class WelcomeBanner extends Component {
49
50
});
50
51
51
52
get displayForRoute () {
52
- return this .siteSettings .top_menu
53
- .split (" |" )
54
- .any (
55
- (menuItem ) => ` discovery.${ menuItem} ` === this .router .currentRouteName
56
- );
53
+ switch (this .siteSettings .welcome_banner_page_visibility ) {
54
+ case " top_menu_pages" :
55
+ return this .siteSettings .top_menu
56
+ .split (" |" )
57
+ .any (
58
+ (menuItem ) =>
59
+ ` discovery.${ menuItem} ` === this .router .currentRouteName
60
+ );
61
+ case " homepage" :
62
+ return (
63
+ this .router .currentRouteName === ` discovery.${ defaultHomepage ()} `
64
+ );
65
+ case " discovery" :
66
+ return this .router .currentRouteName .startsWith (" discovery." );
67
+ case " all_pages" :
68
+ return true ;
69
+ default :
70
+ return false ;
71
+ }
57
72
}
58
73
59
74
get headerText () {
@@ -91,7 +106,7 @@ export default class WelcomeBanner extends Component {
91
106
}
92
107
93
108
get locationClass () {
94
- return ` --${ dasherize (this .siteSettings .welcome_banner_location )} ` ;
109
+ return ` --location- ${ dasherize (this .siteSettings .welcome_banner_location )} ` ;
95
110
}
96
111
97
112
<template >
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ module(
18
18
test (" applies the welcome_banner_location CSS class" , async function (assert ) {
19
19
this .siteSettings .welcome_banner_location = " above_topic_content" ;
20
20
await render (<template ><WelcomeBanner /></template >);
21
- assert .dom (" .welcome-banner.--above-topic-content" ).exists ();
21
+ assert .dom (" .welcome-banner.--location- above-topic-content" ).exists ();
22
22
23
23
this .siteSettings .welcome_banner_location = " below_site_header" ;
24
24
await render (<template ><WelcomeBanner /></template >);
25
- assert .dom (" .welcome-banner.--below-site-header" ).exists ();
25
+ assert .dom (" .welcome-banner.--location- below-site-header" ).exists ();
26
26
});
27
27
28
28
test (" shows the logged in user message with the user's username" , async function (assert ) {
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "enum_site_setting"
4
+
5
+ class WelcomeBannerPageVisibility < EnumSiteSetting
6
+ def self . valid_value? ( val )
7
+ values . any? { |v | v [ :value ] . to_s == val . to_s }
8
+ end
9
+
10
+ def self . values
11
+ @values ||= [
12
+ { name : "welcome_banner_page_visibility.top_menu_pages" , value : "top_menu_pages" } ,
13
+ { name : "welcome_banner_page_visibility.homepage" , value : "homepage" } ,
14
+ { name : "welcome_banner_page_visibility.discovery" , value : "discovery" } ,
15
+ { name : "welcome_banner_page_visibility.all_pages" , value : "all_pages" } ,
16
+ ]
17
+ end
18
+
19
+ def self . translate_names?
20
+ true
21
+ end
22
+ end
Original file line number Diff line number Diff line change @@ -2785,6 +2785,11 @@ en:
2785
2785
welcome_banner_location :
2786
2786
above_topic_content : " Above topic content"
2787
2787
below_site_header : " Below site header"
2788
+ welcome_banner_page_visibility :
2789
+ top_menu_pages : " Top menu pages"
2790
+ homepage : " Homepage"
2791
+ discovery : " Discovery"
2792
+ all_pages : " All pages"
2788
2793
composition_mode :
2789
2794
markdown : " Markdown"
2790
2795
rich : " Rich text"
Original file line number Diff line number Diff line change @@ -2718,6 +2718,7 @@ en:
2718
2718
show_topic_map_in_topics_without_replies : " Shows the topic map even if the topic has no replies."
2719
2719
enable_welcome_banner : " Display a banner on your main topic list pages to welcome members and allow them to search site content"
2720
2720
welcome_banner_location : " Determines where on the page the welcome banner will appear."
2721
+ welcome_banner_page_visibility : " Determines on which pages the welcome banner will appear."
2721
2722
2722
2723
splash_screen : " Displays a temporary loading screen while site assets load"
2723
2724
navigation_menu : " Specify sidebar or header dropdown as the main navigation menu for your site. Sidebar is recommended."
Original file line number Diff line number Diff line change @@ -3678,6 +3678,12 @@ uncategorized:
3678
3678
default : " above_topic_content"
3679
3679
area : " interface"
3680
3680
3681
+ welcome_banner_page_visibility :
3682
+ client : true
3683
+ enum : " WelcomeBannerPageVisibility"
3684
+ default : " top_menu_pages"
3685
+ area : " interface"
3686
+
3681
3687
user_preferences :
3682
3688
default_email_digest_frequency :
3683
3689
enum : " DigestEmailSiteSetting"
Original file line number Diff line number Diff line change @@ -49,11 +49,11 @@ def has_logged_in_subheader?
49
49
end
50
50
51
51
def above_topic_content?
52
- has_css? ( "#main-outlet > .--above-topic-content" , visible : :visible )
52
+ has_css? ( "#main-outlet > .--location- above-topic-content" , visible : :visible )
53
53
end
54
54
55
55
def below_site_header?
56
- has_css? ( ".discourse-root > .--below-site-header" , visible : :visible )
56
+ has_css? ( ".discourse-root > .--location- below-site-header" , visible : :visible )
57
57
end
58
58
end
59
59
end
Original file line number Diff line number Diff line change 159
159
expect ( banner ) . to be_below_site_header
160
160
end
161
161
end
162
+
163
+ context "with interface page visibility setting" do
164
+ before { current_user . update! ( admin : true ) }
165
+
166
+ it "should show on all pages" do
167
+ SiteSetting . welcome_banner_page_visibility = "all_pages"
168
+
169
+ visit "/"
170
+ expect ( banner ) . to be_visible
171
+ sign_in ( current_user )
172
+ %W[ / /u/#{ current_user . username } /preferences/emails /my/messages ] . each do |path |
173
+ visit path
174
+ expect ( banner ) . to be_visible
175
+ end
176
+ end
177
+
178
+ it "should show on discovery routes only" do
179
+ sign_in ( current_user )
180
+ SiteSetting . welcome_banner_page_visibility = "discovery"
181
+
182
+ visit "/filter?q=tag%3Ain-progress"
183
+ expect ( banner ) . to be_visible
184
+
185
+ visit "/upcoming-events?view=month"
186
+ expect ( banner ) . to be_hidden
187
+ end
188
+
189
+ it "should show on top menu pages only" do
190
+ sign_in ( current_user )
191
+ SiteSetting . welcome_banner_page_visibility = "top_menu_pages"
192
+ SiteSetting
193
+ . top_menu
194
+ . split ( "|" )
195
+ . each do |route |
196
+ visit "/#{ route } "
197
+ expect ( banner ) . to be_visible
198
+ end
199
+
200
+ visit "/my/posts"
201
+ expect ( banner ) . to be_hidden
202
+ end
203
+
204
+ it "should show on homepage only" do
205
+ SiteSetting . welcome_banner_page_visibility = "homepage"
206
+
207
+ visit "/"
208
+ expect ( banner ) . to be_visible
209
+
210
+ sign_in ( current_user )
211
+ visit "/new"
212
+ expect ( banner ) . to be_hidden
213
+ end
214
+ end
162
215
end
163
216
164
217
context "when disabled" do
Original file line number Diff line number Diff line change 1
1
@use " lib/viewport" ;
2
2
3
3
.welcome-banner {
4
- & .--below-site-header {
4
+ & .--location- below-site-header {
5
5
background-color : var (--background-color );
6
6
border-radius : 0 ;
7
7
37
37
margin-top : 0 ;
38
38
}
39
39
40
- .--below-site-header & {
40
+ .--location- below-site-header & {
41
41
border-bottom : 0 ;
42
42
padding : var (--space-4 ) var (--space-4 ) var (--space-8 );
43
43
50
50
}
51
51
}
52
52
53
- .--above-topic-content & {
53
+ .--location- above-topic-content & {
54
54
@container (width <= 800px ) {
55
55
flex-direction : column ;
56
56
gap : var (--space-4 );
65
65
width : 100% ;
66
66
align-self : center ;
67
67
68
- .--above-topic-content & {
68
+ .--location- above-topic-content & {
69
69
@container (width >= 800px ) {
70
70
width : 50 cqw;
71
71
}
113
113
margin : 0 ;
114
114
color : var (--search-color );
115
115
116
- .--above-topic-content & {
116
+ .--location- above-topic-content & {
117
117
@container (width >= 800px ) {
118
118
flex-grow : 1 ;
119
119
}
You can’t perform that action at this time.
0 commit comments