From 0614279b9da85619c38732a7c96821bd4de18f36 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 11 Jul 2024 11:55:20 +0200 Subject: [PATCH] DEV: migrates user-stat to gjs (#27867) --- .../discourse/app/components/user-stat.gjs | 38 +++++++++++++++++++ .../discourse/app/components/user-stat.hbs | 13 ------- .../discourse/app/components/user-stat.js | 8 ---- 3 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 app/assets/javascripts/discourse/app/components/user-stat.gjs delete mode 100644 app/assets/javascripts/discourse/app/components/user-stat.hbs delete mode 100644 app/assets/javascripts/discourse/app/components/user-stat.js diff --git a/app/assets/javascripts/discourse/app/components/user-stat.gjs b/app/assets/javascripts/discourse/app/components/user-stat.gjs new file mode 100644 index 00000000000..290e7a61a88 --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/user-stat.gjs @@ -0,0 +1,38 @@ +import Component from "@glimmer/component"; +import { htmlSafe } from "@ember/template"; +import formatDuration from "discourse/helpers/format-duration"; +import number from "discourse/helpers/number"; +import icon from "discourse-common/helpers/d-icon"; +import i18n from "discourse-common/helpers/i18n"; + +export default class UserStat extends Component { + get type() { + return this.args.type ?? "number"; + } + + get isNumber() { + return this.type === "number"; + } + + get isDuration() { + return this.type === "duration"; + } + + +} diff --git a/app/assets/javascripts/discourse/app/components/user-stat.hbs b/app/assets/javascripts/discourse/app/components/user-stat.hbs deleted file mode 100644 index 654ac59dee7..00000000000 --- a/app/assets/javascripts/discourse/app/components/user-stat.hbs +++ /dev/null @@ -1,13 +0,0 @@ - - {{#if this.isNumber}} - {{number @value}} - {{else if this.isDuration}} - {{format-duration @value}} - {{else}} - {{@value}} - {{/if}} - - - {{#if @icon}}{{d-icon @icon}}{{/if}} - {{html-safe (i18n @label count=@value)}} - \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/user-stat.js b/app/assets/javascripts/discourse/app/components/user-stat.js deleted file mode 100644 index bc33c00a5d2..00000000000 --- a/app/assets/javascripts/discourse/app/components/user-stat.js +++ /dev/null @@ -1,8 +0,0 @@ -import Component from "@ember/component"; -import { equal } from "@ember/object/computed"; -export default Component.extend({ - classNames: ["user-stat"], - type: "number", - isNumber: equal("type", "number"), - isDuration: equal("type", "duration"), -});