A platform for community discussion. Free, open, simple.
DEV: Convert topic-post-badges to glimmer/gjs (#26760)
Jarek Radosz9874801f946f
diff --git a/app/assets/javascripts/discourse/app/components/topic-post-badges.gjs b/app/assets/javascripts/discourse/app/components/topic-post-badges.gjsnew file mode 100644index 00000000000..271d541b755--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/topic-post-badges.gjs@@ -0,0 +1,37 @@+import Component from "@glimmer/component";+import { service } from "@ember/service";+import i18n from "discourse-common/helpers/i18n";++export default class TopicPostBadges extends Component {+ @service currentUser;++ get displayUnreadPosts() {+ return this.args.newPosts || this.args.unreadPosts;+ }++ get newDotText() {+ return this.currentUser?.trust_level > 0+ ? " "+ : i18n("filters.new.lower_title");+ }++ <template>+ <span class="topic-post-badges">+ {{~#if this.displayUnreadPosts~}}+ <a+ href={{@url}}+ title={{i18n "topic.unread_posts" count=this.displayUnreadPosts}}+ class="badge badge-notification unread-posts"+ >{{this.displayUnreadPosts}}</a>+ {{/if~}}++ {{~#if @unseen~}}+ <a+ href={{@url}}+ title={{i18n "topic.new"}}+ class="badge badge-notification new-topic"+ >{{this.newDotText}}</a>+ {{/if~}}+ </span>+ </template>+}diff --git a/app/assets/javascripts/discourse/app/components/topic-post-badges.hbs b/app/assets/javascripts/discourse/app/components/topic-post-badges.hbsdeleted file mode 100644index c150834a756..00000000000--- a/app/assets/javascripts/discourse/app/components/topic-post-badges.hbs+++ /dev/null@@ -1,12 +0,0 @@-{{~#if this.displayUnreadPosts}} <a- href={{this.url}}- title={{i18n "topic.unread_posts" count=this.displayUnreadPosts}}- class="badge badge-notification unread-posts"- >{{this.displayUnreadPosts}}</a>-{{/if~}}-{{~#if this.unseen}} <a- href={{this.url}}- title={{i18n "topic.new"}}- class="badge badge-notification new-topic"- >{{this.newDotText}}</a>-{{/if~}}\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/topic-post-badges.js b/app/assets/javascripts/discourse/app/components/topic-post-badges.jsdeleted file mode 100644index 986dc9db00d..00000000000--- a/app/assets/javascripts/discourse/app/components/topic-post-badges.js+++ /dev/null@@ -1,22 +0,0 @@-import Component from "@ember/component";-import { or } from "@ember/object/computed";-import I18n from "discourse-i18n";--export default Component.extend({- tagName: "span",- classNameBindings: [":topic-post-badges"],- newDotText: null,-- init() {- this._super(...arguments);-- this.set(- "newDotText",- this.currentUser && this.currentUser.trust_level > 0- ? " "- : I18n.t("filters.new.lower_title")- );- },-- displayUnreadPosts: or("newPosts", "unreadPosts"),-});