diff --git a/app/assets/javascripts/admin/addon/templates/admin-badges/award.hbs b/app/assets/javascripts/admin/addon/templates/admin-badges/award.hbs index dd94af3ff76..89abd308753 100644 --- a/app/assets/javascripts/admin/addon/templates/admin-badges/award.hbs +++ b/app/assets/javascripts/admin/addon/templates/admin-badges/award.hbs @@ -1,4 +1,4 @@ - +

{{i18n "admin.badges.mass_award.title"}}

{{i18n "admin.badges.mass_award.description"}}

@@ -93,4 +93,4 @@ "admin.badges.mass_award.no_badge_selected" }} {{/if}} - \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/admin/addon/templates/admin-badges/index.hbs b/app/assets/javascripts/admin/addon/templates/admin-badges/index.hbs index f322e03759c..16c92c4b761 100644 --- a/app/assets/javascripts/admin/addon/templates/admin-badges/index.hbs +++ b/app/assets/javascripts/admin/addon/templates/admin-badges/index.hbs @@ -1,4 +1,4 @@ - +
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs index 1207f868085..52ce5688648 100644 --- a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs +++ b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs @@ -1,4 +1,4 @@ - +
- +
{{#if this.grant_count}}
diff --git a/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbs b/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbs index 8a2acc2e1c0..002420bb2e6 100644 --- a/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbs +++ b/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbs @@ -269,8 +269,8 @@ {{/if}} {{#unless this.model.component}} -
@@ -305,11 +305,11 @@ {{/if}}
-
+ {{/unless}} {{#if this.model.component}} - +
- +
{{else}} - +
- +
{{/if}} {{#unless this.model.remote_theme.is_git}} @@ -421,7 +421,7 @@

{{i18n "admin.customize.theme.overriden_settings_explanation" }}

- +
{{#each this.settings as |setting|}} {{/each}} - +
{{/if}} @@ -438,8 +438,8 @@
{{i18n "admin.customize.theme.theme_translations" }}
- {{#each this.translations as |translation|}} {{/each}} - + {{/if}} diff --git a/app/assets/javascripts/admin/addon/templates/site-settings-category.hbs b/app/assets/javascripts/admin/addon/templates/site-settings-category.hbs index 3fba14e61cd..f43d4a526c2 100644 --- a/app/assets/javascripts/admin/addon/templates/site-settings-category.hbs +++ b/app/assets/javascripts/admin/addon/templates/site-settings-category.hbs @@ -1,5 +1,5 @@ {{#if this.filteredContent}} - +
{{#each this.filteredContent as |setting|}} {{/if}} - +
{{else}}
{{i18n "admin.site_settings.no_results"}} diff --git a/app/assets/javascripts/admin/addon/templates/user.hbs b/app/assets/javascripts/admin/addon/templates/user.hbs index 50661dee2f7..04df95f2d26 100644 --- a/app/assets/javascripts/admin/addon/templates/user.hbs +++ b/app/assets/javascripts/admin/addon/templates/user.hbs @@ -1,3 +1 @@ - - {{outlet}} - \ No newline at end of file +
{{outlet}}
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/d-lightbox.hbs b/app/assets/javascripts/discourse/app/components/d-lightbox.hbs index 8893bc55b91..a4ab8c8b943 100644 --- a/app/assets/javascripts/discourse/app/components/d-lightbox.hbs +++ b/app/assets/javascripts/discourse/app/components/d-lightbox.hbs @@ -1,9 +1,8 @@ - @@ -81,4 +80,4 @@
{{/if}} -
\ No newline at end of file + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/d-section.gjs b/app/assets/javascripts/discourse/app/components/d-section.gjs new file mode 100644 index 00000000000..2edd783e622 --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/d-section.gjs @@ -0,0 +1,36 @@ +import Component from "@glimmer/component"; +import bodyClass from "discourse/helpers/body-class"; +import { concat } from "@ember/helper"; +import notEq from "truth-helpers/helpers/not-eq"; +import deprecated from "discourse-common/lib/deprecated"; + +// Can add a body class from within a component +export default class DSection extends Component { + + + constructor() { + super(...arguments); + deprecated( + ` is deprecated. Use {{body-class "foo-page" "bar"}} and/or
instead.`, + { + since: "3.2.0.beta1", + dropFrom: "3.3.0.beta1", + id: "discourse.d-section", + } + ); + } +} diff --git a/app/assets/javascripts/discourse/app/components/d-section.js b/app/assets/javascripts/discourse/app/components/d-section.js deleted file mode 100644 index 3746a3855d6..00000000000 --- a/app/assets/javascripts/discourse/app/components/d-section.js +++ /dev/null @@ -1,47 +0,0 @@ -import Component from "@ember/component"; -import { scheduleOnce } from "@ember/runloop"; - -// Can add a body class from within a component -export default class extends Component { - tagName = null; - pageClass = null; - bodyClass = null; - currentClasses = new Set(); - - didReceiveAttrs() { - this._super(...arguments); - scheduleOnce("afterRender", this, this._updateClasses); - } - - willDestroyElement() { - this._super(...arguments); - scheduleOnce("afterRender", this, this._removeClasses); - } - - _updateClasses() { - if (this.isDestroying || this.isDestroyed) { - return; - } - - const desiredClasses = new Set(); - if (this.pageClass) { - desiredClasses.add(`${this.pageClass}-page`); - } - if (this.bodyClass) { - for (const bodyClass of this.bodyClass.split(" ")) { - desiredClasses.add(bodyClass); - } - } - - document.body.classList.add(...desiredClasses); - const removeClasses = [...this.currentClasses].filter( - (c) => !desiredClasses.has(c) - ); - document.body.classList.remove(...removeClasses); - this.currentClasses = desiredClasses; - } - - _removeClasses() { - document.body.classList.remove(...this.currentClasses); - } -} diff --git a/app/assets/javascripts/discourse/app/components/sidebar.hbs b/app/assets/javascripts/discourse/app/components/sidebar.hbs index b3277988731..27a16749e5c 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar.hbs @@ -1,4 +1,6 @@ - +{{body-class "has-sidebar-page"}} + + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/helpers/body-class.js b/app/assets/javascripts/discourse/app/helpers/body-class.js new file mode 100644 index 00000000000..c7322b725ff --- /dev/null +++ b/app/assets/javascripts/discourse/app/helpers/body-class.js @@ -0,0 +1,13 @@ +import Helper from "@ember/component/helper"; +import { inject as service } from "@ember/service"; + +export default class BodyClass extends Helper { + @service bodyClasses; + + compute([...classes]) { + this.bodyClasses.registerClasses( + this, + classes.flatMap((c) => c?.split(" ")).filter(Boolean) + ); + } +} diff --git a/app/assets/javascripts/discourse/app/services/body-classes.js b/app/assets/javascripts/discourse/app/services/body-classes.js new file mode 100644 index 00000000000..3af38889168 --- /dev/null +++ b/app/assets/javascripts/discourse/app/services/body-classes.js @@ -0,0 +1,39 @@ +import Service from "@ember/service"; +import { disableImplicitInjections } from "discourse/lib/implicit-injections"; +import { registerDestructor } from "@ember/destroyable"; + +@disableImplicitInjections +export default class BodyClassesService extends Service { + #helpers = new Map(); + + registerClasses(helper, classes) { + if (this.#helpers.has(helper)) { + const previousClasses = this.#helpers.get(helper); + + this.#helpers.set(helper, classes); + this.removeUnusedClasses(previousClasses); + } else { + this.#helpers.set(helper, classes); + + registerDestructor(helper, () => { + const previousClasses = this.#helpers.get(helper); + this.#helpers.delete(helper); + this.removeUnusedClasses(previousClasses); + }); + } + + for (const bodyClass of classes) { + document.body.classList.add(bodyClass); + } + } + + removeUnusedClasses(classes) { + const remainingClasses = new Set([...this.#helpers.values()].flat()); + + for (const bodyClass of classes) { + if (!remainingClasses.has(bodyClass)) { + document.body.classList.remove(bodyClass); + } + } + } +} diff --git a/app/assets/javascripts/discourse/app/templates/about.hbs b/app/assets/javascripts/discourse/app/templates/about.hbs index f3b54c9d648..eadf0c0bcd7 100644 --- a/app/assets/javascripts/discourse/app/templates/about.hbs +++ b/app/assets/javascripts/discourse/app/templates/about.hbs @@ -1,4 +1,6 @@ - +{{body-class "about-page"}} + +
@@ -172,4 +174,4 @@
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/badges/index.hbs b/app/assets/javascripts/discourse/app/templates/badges/index.hbs index 5d57beb177b..abf4c169218 100644 --- a/app/assets/javascripts/discourse/app/templates/badges/index.hbs +++ b/app/assets/javascripts/discourse/app/templates/badges/index.hbs @@ -1,4 +1,6 @@ - +{{body-class "badges-page"}} + +

{{i18n "badges.title"}}

@@ -21,4 +23,4 @@ {{/each}}
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/d-section.hbs b/app/assets/javascripts/discourse/app/templates/d-section.hbs deleted file mode 100644 index 3e6bdec3936..00000000000 --- a/app/assets/javascripts/discourse/app/templates/d-section.hbs +++ /dev/null @@ -1 +0,0 @@ -
{{yield}}
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/faq.hbs b/app/assets/javascripts/discourse/app/templates/faq.hbs index b729b06218a..dbf2f74fb8f 100644 --- a/app/assets/javascripts/discourse/app/templates/faq.hbs +++ b/app/assets/javascripts/discourse/app/templates/faq.hbs @@ -1,4 +1,6 @@ - +{{body-class (concat "static-" this.model.path)}} + +
@@ -6,4 +8,4 @@
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/full-page-search.hbs b/app/assets/javascripts/discourse/app/templates/full-page-search.hbs index 874d620bf7f..ec24cdeab38 100644 --- a/app/assets/javascripts/discourse/app/templates/full-page-search.hbs +++ b/app/assets/javascripts/discourse/app/templates/full-page-search.hbs @@ -2,7 +2,9 @@ {{hide-application-footer}} {{/if}} - +{{body-class "search-page"}} + +
{{/if}} - \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/groups/index.hbs b/app/assets/javascripts/discourse/app/templates/groups/index.hbs index 9b536cccbbd..0dcdd0dc8fb 100644 --- a/app/assets/javascripts/discourse/app/templates/groups/index.hbs +++ b/app/assets/javascripts/discourse/app/templates/groups/index.hbs @@ -2,9 +2,11 @@ {{hide-application-footer}} {{/if}} +{{body-class "groups-page"}} + - +
{{#if this.currentUser.can_create_group}} {{i18n "groups.index.empty"}}

{{/if}} - - +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/groups/new.hbs b/app/assets/javascripts/discourse/app/templates/groups/new.hbs index 69028bc4262..32755bdc727 100644 --- a/app/assets/javascripts/discourse/app/templates/groups/new.hbs +++ b/app/assets/javascripts/discourse/app/templates/groups/new.hbs @@ -1,4 +1,6 @@ - +{{body-class "groups-new-page"}} + +

{{i18n "admin.groups.new.title"}}


@@ -51,4 +53,4 @@ - \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/invites/show.hbs b/app/assets/javascripts/discourse/app/templates/invites/show.hbs index b9c00c61a54..8b75725a4fe 100644 --- a/app/assets/javascripts/discourse/app/templates/invites/show.hbs +++ b/app/assets/javascripts/discourse/app/templates/invites/show.hbs @@ -1,4 +1,6 @@ - +{{body-class "invite-page"}} + +
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/login.hbs b/app/assets/javascripts/discourse/app/templates/login.hbs index c598fb59c39..85ea8f5780c 100644 --- a/app/assets/javascripts/discourse/app/templates/login.hbs +++ b/app/assets/javascripts/discourse/app/templates/login.hbs @@ -1,4 +1,6 @@ - +{{body-class "static-login"}} + +
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/navigation/categories.hbs b/app/assets/javascripts/discourse/app/templates/navigation/categories.hbs index 9ddc0f1ed95..083d89409ff 100644 --- a/app/assets/javascripts/discourse/app/templates/navigation/categories.hbs +++ b/app/assets/javascripts/discourse/app/templates/navigation/categories.hbs @@ -1,4 +1,6 @@ - +{{body-class "navigation-categories"}} + + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/navigation/category.hbs b/app/assets/javascripts/discourse/app/templates/navigation/category.hbs index 8d63ff9deb6..63e15ddd6bd 100644 --- a/app/assets/javascripts/discourse/app/templates/navigation/category.hbs +++ b/app/assets/javascripts/discourse/app/templates/navigation/category.hbs @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/navigation/default.hbs b/app/assets/javascripts/discourse/app/templates/navigation/default.hbs index 3ce41264012..911938aca96 100644 --- a/app/assets/javascripts/discourse/app/templates/navigation/default.hbs +++ b/app/assets/javascripts/discourse/app/templates/navigation/default.hbs @@ -1,4 +1,6 @@ - +{{body-class "navigation-topics"}} + + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/navigation/filter.hbs b/app/assets/javascripts/discourse/app/templates/navigation/filter.hbs index 8e6d697fe1b..653aa04d5b7 100644 --- a/app/assets/javascripts/discourse/app/templates/navigation/filter.hbs +++ b/app/assets/javascripts/discourse/app/templates/navigation/filter.hbs @@ -1,4 +1,6 @@ - +{{body-class "navigation-filter"}} + + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/preferences-email.hbs b/app/assets/javascripts/discourse/app/templates/preferences-email.hbs index 14136432eef..0a9307be39f 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences-email.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences-email.hbs @@ -1,54 +1,53 @@ - -
-
- {{#if this.success}} -
{{this.successMessage}}
- - {{d-icon "arrow-left"}} - {{i18n "user.change_email.back_to_preferences"}} - +{{body-class "user-preferences-page"}} - {{else}} - {{#if this.error}} -
{{this.errorMessage}}
- {{/if}} -
- -
- -
- {{#if this.taken}} - {{i18n "user.change_email.taken"}} - {{else}} - {{i18n "user.email.instructions"}} - {{/if}} -
- -
-
-
- - -
+
+ + {{#if this.success}} +
{{this.successMessage}}
+ + {{d-icon "arrow-left"}} + {{i18n "user.change_email.back_to_preferences"}} + + {{else}} + {{#if this.error}} +
{{this.errorMessage}}
{{/if}} - -
- \ No newline at end of file +
+ +
+ +
+ {{#if this.taken}} + {{i18n "user.change_email.taken"}} + {{else}} + {{i18n "user.email.instructions"}} + {{/if}} +
+ +
+
+
+ + +
+ {{/if}} + +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs b/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs index 82a5fc4276d..48c946884f1 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences-second-factor.hbs @@ -1,213 +1,213 @@ - -
- -
- {{#if this.showEnforcedNotice}} -
{{i18n - "user.second_factor.enforced_notice" - }}
- {{/if}} +{{body-class "user-preferences-page"}} - {{#if this.displayOAuthWarning}} -
{{i18n - "user.second_factor.oauth_enabled_warning" - }}
- {{/if}} +
+ + + {{#if this.showEnforcedNotice}} +
{{i18n + "user.second_factor.enforced_notice" + }}
+ {{/if}} - {{#if this.errorMessage}} -
{{this.errorMessage}}
- {{/if}} + {{#if this.displayOAuthWarning}} +
{{i18n + "user.second_factor.oauth_enabled_warning" + }}
+ {{/if}} - {{#if this.loaded}} -
-
-

{{i18n "user.second_factor.totp.title"}}

- {{#each this.totps as |totp|}} -
-
- {{#if totp.name}} - {{totp.name}} - {{else}} - {{i18n "user.second_factor.totp.default_name"}} - {{/if}} -
- {{#if this.isCurrentUser}} -
- -
- {{/if}} -
- {{/each}} - -
-
+ {{#if this.errorMessage}} +
{{this.errorMessage}}
+ {{/if}} -
-
-

{{i18n "user.second_factor.security_key.title"}}

- {{#each this.security_keys as |security_key|}} -
-
- {{#if security_key.name}} - {{security_key.name}} - {{else}} - {{i18n "user.second_factor.security_key.default_name"}} - {{/if}} -
- - {{#if this.isCurrentUser}} -
- -
- {{/if}} -
- {{/each}} - -
-
- -
-
-

{{i18n "user.second_factor_backup.title"}}

+ {{#if this.loaded}} +
+
+

{{i18n "user.second_factor.totp.title"}}

+ {{#each this.totps as |totp|}}
- {{#if this.model.second_factor_enabled}} -
- {{#if this.model.second_factor_backup_enabled}} - {{html-safe - (i18n - "user.second_factor_backup.manage" - count=this.model.second_factor_remaining_backup_codes - ) - }} - {{else}} - - {{/if}} -
- - {{#if - (and - this.model.second_factor_backup_enabled this.isCurrentUser - ) - }} -
- -
+
+ {{#if totp.name}} + {{totp.name}} + {{else}} + {{i18n "user.second_factor.totp.default_name"}} {{/if}} - - {{else}} - {{i18n "user.second_factor_backup.enable_prerequisites"}} +
+ {{#if this.isCurrentUser}} +
+ +
{{/if}}
-
+ {{/each}} +
+
- {{#if this.model.second_factor_enabled}} - {{#unless this.showEnforcedNotice}} -
-
- - +
+
+

{{i18n "user.second_factor.security_key.title"}}

+ {{#each this.security_keys as |security_key|}} +
+
+ {{#if security_key.name}} + {{security_key.name}} + {{else}} + {{i18n "user.second_factor.security_key.default_name"}} + {{/if}}
-
- {{/unless}} - {{/if}} - {{else}} -
- -
-
- -
-
- {{i18n "user.second_factor.confirm_password_description"}} + {{#if this.isCurrentUser}} +
+ +
+ {{/if}}
+ {{/each}} + +
+
+ +
+
+

{{i18n "user.second_factor_backup.title"}}

+
+ {{#if this.model.second_factor_enabled}} +
+ {{#if this.model.second_factor_backup_enabled}} + {{html-safe + (i18n + "user.second_factor_backup.manage" + count=this.model.second_factor_remaining_backup_codes + ) + }} + {{else}} + + {{/if}} +
+ + {{#if + (and + this.model.second_factor_backup_enabled this.isCurrentUser + ) + }} +
+ +
+ {{/if}} + + {{else}} + {{i18n "user.second_factor_backup.enable_prerequisites"}} + {{/if}}
+
-
-
- - - {{#unless this.showEnforcedNotice}} + {{#if this.model.second_factor_enabled}} + {{#unless this.showEnforcedNotice}} +
+
+ - {{/unless}} +
-
- {{this.resetPasswordProgress}} - {{#unless this.resetPasswordLoading}} - {{i18n "user.second_factor.forgot_password"}} - {{/unless}} + {{/unless}} + {{/if}} + {{else}} +
+ + +
+
+ +
+
+ {{i18n "user.second_factor.confirm_password_description"}}
- {{/if}} - - -
- \ No newline at end of file + + +
+
+ + + {{#unless this.showEnforcedNotice}} + + {{/unless}} +
+
+ {{this.resetPasswordProgress}} + {{#unless this.resetPasswordLoading}} + {{i18n "user.second_factor.forgot_password"}} + {{/unless}} +
+
+ {{/if}} + +
+
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/preferences.hbs b/app/assets/javascripts/discourse/app/templates/preferences.hbs index 16435e6cb84..6309d5ae0a9 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences.hbs @@ -1,4 +1,4 @@ - +{{body-class "user-preferences-page"}}
diff --git a/app/assets/javascripts/discourse/app/templates/privacy.hbs b/app/assets/javascripts/discourse/app/templates/privacy.hbs index 7108ee67f47..5ac88e0119b 100644 --- a/app/assets/javascripts/discourse/app/templates/privacy.hbs +++ b/app/assets/javascripts/discourse/app/templates/privacy.hbs @@ -1,7 +1,9 @@ - +{{body-class "static-privacy"}} + +
{{html-safe this.model.html}}
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/tag/show.hbs b/app/assets/javascripts/discourse/app/templates/tag/show.hbs index 6c3750fd2fa..0c52faf3483 100644 --- a/app/assets/javascripts/discourse/app/templates/tag/show.hbs +++ b/app/assets/javascripts/discourse/app/templates/tag/show.hbs @@ -2,200 +2,188 @@ {{hide-application-footer}} {{/if}} - -
- -
+{{body-class + "tags-page" + (concat "tag-" this.tag.id) + (if this.category.slug (concat "category-" this.category.slug)) + (if this.additionalTags "tags-intersection") +}} - - - +
+ +
-
- -
- -
-
- - {{#if this.showInfo}} - - {{/if}} - - - - - - + +
+ +
+
-
-
-
- -
- {{#unless this.loading}} - - {{#if this.top}} -
- +{{#if this.showInfo}} + +{{/if}} + + + + + + + + + + + +
+
+
+ +
+ {{#unless this.loading}} + + {{#if this.top}} +
+ +
+ {{else}} + {{#if this.topicTrackingState.hasIncoming}} + - {{else}} - {{#if this.topicTrackingState.hasIncoming}} -
- - - -
- {{/if}} {{/if}} - {{#unless this.bulkSelectEnabled}} - {{#if - (and this.showTopicsAndRepliesToggle this.site.mobileView) - }} - - {{/if}} - {{/unless}} - {{#if this.list.topics}} - {{/if}} -
- -
- + {{/if}} + - {{#unless this.list.canLoadMore}} - - {{html-safe - (i18n - "topic.browse_all_tags_or_latest" basePath=(base-path) - ) - }} - - {{/unless}} -
- {{/unless}} +
+ - -
+ {{#unless this.list.canLoadMore}} + + {{html-safe + (i18n "topic.browse_all_tags_or_latest" basePath=(base-path)) + }} + + {{/unless}} + + {{/unless}} + +
+
- - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/tags.hbs b/app/assets/javascripts/discourse/app/templates/tags.hbs index bdb3d41c392..e3947aa1710 100644 --- a/app/assets/javascripts/discourse/app/templates/tags.hbs +++ b/app/assets/javascripts/discourse/app/templates/tags.hbs @@ -1,3 +1,2 @@ - - {{outlet}} - \ No newline at end of file +{{body-class "tags-page"}} +{{outlet}} \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/tos.hbs b/app/assets/javascripts/discourse/app/templates/tos.hbs index a334271b1f2..8a0b7fda843 100644 --- a/app/assets/javascripts/discourse/app/templates/tos.hbs +++ b/app/assets/javascripts/discourse/app/templates/tos.hbs @@ -1,7 +1,9 @@ - +{{body-class "static-tos"}} + +
{{html-safe this.model.html}}
- \ No newline at end of file +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs b/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs index 811017f0a4f..549adaa10e4 100644 --- a/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs +++ b/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs @@ -1,230 +1,226 @@ - - {{#if this.canInviteToForum}} - - - {{#if this.showSearch}} - +{{body-class "user-invites-page"}} + +{{#if this.canInviteToForum}} + +
+ {{#if this.showSearch}} + + {{/if}} +
+ + {{#if this.canBulkInvite}} + {{#if this.siteSettings.allow_bulk_invite}} + {{#unless this.site.mobileView}} + + {{/unless}} + {{/if}} {{/if}} - - - {{#if this.canBulkInvite}} - {{#if this.siteSettings.allow_bulk_invite}} - {{#unless this.site.mobileView}} - - {{/unless}} - {{/if}} - {{/if}} - {{#if this.showBulkActionButtons}} - {{#if this.inviteExpired}} - {{#if this.removedAll}} - - {{i18n "user.invited.removed_all"}} - - {{else}} - - {{/if}} - {{/if}} - - {{#if this.invitePending}} - {{#if this.reinvitedAll}} - - - - {{else if this.hasEmailInvites}} - - {{/if}} - {{/if}} - {{/if}} - - -
- {{#if this.model.invites}} - {{#if this.inviteRedeemed}} - - - - - - {{#if this.model.can_see_invite_details}} - - - - - - - {{/if}} - - - - {{#each this.model.invites as |invite|}} - - - - {{#if this.model.can_see_invite_details}} - - - - - - - {{/if}} - - {{/each}} - -
{{i18n "user.invited.user"}}{{i18n "user.invited.redeemed_at"}}{{i18n "user.last_seen"}}{{i18n "user.invited.topics_entered"}}{{i18n "user.invited.posts_read_count"}}{{i18n "user.invited.time_read"}}{{i18n "user.invited.days_visited"}}{{i18n "user.invited.invited_via"}}
- {{avatar - invite.user - imageSize="tiny" - }} - {{invite.user.username}} - {{format-date invite.redeemed_at}}{{format-date invite.user.last_seen_at}}{{number invite.user.topics_entered}}{{number invite.user.posts_read_count}}{{format-duration invite.user.time_read}} - {{html-safe invite.user.days_visited}} - / - {{html-safe invite.user.days_since_created}} - {{html-safe invite.invite_source}}
- {{else}} - - - - - - - - - - - {{#each this.model.invites as |invite|}} - - - - - - - - {{#if invite.can_delete_invite}} - - {{/if}} - - {{/each}} - -
{{i18n "user.invited.invited_via"}}{{i18n "user.invited.sent"}}{{i18n "user.invited.expires_at"}}
-
{{i18n - "user.invited.invited_via" - }}
- {{#if invite.email}} - {{d-icon "envelope"}} - {{invite.email}} - {{else}} - {{d-icon "link"}} - {{i18n - "user.invited.invited_via_link" - key=invite.shortKey - count=invite.redemption_count - max=invite.max_redemptions_allowed - }} - {{/if}} - - {{#each invite.groups as |g|}} -

{{d-icon - "users" - }} - {{g.name}}

- {{/each}} - - {{#if invite.topic}} -

{{d-icon "file"}} {{invite.topic.title}}

- {{/if}} -
-
{{i18n "user.invited.sent"}}
- {{format-date invite.updated_at}} -
-
{{i18n - "user.invited.expires_at" - }}
- {{#if this.inviteExpired}} - {{raw-date invite.expires_at}} - {{else if invite.expired}} - {{i18n "user.invited.expired"}} - {{else}} - {{raw-date invite.expires_at}} - {{/if}} -
- - -
- {{/if}} - - - {{else}} -
- {{#if this.canBulkInvite}} - {{html-safe (i18n "user.invited.bulk_invite.none")}} + {{#if this.showBulkActionButtons}} + {{#if this.inviteExpired}} + {{#if this.removedAll}} + + {{i18n "user.invited.removed_all"}} + {{else}} - {{i18n "user.invited.none"}} + {{/if}} -
+ {{/if}} + + {{#if this.invitePending}} + {{#if this.reinvitedAll}} + + + + {{else if this.hasEmailInvites}} + + {{/if}} + {{/if}} {{/if}}
- - {{else}} -
- {{this.model.error}} -
- {{/if}} - \ No newline at end of file +
+
+ {{#if this.model.invites}} + {{#if this.inviteRedeemed}} + + + + + + {{#if this.model.can_see_invite_details}} + + + + + + + {{/if}} + + + + {{#each this.model.invites as |invite|}} + + + + {{#if this.model.can_see_invite_details}} + + + + + + + {{/if}} + + {{/each}} + +
{{i18n "user.invited.user"}}{{i18n "user.invited.redeemed_at"}}{{i18n "user.last_seen"}}{{i18n "user.invited.topics_entered"}}{{i18n "user.invited.posts_read_count"}}{{i18n "user.invited.time_read"}}{{i18n "user.invited.days_visited"}}{{i18n "user.invited.invited_via"}}
+ {{avatar + invite.user + imageSize="tiny" + }} + {{invite.user.username}} + {{format-date invite.redeemed_at}}{{format-date invite.user.last_seen_at}}{{number invite.user.topics_entered}}{{number invite.user.posts_read_count}}{{format-duration invite.user.time_read}} + {{html-safe invite.user.days_visited}} + / + {{html-safe invite.user.days_since_created}} + {{html-safe invite.invite_source}}
+ {{else}} + + + + + + + + + + + {{#each this.model.invites as |invite|}} + + + + + + + + {{#if invite.can_delete_invite}} + + {{/if}} + + {{/each}} + +
{{i18n "user.invited.invited_via"}}{{i18n "user.invited.sent"}}{{i18n "user.invited.expires_at"}}
+
{{i18n "user.invited.invited_via"}}
+ {{#if invite.email}} + {{d-icon "envelope"}} + {{invite.email}} + {{else}} + {{d-icon "link"}} + {{i18n + "user.invited.invited_via_link" + key=invite.shortKey + count=invite.redemption_count + max=invite.max_redemptions_allowed + }} + {{/if}} + + {{#each invite.groups as |g|}} +

{{d-icon + "users" + }} + {{g.name}}

+ {{/each}} + + {{#if invite.topic}} +

{{d-icon "file"}} {{invite.topic.title}}

+ {{/if}} +
+
{{i18n "user.invited.sent"}}
+ {{format-date invite.updated_at}} +
+
{{i18n "user.invited.expires_at"}}
+ {{#if this.inviteExpired}} + {{raw-date invite.expires_at}} + {{else if invite.expired}} + {{i18n "user.invited.expired"}} + {{else}} + {{raw-date invite.expires_at}} + {{/if}} +
+ + +
+ {{/if}} + + + {{else}} +
+ {{#if this.canBulkInvite}} + {{html-safe (i18n "user.invited.bulk_invite.none")}} + {{else}} + {{i18n "user.invited.none"}} + {{/if}} +
+ {{/if}} +
+ +{{else}} +
+ {{this.model.error}} +
+{{/if}} \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/user-invited.hbs b/app/assets/javascripts/discourse/app/templates/user-invited.hbs index 33a32a68135..426bca100e6 100644 --- a/app/assets/javascripts/discourse/app/templates/user-invited.hbs +++ b/app/assets/javascripts/discourse/app/templates/user-invited.hbs @@ -1,5 +1,5 @@ {{#if this.can_see_invite_details}} - + {{body-class "user-invites-page"}}
diff --git a/app/assets/javascripts/discourse/app/templates/user.hbs b/app/assets/javascripts/discourse/app/templates/user.hbs index ab70bfe9f66..6b439b10a83 100644 --- a/app/assets/javascripts/discourse/app/templates/user.hbs +++ b/app/assets/javascripts/discourse/app/templates/user.hbs @@ -9,7 +9,7 @@ {{if this.model.profile_hidden 'profile-hidden'}} {{this.primaryGroup}}" > - +
@@ -474,5 +474,5 @@ {{outlet}}
- +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/user/activity.hbs b/app/assets/javascripts/discourse/app/templates/user/activity.hbs index 574930b5d8e..6993f2361a0 100644 --- a/app/assets/javascripts/discourse/app/templates/user/activity.hbs +++ b/app/assets/javascripts/discourse/app/templates/user/activity.hbs @@ -1,4 +1,4 @@ - +{{body-class "user-activity-page"}}
diff --git a/app/assets/javascripts/discourse/app/templates/user/badges.hbs b/app/assets/javascripts/discourse/app/templates/user/badges.hbs index b98331b7f53..4419f262f56 100644 --- a/app/assets/javascripts/discourse/app/templates/user/badges.hbs +++ b/app/assets/javascripts/discourse/app/templates/user/badges.hbs @@ -1,4 +1,6 @@ - +{{body-class "user-badges-page"}} + +

{{i18n "badges.favorite_count" @@ -25,4 +27,4 @@ @outletArgs={{hash user=this.user.model}} />

-
\ No newline at end of file + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/user/messages.hbs b/app/assets/javascripts/discourse/app/templates/user/messages.hbs index 3473acc7161..88cd66259ad 100644 --- a/app/assets/javascripts/discourse/app/templates/user/messages.hbs +++ b/app/assets/javascripts/discourse/app/templates/user/messages.hbs @@ -1,4 +1,4 @@ - +{{body-class "user-messages-page"}} +{{body-class "user-notifications-page"}}
diff --git a/app/assets/javascripts/discourse/app/templates/user/summary.hbs b/app/assets/javascripts/discourse/app/templates/user/summary.hbs index 15859e0cdb0..1897c732c0b 100644 --- a/app/assets/javascripts/discourse/app/templates/user/summary.hbs +++ b/app/assets/javascripts/discourse/app/templates/user/summary.hbs @@ -1,306 +1,300 @@ - -
- - {{#if this.model.can_see_summary_stats}} -
-

{{i18n "user.summary.stats"}}

-
    -
  • +{{body-class "user-summary-page"}} + +
    + + {{#if this.model.can_see_summary_stats}} +
    +

    {{i18n "user.summary.stats"}}

    +
      +
    • + +
    • +
    • + +
    • + {{#if this.showRecentTimeRead}} +
    • -
    • -
    • -
    • - {{#if this.showRecentTimeRead}} -
    • - -
    • - {{/if}} -
    • + {{/if}} +
    • + +
    • +
    • + +
    • +
    • + -
    • -
    • - -
    • -
    • - - - -
    • -
    • - + +
    • +
    • + +
    • + {{#if this.model.bookmark_count}} +
    • + + +
    • - {{#if this.model.bookmark_count}} -
    • - - - + {{/if}} +
    • + + + +
    • +
    • + + + +
    • + +
    +
    + {{/if}} + + + +
    + + + + + + + + + + + +
    + +
    + + {{#if this.model.links.length}} + + {{else}} +

    {{i18n "user.summary.no_links"}}

    + {{/if}} +
    + + + + + + +
    + +
    + + + + + + + + + + + +
    + + {{#if this.model.top_categories.length}} +
    + + + + + + + + + {{#each this.model.top_categories as |category|}} + + + + + + {{/each}} + +
    {{i18n "user.summary.topics"}}{{i18n "user.summary.replies"}}
    + + + +
    +
    +
    + {{/if}} + + {{#if this.siteSettings.enable_badges}} +
    +

    {{i18n "user.summary.top_badges"}}

    + + {{#if this.model.badges}} +
    + {{#each this.model.badges as |badge|}} + + {{/each}} -
-
- {{/if}} +
+ {{else}} +

{{i18n "user.summary.no_badges"}}

+ {{/if}} - - -
- - - - - - - - - - - + {{#if this.moreBadges}} + + {{i18n "user.summary.more_badges"}} + + {{/if}}
- -
- - {{#if this.model.links.length}} - - {{else}} -

{{i18n "user.summary.no_links"}}

- {{/if}} -
- - - - - - -
- -
- - - - - - - - - - - -
- - {{#if this.model.top_categories.length}} -
- - - - - - - - - {{#each this.model.top_categories as |category|}} - - - - - - {{/each}} - -
{{i18n "user.summary.topics"}}{{i18n "user.summary.replies"}}
- - - -
-
-
- {{/if}} - - {{#if this.siteSettings.enable_badges}} -
-

{{i18n "user.summary.top_badges"}}

- - {{#if this.model.badges}} -
- {{#each this.model.badges as |badge|}} - - {{/each}} - -
- {{else}} -

{{i18n "user.summary.no_badges"}}

- {{/if}} - - {{#if this.moreBadges}} - - {{i18n "user.summary.more_badges"}} - - {{/if}} -
- {{/if}} -
-
\ No newline at end of file + {{/if}} +
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/templates/users.hbs b/app/assets/javascripts/discourse/app/templates/users.hbs index cfb476c4ccc..9f183247b90 100644 --- a/app/assets/javascripts/discourse/app/templates/users.hbs +++ b/app/assets/javascripts/discourse/app/templates/users.hbs @@ -2,7 +2,8 @@ {{hide-application-footer}} {{/if}} - +{{body-class "users-page"}} +
-
\ No newline at end of file + \ No newline at end of file diff --git a/app/assets/javascripts/discourse/config/deprecation-workflow.js b/app/assets/javascripts/discourse/config/deprecation-workflow.js index 6beb637f2b4..853946bd7e2 100644 --- a/app/assets/javascripts/discourse/config/deprecation-workflow.js +++ b/app/assets/javascripts/discourse/config/deprecation-workflow.js @@ -10,5 +10,6 @@ globalThis.deprecationWorkflow.config = { matchId: "ember-this-fallback.this-property-fallback", }, { handler: "silence", matchId: "discourse.select-kit" }, + { handler: "silence", matchId: "discourse.d-section" }, ], }; diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-parent-view-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-parent-view-test.js index 053db157d01..47d08d61ba0 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-parent-view-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-parent-view-test.js @@ -1,28 +1,35 @@ -import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; +import { module, test } from "qunit"; +import { setupRenderingTest } from "ember-qunit"; import { hbs } from "ember-cli-htmlbars"; -import { test } from "qunit"; -import { visit } from "@ember/test-helpers"; +import { render } from "@ember/test-helpers"; import { withSilencedDeprecationsAsync } from "discourse-common/lib/deprecated"; +import Component from "@ember/component"; import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper"; -acceptance("Plugin Outlet - Deprecated parentView", function (needs) { - needs.hooks.beforeEach(function () { - registerTemporaryModule( - "discourse/templates/connectors/user-profile-primary/hello", - hbs`{{this.parentView.parentView.class}}` - ); - }); +module("Plugin Outlet - Deprecated parentView", function (hooks) { + setupRenderingTest(hooks); + + test("Can access parentView", async function (assert) { + this.component = class AComponent extends Component { + layout = hbs``; + }; + + registerTemporaryModule( + "discourse/templates/connectors/an-outlet/hello", + hbs`{{this.parentView.parentView.constructor.name}}` + ); - test("Can access parentview", async function (assert) { await withSilencedDeprecationsAsync( "discourse.plugin-outlet-parent-view", async () => { - await visit("/u/eviltrout"); - assert.strictEqual( - query(".hello-username").innerText, - "user-main", - "it renders a value from parentView.parentView" - ); + await render(hbs``); + + assert + .dom(".hello-username") + .hasText( + "AComponent", + "it renders a value from parentView.parentView" + ); } ); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-section-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/d-section-test.gjs new file mode 100644 index 00000000000..9b377acee27 --- /dev/null +++ b/app/assets/javascripts/discourse/tests/integration/components/d-section-test.gjs @@ -0,0 +1,19 @@ +import { module, test } from "qunit"; +import { setupRenderingTest } from "discourse/tests/helpers/component-test"; +import { render } from "@ember/test-helpers"; +import DSection from "discourse/components/d-section"; + +module("Integration | Component | d-section", function (hooks) { + setupRenderingTest(hooks); + + test("can set classes on the body element", async function (assert) { + await render(); + + assert.dom(".special").hasText("testing!"); + assert.strictEqual(document.body.className, "test-page foo bar"); + }); +}); diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/body-class-test.js b/app/assets/javascripts/discourse/tests/integration/helpers/body-class-test.js new file mode 100644 index 00000000000..684ef5d7190 --- /dev/null +++ b/app/assets/javascripts/discourse/tests/integration/helpers/body-class-test.js @@ -0,0 +1,42 @@ +import { module, test } from "qunit"; +import { setupRenderingTest } from "discourse/tests/helpers/component-test"; +import { render, settled } from "@ember/test-helpers"; +import { hbs } from "ember-cli-htmlbars"; + +module("Integration | Helper | body-class", function (hooks) { + setupRenderingTest(hooks); + + test("A single class", async function (assert) { + await render(hbs`{{body-class "foo"}}`); + + assert.true(document.body.classList.contains("foo")); + }); + + test("Multiple classes", async function (assert) { + this.set("bar", "bar"); + await render(hbs`{{body-class "baz" this.bar}}`); + + assert.true(document.body.classList.contains("baz")); + assert.true(document.body.classList.contains("bar")); + }); + + test("Empty classes", async function (assert) { + const classesBefore = document.body.className; + await render(hbs`{{body-class (if false "not-really")}}`); + assert.strictEqual(document.body.className, classesBefore); + }); + + test("Dynamic classes", async function (assert) { + this.set("dynamic", "bar"); + await render(hbs`{{body-class this.dynamic}}`); + assert.true(document.body.classList.contains("bar"), "has .bar"); + + this.set("dynamic", "baz"); + await settled(); + assert.true(document.body.classList.contains("baz"), "has .baz"); + assert.false( + document.body.classList.contains("bar"), + "does not have .bar anymore" + ); + }); +}); diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.hbs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.hbs index 438cc58f341..e1a3ba23cd0 100644 --- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.hbs +++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/navigation-stacked.hbs @@ -14,7 +14,7 @@ - +
{{/each}} - +
\ No newline at end of file diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.hbs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.hbs index 25e9b740b20..66c9fa16fdb 100644 --- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.hbs +++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/navigation.hbs @@ -1,7 +1,7 @@
- +
- +
\ No newline at end of file diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/user-about.hbs b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/user-about.hbs index a182b1d6ffd..9ef837fe9b5 100644 --- a/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/user-about.hbs +++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/organisms/user-about.hbs @@ -1,5 +1,5 @@ - +
@@ -41,11 +41,11 @@
- +
- +
- +
- +
@@ -244,11 +244,11 @@
- +
- +
- +
\ No newline at end of file