mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:52:45 +08:00
DEV: migrates user-badge to gjs (#27866)
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
This commit is contained in:
parent
b024e32e74
commit
48f36e52a4
|
@ -0,0 +1,25 @@
|
|||
import Component from "@glimmer/component";
|
||||
import BadgeButton from "discourse/components/badge-button";
|
||||
|
||||
export default class UserBadge extends Component {
|
||||
get showGrantCount() {
|
||||
return this.args.count > 1;
|
||||
}
|
||||
|
||||
get badgeUrl() {
|
||||
// NOTE: I tried using a link-to helper here but the queryParams mean it fails
|
||||
let username = this.args.user?.username_lower;
|
||||
username = username ? `?username=${username}` : "";
|
||||
return this.args.badge.url + username;
|
||||
}
|
||||
|
||||
<template>
|
||||
<a class="user-card-badge-link" href={{this.badgeUrl}}>
|
||||
<BadgeButton @badge={{@badge}}>
|
||||
{{#if this.showGrantCount}}
|
||||
<span class="count"> (×{{@count}})</span>
|
||||
{{/if}}
|
||||
</BadgeButton>
|
||||
</a>
|
||||
</template>
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<a class="user-card-badge-link" href={{this.badgeUrl}}>
|
||||
<BadgeButton @badge={{@badge}}>
|
||||
{{#if this.showGrantCount}}
|
||||
<span class="count"> (×{{@count}})</span>
|
||||
{{/if}}
|
||||
</BadgeButton>
|
||||
</a>
|
|
@ -1,19 +0,0 @@
|
|||
import Component from "@ember/component";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export default Component.extend({
|
||||
tagName: "",
|
||||
|
||||
@discourseComputed("count")
|
||||
showGrantCount(count) {
|
||||
return count && count > 1;
|
||||
},
|
||||
|
||||
@discourseComputed("badge", "user")
|
||||
badgeUrl() {
|
||||
// NOTE: I tried using a link-to helper here but the queryParams mean it fails
|
||||
let username = this.get("user.username_lower") || "";
|
||||
username = username !== "" ? "?username=" + username : "";
|
||||
return this.get("badge.url") + username;
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue
Block a user