A platform for community discussion. Free, open, simple.
DEV: Convert 11 components to glimmer (#44614)
Jarek Radosz7e80a8e9d4b4
diff --git a/frontend/discourse/app/components/bread-crumbs.gjs b/frontend/discourse/app/components/bread-crumbs.gjsindex 466bbfc9c43..a8ec83a4039 100644--- a/frontend/discourse/app/components/bread-crumbs.gjs+++ b/frontend/discourse/app/components/bread-crumbs.gjs@@ -1,8 +1,7 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";+import Component from "@glimmer/component";+import { cached } from "@glimmer/tracking";import { hash } from "@ember/helper";-import { computed } from "@ember/object";-import { tagName } from "@ember-decorators/component";+import { service } from "@ember/service";import PluginOutlet from "discourse/components/plugin-outlet";import categoryVariables from "discourse/helpers/category-variables";import lazyHash from "discourse/helpers/lazy-hash";@@ -12,14 +11,17 @@ import TagsIntersectionChooser from "discourse/select-kit/components/tags-intersimport dConcatClass from "discourse/ui-kit/helpers/d-concat-class";import deprecatedOutletArgument from "../helpers/deprecated-outlet-argument.js";-@tagName("")export default class BreadCrumbs extends Component {- editingCategory = false;- editingCategoryTab = null;+ @service site;+ @service siteSettings;- @computed("category", "categories", "noSubcategories")+ get editingCategory() {+ return this.args.editingCategory ?? false;+ }++ @cachedget categoryBreadcrumbs() {- const ancestors = this.category?.ancestors || [];+ const ancestors = this.args.category?.ancestors || [];const parentCategories = [undefined, ...ancestors];const categories = [...ancestors, undefined];@@ -28,7 +30,7 @@ export default class BreadCrumbs extends Component {.map((record) => {const [parentCategory, subCategory] = record;- const options = this.categories.filter(+ const options = this.args.categories.filter((c) =>c.get("parentCategory.id") === (parentCategory && parentCategory.id));@@ -38,20 +40,18 @@ export default class BreadCrumbs extends Component {parentCategory,options,isSubcategory: !!parentCategory,- noSubcategories: !subCategory && this.noSubcategories,+ noSubcategories: !subCategory && this.args.noSubcategories,hasOptions: !parentCategory || parentCategory.has_children,};});}- @computed("siteSettings.tagging_enabled", "editingCategory")get showTagsSection() {- return this.siteSettings?.tagging_enabled && !this.editingCategory;+ return this.siteSettings.tagging_enabled && !this.editingCategory;}- @computed("category")get hidden() {- return this.site.mobileView && !this.category;+ return this.site.mobileView && !this.args.category;}<template>@@ -63,7 +63,7 @@ export default class BreadCrumbs extends Component {@connectorTagName="li"@deprecatedArgs={{lazyHashtagId=(deprecatedOutletArgument- value=this.tag.namemessage="The argument 'tagId' is deprecated on the outlet 'bread-crumbs-left', use 'tag.name' instead"id="discourse.plugin-connector.deprecated-arg.bread-crumbs-left"since="2025.12.0-latest"@@ -72,14 +72,14 @@ export default class BreadCrumbs extends Component {}}@name="bread-crumbs-left"@outletArgs={{lazyHash- tag=this.tag- additionalTags=this.additionalTags- noSubcategories=this.noSubcategories+ tag=@tag+ additionalTags=@additionalTags+ noSubcategories=@noSubcategoriesshowTagsSection=this.showTagsSection- currentCategory=this.category+ currentCategory=@categorycategoryBreadcrumbs=this.categoryBreadcrumbseditingCategory=this.editingCategory- editingCategoryTab=this.editingCategoryTab+ editingCategoryTab=@editingCategoryTab}}/>@@ -100,34 +100,34 @@ export default class BreadCrumbs extends Component {@categories={{breadcrumb.options}}@category={{breadcrumb.category}}@editingCategory={{this.editingCategory}}- @editingCategoryTab={{this.editingCategoryTab}}+ @editingCategoryTab={{@editingCategoryTab}}@options={{hashparentCategory=breadcrumb.parentCategorysubCategory=breadcrumb.isSubcategorynoSubcategories=breadcrumb.noSubcategories}}- @tag={{this.tag}}+ @tag={{@tag}}/></li>{{/if}}{{/each}}{{#if this.showTagsSection}}- {{#if this.additionalTags}}+ {{#if @additionalTags}}<li><TagsIntersectionChooser- @additionalTags={{this.additionalTags}}- @currentCategory={{this.category}}- @mainTag={{this.tag}}- @options={{hash categoryId=this.category.id}}+ @additionalTags={{@additionalTags}}+ @currentCategory={{@category}}+ @mainTag={{@tag}}+ @options={{hash [email protected]}}/></li>{{else}}<li><TagDrop- @currentCategory={{this.category}}- @noSubcategories={{this.noSubcategories}}- @tag={{this.tag}}+ @currentCategory={{@category}}+ @noSubcategories={{@noSubcategories}}+ @tag={{@tag}}/></li>{{/if}}@@ -137,7 +137,7 @@ export default class BreadCrumbs extends Component {@connectorTagName="li"@deprecatedArgs={{lazyHashtagId=(deprecatedOutletArgument- value=this.tag.namemessage="The argument 'tagId' is deprecated on the outlet 'bread-crumbs-right', use 'tag.name' instead"id="discourse.plugin-connector.deprecated-arg.bread-crumbs-right"since="2025.12.0-latest"@@ -146,14 +146,14 @@ export default class BreadCrumbs extends Component {}}@name="bread-crumbs-right"@outletArgs={{lazyHash- tag=this.tag- additionalTags=this.additionalTags- noSubcategories=this.noSubcategories+ tag=@tag+ additionalTags=@additionalTags+ noSubcategories=@noSubcategoriesshowTagsSection=this.showTagsSection- currentCategory=this.category+ currentCategory=@categorycategoryBreadcrumbs=this.categoryBreadcrumbseditingCategory=this.editingCategory- editingCategoryTab=this.editingCategoryTab+ editingCategoryTab=@editingCategoryTab}}/></ol>diff --git a/frontend/discourse/app/ui-kit/d-conditional-loading-section.gjs b/frontend/discourse/app/ui-kit/d-conditional-loading-section.gjsindex a282cae219a..c7f8a576db2 100644--- a/frontend/discourse/app/ui-kit/d-conditional-loading-section.gjs+++ b/frontend/discourse/app/ui-kit/d-conditional-loading-section.gjs@@ -1,28 +1,25 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { tagName } from "@ember-decorators/component";+import { or } from "discourse/truth-helpers";import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";import { i18n } from "discourse-i18n";-@tagName("")-export default class DConditionalLoadingSection extends Component {- isLoading = false;- title = i18n("conditional_loading_section.loading");+const DConditionalLoadingSection = <template>+ <div+ class={{dConcatClass+ "conditional-loading-section"+ (if @isLoading "is-loading")+ }}+ ...attributes+ >+ {{#if @isLoading}}+ <span class="title">{{or+ @title+ (i18n "conditional_loading_section.loading")+ }}</span>+ <div class="spinner {{@size}}"></div>+ {{else}}+ {{yield}}+ {{/if}}+ </div>+</template>;- <template>- <div- class={{dConcatClass- "conditional-loading-section"- (if this.isLoading "is-loading")- }}- ...attributes- >- {{#if this.isLoading}}- <span class="title">{{this.title}}</span>- <div class="spinner {{this.size}}"></div>- {{else}}- {{yield}}- {{/if}}- </div>- </template>-}+export default DConditionalLoadingSection;diff --git a/frontend/discourse/app/ui-kit/d-date-time-input.gjs b/frontend/discourse/app/ui-kit/d-date-time-input.gjsindex 95e7412a05a..48df39f9301 100644--- a/frontend/discourse/app/ui-kit/d-date-time-input.gjs+++ b/frontend/discourse/app/ui-kit/d-date-time-input.gjs@@ -1,48 +1,54 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { action, computed } from "@ember/object";-import { tagName } from "@ember-decorators/component";+import Component from "@glimmer/component";+import { action } from "@ember/object";import DButton from "discourse/ui-kit/d-button";import DDateInput from "discourse/ui-kit/d-date-input";import DTimeInput from "discourse/ui-kit/d-time-input";-@tagName("")export default class DDateTimeInput extends Component {- date = null;- relativeDate = null;- showTime = true;- clearable = false;+ // Subclasses read the inputs by name (`this.date`), so they stay getters.+ get date() {+ return this.args.date;+ }++ get relativeDate() {+ return this.args.relativeDate;+ }++ get showTime() {+ return this.args.showTime ?? true;+ }++ get clearable() {+ return this.args.clearable ?? false;+ }- @computed("date", "showTime")get hours() {- return this.date && this.get("showTime") ? this.date.hours() : null;+ return this.date && this.showTime ? this.date.hours() : null;}- @computed("date", "showTime")get minutes() {- return this.date && this.get("showTime") ? this.date.minutes() : null;+ return this.date && this.showTime ? this.date.minutes() : null;}- @computed("timezone")get resolvedTimezone() {- return this.timezone || moment.tz.guess();+ return this.args.timezone || moment.tz.guess();}@actiononClear() {- this.onChange(null);+ this.args.onChange(null);}@actiononChangeTime(time) {- if (this.onChange) {+ if (this.args.onChange) {const date = this.date? this.date: this.relativeDate? this.relativeDate: moment.tz(this.resolvedTimezone);- this.onChange(+ this.args.onChange(moment.tz({year: date.year(),@@ -64,7 +70,7 @@ export default class DDateTimeInput extends Component {return;}- this.onChange?.(+ this.args.onChange?.(moment.tz({year: date.year(),@@ -80,13 +86,13 @@ export default class DDateTimeInput extends Component {<template><div class="d-date-time-input" ...attributes>- {{#unless this.timeFirst}}+ {{#unless @timeFirst}}<DDateInput@date={{this.date}}@onChange={{this.onChangeDate}}- @placeholder={{this.placeholder}}+ @placeholder={{@placeholder}}@relativeDate={{this.relativeDate}}- @useGlobalPickerContainer={{this.useGlobalPickerContainer}}+ @useGlobalPickerContainer={{@useGlobalPickerContainer}}/>{{/unless}}@@ -98,13 +104,13 @@ export default class DDateTimeInput extends Component {/>{{/if}}- {{#if this.timeFirst}}+ {{#if @timeFirst}}<DDateInput@date={{this.date}}@onChange={{this.onChangeDate}}- @placeholder={{this.placeholder}}+ @placeholder={{@placeholder}}@relativeDate={{this.relativeDate}}- @useGlobalPickerContainer={{this.useGlobalPickerContainer}}+ @useGlobalPickerContainer={{@useGlobalPickerContainer}}/>{{/if}}diff --git a/frontend/discourse/app/ui-kit/d-tap-tile.gjs b/frontend/discourse/app/ui-kit/d-tap-tile.gjsindex 78f8571fe4f..39cf600323d 100644--- a/frontend/discourse/app/ui-kit/d-tap-tile.gjs+++ b/frontend/discourse/app/ui-kit/d-tap-tile.gjs@@ -1,61 +1,43 @@-/* eslint-disable ember/no-classic-components, ember/require-tagless-components */-import { tracked } from "@glimmer/tracking";-import Component from "@ember/component";-import { computed } from "@ember/object";-import {- attributeBindings,- classNameBindings,- classNames,-} from "@ember-decorators/component";+import Component from "@glimmer/component";+import { on } from "@ember/modifier";+import { action } from "@ember/object";import { deepEqual } from "discourse/lib/object";+import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";import dIcon from "discourse/ui-kit/helpers/d-icon";-@classNames("tap-tile")-@classNameBindings("active")-@attributeBindings("role", "ariaPressed", "tabIndex")export default class DTapTile extends Component {- role = "button";- tabIndex = 0;-- @tracked _ariaPressedOverride;-- init() {- super.init(...arguments);- this.set("elementId", `tap_tile_${this.tileId}`);- }-- @computed("active")- get ariaPressed() {- if (this._ariaPressedOverride !== undefined) {- return this._ariaPressedOverride;- }- return this.active;- }-- set ariaPressed(value) {- this._ariaPressedOverride = value;- }-- @computed("activeTile", "tileId")get active() {- return deepEqual(this.activeTile, this.tileId);+ return deepEqual(this.args.activeTile, this.args.tileId);}+ @actionclick() {- this.onChange(this.tileId);+ this.args.onChange(this.args.tileId);}+ @actionkeyDown(e) {if (e.key === "Enter") {e.stopPropagation();- this.onChange(this.tileId);+ this.args.onChange(this.args.tileId);}}<template>- {{#if this.icon}}- {{dIcon this.icon}}- {{/if}}- {{yield}}+ <div+ role="button"+ tabindex="0"+ ...attributes+ aria-pressed={{if this.active "true" "false"}}+ class={{dConcatClass "tap-tile" (if this.active "active")}}+ id="tap_tile_{{@tileId}}"+ {{on "click" this.click}}+ {{on "keydown" this.keyDown}}+ >+ {{#if @icon}}+ {{dIcon @icon}}+ {{/if}}+ {{yield}}+ </div></template>}diff --git a/frontend/discourse/tests/integration/ui-kit/d-conditional-loading-section-test.gjs b/frontend/discourse/tests/integration/ui-kit/d-conditional-loading-section-test.gjsnew file mode 100644index 00000000000..57e7d282660--- /dev/null+++ b/frontend/discourse/tests/integration/ui-kit/d-conditional-loading-section-test.gjs@@ -0,0 +1,48 @@+import { render } from "@ember/test-helpers";+import { module, test } from "qunit";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";+import DConditionalLoadingSection from "discourse/ui-kit/d-conditional-loading-section";+import { i18n } from "discourse-i18n";++module("Integration | ui-kit | DConditionalLoadingSection", function (hooks) {+ setupRenderingTest(hooks);++ test("shows a default title while loading", async function (assert) {+ await render(+ <template>+ <DConditionalLoadingSection @isLoading={{true}}>+ <p class="content">content</p>+ </DConditionalLoadingSection>+ </template>+ );++ assert+ .dom(".conditional-loading-section")+ .hasClass("is-loading", "marks the section as loading");+ assert.dom(".title").hasText(i18n("conditional_loading_section.loading"));+ assert.dom(".content").doesNotExist("hides the content");+ });++ test("shows a given title while loading", async function (assert) {+ await render(+ <template>+ <DConditionalLoadingSection @isLoading={{true}} @title="Saving" />+ </template>+ );++ assert.dom(".title").hasText("Saving");+ });++ test("renders the content once loaded", async function (assert) {+ await render(+ <template>+ <DConditionalLoadingSection @isLoading={{false}}>+ <p class="content">content</p>+ </DConditionalLoadingSection>+ </template>+ );++ assert.dom(".content").exists();+ assert.dom(".title").doesNotExist();+ });+});diff --git a/frontend/discourse/tests/integration/ui-kit/d-date-time-input-test.gjs b/frontend/discourse/tests/integration/ui-kit/d-date-time-input-test.gjsindex 9fbb3c2969d..1b43a4ceabc 100644--- a/frontend/discourse/tests/integration/ui-kit/d-date-time-input-test.gjs+++ b/frontend/discourse/tests/integration/ui-kit/d-date-time-input-test.gjs@@ -85,4 +85,19 @@ module("Integration | ui-kit | DDateTimeInput", function (hooks) {await triggerEvent(".date-picker", "change");assert.strictEqual(this.date.format(), "2023-05-05T12:00:00+10:00");});++ test("exposes its inputs to subclasses by name", async function (assert) {+ class Subclass extends DDateTimeInput {+ <template>+ <span class="probe">{{if this.date "dated"}}+ {{this.showTime}}+ {{this.clearable}}</span>+ </template>+ }+ this.setProperties({ date: DEFAULT_DATE_TIME });++ await render(<template><Subclass @date={{this.date}} /></template>);++ assert.dom(".probe").hasText("dated true false");+ });});diff --git a/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-list-setting.gjs b/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-list-setting.gjsindex fbc872a317b..62af4393057 100644--- a/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-list-setting.gjs+++ b/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-list-setting.gjs@@ -1,26 +1,22 @@-import { action, computed } from "@ember/object";-import { tagName } from "@ember-decorators/component";+import { action } from "@ember/object";import { makeArray } from "discourse/lib/helpers";import DButton from "discourse/ui-kit/d-button";import HouseAdsChooser from "./house-ads-chooser.js";import HouseAdsSetting from "./house-ads-setting.gjs";-@tagName("")export default class HouseAdsListSetting extends HouseAdsSetting {- @computed("[email protected]")get adNames() {- return this.allAds?.map?.((item) => item.name) ?? [];+ return this.args.allAds?.map?.((item) => item.name) ?? [];}@actionchangeAdValue(value) {- const settingValue = makeArray(value).join("|");- this.set("adValue", settingValue);+ this.adValue = makeArray(value).join("|");}<template><div class="house-ads-setting house-ads-list-setting" ...attributes>- <label for={{this.name}}>{{this.title}}</label>+ <label for={{@name}}>{{this.title}}</label><HouseAdsChooser@choices={{this.adNames}}@onChange={{this.changeAdValue}}diff --git a/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-setting.gjs b/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-setting.gjsindex 06d78f258b7..3d3e94fde29 100644--- a/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-setting.gjs+++ b/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-setting.gjs@@ -1,83 +1,62 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { action, computed } from "@ember/object";-import { tagName } from "@ember-decorators/component";+import Component from "@glimmer/component";+import { action } from "@ember/object";import { ajax } from "discourse/lib/ajax";import { popupAjaxError } from "discourse/lib/ajax-error";import { deepEqual } from "discourse/lib/object";+import { resettableTracked } from "discourse/lib/tracked-tools";import DButton from "discourse/ui-kit/d-button";import DTextField from "discourse/ui-kit/d-text-field";import { i18n } from "discourse-i18n";-@tagName("")export default class HouseAdsSetting extends Component {- adValue = "";- saving = false;- savingStatus = "";+ @resettableTracked adValue = this.args.value;- init() {- super.init(...arguments);- this.set("adValue", this.get("value"));- }+ saving = false;- @computed("name")get title() {- return i18n(`admin.adplugin.house_ads.${this.name}.title`);+ return i18n(`admin.adplugin.house_ads.${this.args.name}.title`);}- @computed("name")get help() {- return i18n(`admin.adplugin.house_ads.${this.name}.description`);+ return i18n(`admin.adplugin.house_ads.${this.args.name}.description`);}- @computed("adValue", "value")get changed() {- return !deepEqual(this.adValue, this.value);+ return !deepEqual(this.adValue, this.args.value);}@actionasync save() {- if (this.get("saving")) {+ if (this.saving) {return;}- this.setProperties({- saving: true,- savingStatus: i18n("saving"),- });+ this.saving = true;try {await ajax(- `/admin/plugins/discourse-adplugin/house-settings/${this.get("name")}`,+ `/admin/plugins/discourse-adplugin/house-settings/${this.args.name}`,{type: "PUT",- data: { value: this.get("adValue") },+ data: { value: this.adValue },});- const adSettings = this.get("adSettings");- adSettings.set(this.get("name"), this.get("adValue"));- this.setProperties({- value: this.get("adValue"),- savingStatus: i18n("saved"),- });+ this.args.adSettings.set(this.args.name, this.adValue);} catch (e) {popupAjaxError(e);} finally {- this.setProperties({- saving: false,- savingStatus: "",- });+ this.saving = false;}}@actioncancel() {- this.set("adValue", this.get("value"));+ this.adValue = this.args.value;}<template><div class="house-ads-setting" ...attributes>- <label for={{this.name}}>{{this.title}}</label>+ <label for={{@name}}>{{this.title}}</label><DTextField @classNames="house-ads-text-input" @value={{this.adValue}} /><div class="setting-controls">{{#if this.changed}}diff --git a/plugins/discourse-adplugin/test/javascripts/integration/components/house-ads-list-setting-test.gjs b/plugins/discourse-adplugin/test/javascripts/integration/components/house-ads-list-setting-test.gjsnew file mode 100644index 00000000000..432abae5ce3--- /dev/null+++ b/plugins/discourse-adplugin/test/javascripts/integration/components/house-ads-list-setting-test.gjs@@ -0,0 +1,53 @@+import EmberObject from "@ember/object";+import { click, render } from "@ember/test-helpers";+import { module, test } from "qunit";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";+import pretender, { response } from "discourse/tests/helpers/create-pretender";+import selectKit from "discourse/tests/helpers/select-kit-helper";+import HouseAdsListSetting from "discourse/plugins/discourse-adplugin/admin/components/house-ads-list-setting";++module("Integration | Component | HouseAdsListSetting", function (hooks) {+ setupRenderingTest(hooks);++ test("saves the picked ads to the setting", async function (assert) {+ let saved;+ pretender.put(+ "/admin/plugins/discourse-adplugin/house-settings/topic_list_top",+ (request) => {+ saved = new URLSearchParams(request.requestBody).get("value");+ return response({});+ }+ );+ const adSettings = EmberObject.create({ topic_list_top: "first" });+ const allAds = [{ name: "first" }, { name: "second" }];++ await render(+ <template>+ <HouseAdsListSetting+ @adSettings={{adSettings}}+ @allAds={{allAds}}+ @name="topic_list_top"+ @value={{adSettings.topic_list_top}}+ />+ </template>+ );++ assert.dom(".setting-controls .ok").doesNotExist("starts unchanged");++ const chooser = selectKit(".house-ads-chooser");+ await chooser.expand();+ await chooser.selectRowByValue("second");++ assert.dom(".setting-controls .ok").exists("offers to save the change");++ await click(".setting-controls .ok");++ assert.strictEqual(saved, "first|second", "sends the new value");+ assert.strictEqual(+ adSettings.topic_list_top,+ "first|second",+ "updates the settings model"+ );+ assert.dom(".setting-controls .ok").doesNotExist("is unchanged again");+ });+});diff --git a/plugins/discourse-cakeday/assets/javascripts/discourse/connectors/user-card-post-names/user-card-cakeday.gjs b/plugins/discourse-cakeday/assets/javascripts/discourse/connectors/user-card-post-names/user-card-cakeday.gjsindex dd90e8c6c76..8c0c456b8f1 100644--- a/plugins/discourse-cakeday/assets/javascripts/discourse/connectors/user-card-post-names/user-card-cakeday.gjs+++ b/plugins/discourse-cakeday/assets/javascripts/discourse/connectors/user-card-post-names/user-card-cakeday.gjs@@ -1,6 +1,5 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { tagName } from "@ember-decorators/component";+import Component from "@glimmer/component";+import { service } from "@ember/service";import {birthday,birthdayTitle,@@ -9,15 +8,24 @@ import {} from "discourse/plugins/discourse-cakeday/discourse/lib/cakeday";import EmojiImages from "../../components/emoji-images.gjs";-@tagName("")export default class UserCardCakeday extends Component {- init() {- super.init(...arguments);- const { user } = this;- this.set("isCakeday", cakeday(user.cakedate));- this.set("isBirthday", birthday(user.birthdate));- this.set("cakedayTitle", cakedayTitle(user, this.currentUser));- this.set("birthdayTitle", birthdayTitle(user, this.currentUser));+ @service currentUser;+ @service siteSettings;++ get isCakeday() {+ return cakeday(this.args.user.cakedate);+ }++ get isBirthday() {+ return birthday(this.args.user.birthdate);+ }++ get cakedayTitle() {+ return cakedayTitle(this.args.user, this.currentUser);+ }++ get birthdayTitle() {+ return birthdayTitle(this.args.user, this.currentUser);}<template>diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/connectors/group-reports-nav-item/nav-item.gjs b/plugins/discourse-data-explorer/assets/javascripts/discourse/connectors/group-reports-nav-item/nav-item.gjsindex c761759dcfa..d0df045c4af 100644--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/connectors/group-reports-nav-item/nav-item.gjs+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/connectors/group-reports-nav-item/nav-item.gjs@@ -1,11 +1,8 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";+import Component from "@glimmer/component";import { LinkTo } from "@ember/routing";-import { tagName } from "@ember-decorators/component";import dIcon from "discourse/ui-kit/helpers/d-icon";import { i18n } from "discourse-i18n";-@tagName("")export default class NavItem extends Component {static shouldRender(args) {return args.group.has_visible_data_explorer_queries;diff --git a/plugins/discourse-patreon/assets/javascripts/discourse/connectors/admin-user-details/patreon.gjs b/plugins/discourse-patreon/assets/javascripts/discourse/connectors/admin-user-details/patreon.gjsindex 619030f3087..736f28f3775 100644--- a/plugins/discourse-patreon/assets/javascripts/discourse/connectors/admin-user-details/patreon.gjs+++ b/plugins/discourse-patreon/assets/javascripts/discourse/connectors/admin-user-details/patreon.gjs@@ -1,29 +1,25 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";import { action } from "@ember/object";-import { trustHTML } from "@ember/template";-import { tagName } from "@ember-decorators/component";import { ajax } from "discourse/lib/ajax";import { userPath } from "discourse/lib/url";import DButton from "discourse/ui-kit/d-button";+import dFormatDate from "discourse/ui-kit/helpers/d-format-date";import dIcon from "discourse/ui-kit/helpers/d-icon";import { i18n } from "discourse-i18n";-@tagName("")export default class Patreon extends Component {static shouldRender(args, context) {return context.siteSettings.patreon_enabled && args.model.patreon_id;}- init() {- super.init(...arguments);- this.set("patron_url", "https://patreon.com/members");- }+ @tracked patreon_email;+ @tracked patron_url = "https://patreon.com/members";@actionasync checkPatreonEmail() {const result = await ajax(- userPath(`${this.model.username_lower}/patreon_email.json`),+ userPath(`${this.args.model.username_lower}/patreon_email.json`),{data: {context: window.location.pathname,@@ -39,8 +35,8 @@ export default class Patreon extends Component {url = `${url}?query=${email}`;}- this.set("patreon_email", email);- this.set("patron_url", url);+ this.patreon_email = email;+ this.patron_url = url;}}@@ -50,9 +46,9 @@ export default class Patreon extends Component {<h1>{{i18n "patreon.title"}}</h1><div class="display-row"><div class="field">{{i18n "patreon.field.id"}}</div>- <div class="value">{{this.model.patreon_id}}</div>+ <div class="value">{{@model.patreon_id}}</div></div>- {{#if this.model.patreon_email_exists}}+ {{#if @model.patreon_email_exists}}<div class="display-row"><div class="field">{{i18n "patreon.field.email"}}</div><div class="value">@@ -70,24 +66,23 @@ export default class Patreon extends Component {</div></div>{{/if}}- {{#if this.model.patreon_amount_cents}}+ {{#if @model.patreon_amount_cents}}<div class="display-row"><div class="field">{{i18n "patreon.field.amount_cents"}}</div>- <div class="value">{{this.model.patreon_amount_cents}}</div>+ <div class="value">{{@model.patreon_amount_cents}}</div></div>{{/if}}- {{#if this.model.patreon_rewards}}+ {{#if @model.patreon_rewards}}<div class="display-row"><div class="field">{{i18n "patreon.field.rewards"}}</div>- <div class="value">{{this.model.patreon_rewards}}</div>+ <div class="value">{{@model.patreon_rewards}}</div></div>{{/if}}- {{#if this.model.patreon_declined_since}}+ {{#if @model.patreon_declined_since}}<div class="display-row"><div class="field">{{i18n "patreon.field.declined_since"}}</div>- <div class="value">{{trustHTML- this.format-date- this.model.patreon_declined_since+ <div class="value">{{dFormatDate+ @model.patreon_declined_since}}</div></div>{{/if}}@@ -103,7 +98,7 @@ export default class Patreon extends Component {</a></div><div class="controls">- {{#if this.model.patreon_email}}+ {{#if @model.patreon_email}}{{i18n "patreon.field.more_details.help_text.email_available"}}{{else}}{{i18ndiff --git a/plugins/discourse-patreon/test/javascripts/integration/components/patreon-admin-user-details-test.gjs b/plugins/discourse-patreon/test/javascripts/integration/components/patreon-admin-user-details-test.gjsnew file mode 100644index 00000000000..b991b32e4ad--- /dev/null+++ b/plugins/discourse-patreon/test/javascripts/integration/components/patreon-admin-user-details-test.gjs@@ -0,0 +1,42 @@+import { click, render } from "@ember/test-helpers";+import { module, test } from "qunit";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";+import pretender, { response } from "discourse/tests/helpers/create-pretender";+import Patreon from "discourse/plugins/discourse-patreon/discourse/connectors/admin-user-details/patreon";++module(+ "Integration | Component | Patreon admin user details",+ function (hooks) {+ setupRenderingTest(hooks);++ test("shows the decline date and looks up the email", async function (assert) {+ pretender.get("/u/patron/patreon_email.json", () =>+ response({ email: "[email protected]" })+ );+ const model = {+ username_lower: "patron",+ patreon_id: "123",+ patreon_email_exists: true,+ patreon_declined_since: "2026-01-02T10:00:00Z",+ };++ await render(<template><Patreon @model={{model}} /></template>);++ assert+ .dom(".patreon .display-row:nth-child(4) .value")+ .hasAnyText("shows when the pledge was declined");++ await click(".patreon .btn-default");++ assert+ .dom(".patreon")+ .includesText("[email protected]", "shows the looked-up email");+ assert+ .dom(".patreon a[target='_blank']")+ .hasAttribute(+ "href",+ "https://patreon.com/[email protected]"+ );+ });+ }+);diff --git a/plugins/poll/assets/javascripts/discourse/components/modal/poll-breakdown.gjs b/plugins/poll/assets/javascripts/discourse/components/modal/poll-breakdown.gjsindex 9df89f0475a..bb9ebf503e7 100644--- a/plugins/poll/assets/javascripts/discourse/components/modal/poll-breakdown.gjs+++ b/plugins/poll/assets/javascripts/discourse/components/modal/poll-breakdown.gjs@@ -1,12 +1,11 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";import { fn, get } from "@ember/helper";import { on } from "@ember/modifier";-import { action, computed } from "@ember/object";+import { action } from "@ember/object";import { service } from "@ember/service";import { classify } from "@ember/string";import { trustHTML } from "@ember/template";-import { tagName } from "@ember-decorators/component";import { ajax } from "discourse/lib/ajax";import { popupAjaxError } from "discourse/lib/ajax-error";import ComboBox from "discourse/select-kit/components/combo-box";@@ -17,30 +16,25 @@ import { i18n } from "discourse-i18n";import PollBreakdownChart from "discourse/plugins/poll/discourse/components/poll-breakdown-chart";import PollBreakdownOption from "discourse/plugins/poll/discourse/components/poll-breakdown-option";-@tagName("")export default class PollBreakdownModal extends Component {@service dialog;@service siteSettings;- model = null;- charts = null;- groupedBy = null;- highlightedOption = null;- displayMode = "percentage";-- init() {- this.set("groupedBy", this.groupableUserFields[0]?.id);+ @tracked charts = null;+ @tracked groupedBy = null;+ @tracked highlightedOption = null;+ @tracked displayMode = "percentage";+ constructor() {+ super(...arguments);+ this.groupedBy = this.groupableUserFields[0]?.id;this.fetchGroupedPollData();-- super.init(...arguments);}- @computed("model.poll.title", "model.post.topic.title")get title() {- return this.model?.poll?.title- ? trustHTML(this.model?.poll?.title)- : this.model?.post?.topic?.title;+ return this.args.model?.poll?.title+ ? trustHTML(this.args.model?.poll?.title)+ : this.args.model?.post?.topic?.title;}get groupableUserFields() {@@ -58,9 +52,8 @@ export default class PollBreakdownModal extends Component {});}- @computed("model.poll.options")get totalVotes() {- return this.model?.poll?.options?.reduce(+ return this.args.model?.poll?.options?.reduce((sum, option) => sum + option.votes,0);@@ -69,8 +62,8 @@ export default class PollBreakdownModal extends Component {fetchGroupedPollData() {return ajax("/polls/grouped_poll_results.json", {data: {- post_id: this.model.post.id,- poll_name: this.model.poll.name,+ post_id: this.args.model.post.id,+ poll_name: this.args.model.poll.name,user_field_name: this.groupedBy,},})@@ -86,19 +79,19 @@ export default class PollBreakdownModal extends Component {return;}- this.set("charts", result.grouped_results);+ this.charts = result.grouped_results;});}@actionsetGrouping(value) {- this.set("groupedBy", value);+ this.groupedBy = value;this.fetchGroupedPollData();}@actiononSelectPanel(panel) {- this.set("displayMode", panel.id);+ this.displayMode = panel.id;}<template>@@ -134,11 +127,11 @@ export default class PollBreakdownModal extends Component {<div class="poll-breakdown-total-votes">{{i18n"poll.breakdown.votes"- count=this.model.poll.voters}}</div><ul class="poll-breakdown-options">- {{#each this.model.poll.options as |option index|}}+ {{#each @model.poll.options as |option index|}}<PollBreakdownOption@displayMode={{this.displayMode}}@highlightedOption={{this.highlightedOption}}@@ -146,7 +139,7 @@ export default class PollBreakdownModal extends Component {@onMouseOut={{fn (mut this.highlightedOption) null}}@onMouseOver={{fn (mut this.highlightedOption) index}}@option={{option}}- @optionsCount={{this.model.poll.options.length}}+ @optionsCount={{@model.poll.options.length}}@totalVotes={{this.totalVotes}}/>{{/each}}diff --git a/plugins/poll/assets/javascripts/discourse/components/poll-breakdown-option.gjs b/plugins/poll/assets/javascripts/discourse/components/poll-breakdown-option.gjsindex 6a7e2ed74e9..d54cc1c864b 100644--- a/plugins/poll/assets/javascripts/discourse/components/poll-breakdown-option.gjs+++ b/plugins/poll/assets/javascripts/discourse/components/poll-breakdown-option.gjs@@ -1,57 +1,44 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";+import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";import { on } from "@ember/modifier";-import { computed } from "@ember/object";import { trustHTML } from "@ember/template";-import { tagName } from "@ember-decorators/component";import { loadChartJSGetHoverColor } from "discourse/lib/load-chart-js";import { deepEqual } from "discourse/lib/object";import I18n, { i18n } from "discourse-i18n";import { getColors } from "discourse/plugins/poll/lib/chart-colors";import decoratePollOption from "../modifiers/decorate-poll-option.js";-@tagName("")export default class PollBreakdownOption extends Component {- // Arguments:- option = null;- index = null;- totalVotes = null;- optionsCount = null;- displayMode = null;- highlightedOption = null;- onMouseOver = null;- onMouseOut = null;+ @tracked getHoverColor;constructor() {super(...arguments);loadChartJSGetHoverColor().then((getHoverColor) => {- this.set("getHoverColor", getHoverColor);+ this.getHoverColor = getHoverColor;});}- @computed("highlightedOption", "index")get highlighted() {- return deepEqual(this.highlightedOption, this.index);+ return deepEqual(this.args.highlightedOption, this.args.index);}- @computed("displayMode")get showPercentage() {- return this.displayMode === "percentage";+ return this.args.displayMode === "percentage";}- @computed("option.votes", "totalVotes")get percent() {- return I18n.toNumber((this.option?.votes / this.totalVotes) * 100.0, {- precision: 1,- });+ return I18n.toNumber(+ (this.args.option?.votes / this.args.totalVotes) * 100.0,+ {+ precision: 1,+ }+ );}- @computed("optionsCount")get optionColors() {- return getColors(this.optionsCount);+ return getColors(this.args.optionsCount);}- @computed("highlighted")get colorBackgroundStyle() {if (this.highlighted) {// TODO: Use CSS variables (#10341)@@ -59,9 +46,8 @@ export default class PollBreakdownOption extends Component {}}- @computed("getHoverColor", "highlighted", "optionColors", "index")get colorPreviewStyle() {- const color = this.optionColors[this.index];+ const color = this.optionColors[this.args.index];const previewColor = this.highlighted? (this.getHoverColor?.(color) ?? color): color;diff --git a/plugins/poll/test/javascripts/component/poll-breakdown-test.gjs b/plugins/poll/test/javascripts/component/poll-breakdown-test.gjsindex 155cbe911bc..01192e75a48 100644--- a/plugins/poll/test/javascripts/component/poll-breakdown-test.gjs+++ b/plugins/poll/test/javascripts/component/poll-breakdown-test.gjs@@ -1,5 +1,5 @@import { getOwner } from "@ember/owner";-import { render, settled, triggerEvent } from "@ember/test-helpers";+import { click, render, settled, triggerEvent } from "@ember/test-helpers";import { module, test } from "qunit";import ModalContainer from "discourse/components/modal-container";import { setupRenderingTest } from "discourse/tests/helpers/component-test";@@ -45,4 +45,37 @@ module("Poll | Component | PollBreakdownModal", function (hooks) {"differs from the base color");});++ test("shows each option's share and switches to counts", async function (assert) {+ this.siteSettings.poll_groupable_user_fields = "occupation";+ pretender.get("/polls/grouped_poll_results.json", () =>+ response({ grouped_results: [] })+ );+ const model = {+ post: { id: 1, topic: { title: "A topic" } },+ poll: {+ name: "poll",+ title: "Favorite color",+ voters: 4,+ options: [+ { id: "a", html: "Red", votes: 1 },+ { id: "b", html: "Blue", votes: 3 },+ ],+ },+ };+ await render(<template><ModalContainer /></template>);+ getOwner(this).lookup("service:modal").show(PollBreakdownModal, { model });+ await settled();++ assert.dom(".poll-breakdown-title").hasText("Favorite color");+ assert+ .dom(".poll-breakdown-option:nth-child(2) .poll-breakdown-option-count")+ .hasText("75.0%", "shows percentages by default");++ await click(".modal-tab.count");++ assert+ .dom(".poll-breakdown-option:nth-child(2) .poll-breakdown-option-count")+ .hasText("3", "shows vote counts on the count tab");+ });});