From 486edb845c4d8b144c0ba28c6cfc0c5b1119d0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= <1108771+megothss@users.noreply.github.com> Date: Fri, 23 Jun 2023 16:51:59 -0300 Subject: [PATCH] DEV: Added data attributes to identify the user settings in the UI (#22261) This commit adds data attributes to identify the controls in the user settings UI. Plugins and TCs can use this information to target each setting to highlight or hide them. Although most of the settings also have specific classes identifying them, using data attributes is more future proof as it is less likely to change them classes, specially as we increase the adoption of the BEM methodology in CSS. Using data attributes also are semantically correct as the setting name is data not really related to the classes used. --- .../components/user-notification-schedule.hbs | 5 +- .../app/templates/preferences/account.hbs | 29 ++++++--- .../app/templates/preferences/emails.hbs | 32 +++++++--- .../app/templates/preferences/interface.hbs | 35 +++++++--- .../templates/preferences/navigation-menu.hbs | 15 ++++- .../templates/preferences/notifications.hbs | 10 ++- .../app/templates/preferences/profile.hbs | 21 +++--- .../app/templates/preferences/security.hbs | 12 +++- .../app/templates/preferences/tracking.hbs | 15 ++++- .../app/templates/preferences/users.hbs | 64 +++++++++++-------- 10 files changed, 162 insertions(+), 76 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/user-notification-schedule.hbs b/app/assets/javascripts/discourse/app/components/user-notification-schedule.hbs index 56cfd657be8..8b08f2ada1c 100644 --- a/app/assets/javascripts/discourse/app/components/user-notification-schedule.hbs +++ b/app/assets/javascripts/discourse/app/components/user-notification-schedule.hbs @@ -1,4 +1,7 @@ -
+
diff --git a/app/assets/javascripts/discourse/app/templates/preferences/account.hbs b/app/assets/javascripts/discourse/app/templates/preferences/account.hbs index 400654ac0ae..df67088fda1 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences/account.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences/account.hbs @@ -1,10 +1,10 @@ -
+
{{#unless this.siteSettings.discourse_connect_overrides_avatar}} -
+
@@ -22,7 +22,7 @@ {{/unless}} {{#if this.canCheckEmails}} -
+
{{#if this.model.email}} {{#if this.siteSettings.enable_secondary_emails}} @@ -111,7 +111,10 @@ {{/if}} {{#if this.canUpdateAssociatedAccounts}} -
+
@@ -175,7 +178,7 @@ {{/if}} {{#if this.canEditName}} -
+
{{#if this.model.can_edit_name}} @@ -195,7 +198,7 @@ {{/if}} {{#if this.canSelectTitle}} -
+
+
+
{{#if this.newStatus}} @@ -251,7 +254,10 @@ {{/if}} {{#if this.canSelectPrimaryGroup}} -
+
+
-
+
@@ -24,7 +27,7 @@ {{/if}}
-
+
-
+
@@ -65,12 +72,16 @@
{{#if this.model.user_option.email_digests}} -
+
-
{{html-safe - (i18n "user.mailing_list_mode.instructions") - }}
+
+ {{html-safe (i18n "user.mailing_list_mode.instructions")}} +
{{#if this.model.user_option.mailing_list_mode}} -
+
{{#if this.showThemeSelector}} -
+
+
{{i18n "user.color_scheme"}}
@@ -90,7 +93,7 @@ {{/if}} {{#if this.showDarkModeToggle}} -
+
{{/if}} -
+
@@ -125,7 +128,7 @@
{{#if this.siteSettings.allow_user_locale}} -
+
@@ -146,7 +149,7 @@
{{/if}} -
+
-
+
{{i18n "user.other_settings"}} {{#if this.siteSettings.automatically_unpin_topics}} {{/if}} {{#if this.siteSettings.allow_users_to_hide_profile}} @@ -189,14 +196,19 @@ @labelKey="user.hide_profile_and_presence" @checked={{this.model.user_option.hide_profile_and_presence}} @class="pref-hide-profile" + data-setting-name="user-hide-profile" /> {{/if}} -
+
@@ -208,7 +220,10 @@ @onChange={{action (mut this.model.user_option.title_count_mode)}} />
-
+
@@ -226,11 +241,13 @@ @labelKey="user.skip_new_user_tips.description" @checked={{this.model.user_option.skip_new_user_tips}} @class="pref-new-user-tips" + data-setting-name="user-new-user-tips" /> {{#if this.site.user_tips}} {{i18n "user.reset_seen_user_tips"}} {{/if}}
diff --git a/app/assets/javascripts/discourse/app/templates/preferences/navigation-menu.hbs b/app/assets/javascripts/discourse/app/templates/preferences/navigation-menu.hbs index ce03f6496e5..a1aab208b4d 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences/navigation-menu.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences/navigation-menu.hbs @@ -1,4 +1,7 @@ -
+
{{i18n "user.experimental_sidebar.categories_section" }} @@ -20,7 +23,10 @@
{{#if this.model.display_sidebar_tags}} -
+
{{i18n "user.experimental_sidebar.tags_section" }} @@ -41,7 +47,10 @@
{{/if}} -
+
{{i18n "user.experimental_sidebar.navigation_section" }} diff --git a/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs b/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs index 28e0a7355d3..6b0f382fb1f 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs @@ -1,7 +1,10 @@
-
+
{{#unless this.capabilities.isAppWebview}} -
+
diff --git a/app/assets/javascripts/discourse/app/templates/preferences/profile.hbs b/app/assets/javascripts/discourse/app/templates/preferences/profile.hbs index 8d4021793fd..b87f0754a5d 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences/profile.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences/profile.hbs @@ -1,5 +1,5 @@ {{#if this.canChangeBio}} -
+
@@ -7,7 +7,7 @@
{{/if}} -
+
{{#if this.model.can_change_location}} -
+
@@ -39,7 +39,7 @@ {{/if}} {{#if this.model.can_change_website}} -
+
@@ -55,7 +55,7 @@ {{/if}} {{#each this.userFields as |uf|}} -
+
{{/each}} @@ -63,7 +63,10 @@ {{#if this.siteSettings.allow_profile_backgrounds}} {{#if this.canUploadProfileHeader}} -
+
@@ -80,7 +83,7 @@
{{/if}} {{#if this.canUploadUserCardBackground}} -
+
@@ -99,7 +102,7 @@ {{/if}} {{#if this.siteSettings.allow_featured_topic_on_user_profiles}} -
+
{{#if this.model.featured_topic}}