Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit e52513f

Browse files
committed
DEV: Modernize user card connector and resolve deprecations
Removes deprecated `parentView` access, and `getOwner`
1 parent d0170d0 commit e52513f

File tree

3 files changed

+60
-57
lines changed

3 files changed

+60
-57
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Component from "@glimmer/component";
2+
import { action } from "@ember/object";
3+
import { service } from "@ember/service";
4+
import DButton from "discourse/components/d-button";
5+
import { emojiUrlFor } from "discourse/lib/text";
6+
import icon from "discourse-common/helpers/d-icon";
7+
import I18n from "I18n";
8+
import { showUserNotes } from "discourse/plugins/discourse-user-notes/discourse-user-notes/lib/user-notes";
9+
10+
export default class extends Component {
11+
static shouldRender(args, context) {
12+
const { siteSettings, currentUser } = context;
13+
return siteSettings.user_notes_enabled && currentUser?.staff;
14+
}
15+
16+
@service siteSettings;
17+
@service currentUser;
18+
@service store;
19+
20+
get userNotesCount() {
21+
return parseInt(
22+
this.args.outletArgs.user.get("user_notes_count") ||
23+
this.args.outletArgs.user.get("custom_fields.user_notes_count") ||
24+
0,
25+
10
26+
);
27+
}
28+
29+
@action
30+
showUserNotes() {
31+
showUserNotes(this.store, this.args.outletArgs.user.id, (count) => {
32+
if (this.isDestroying || this.isDestroyed) {
33+
return;
34+
}
35+
36+
this.set("userNotesCount", count);
37+
});
38+
}
39+
40+
<template>
41+
<div class="show-user-notes-on-card">
42+
{{#if this.userNotesCount}}
43+
<DButton
44+
@translatedTitle={{I18n.t
45+
"user_notes.show"
46+
count=this.userNotesCount
47+
}}
48+
@action={{this.showUserNotes}}
49+
class="btn btn-flat"
50+
>
51+
{{#if this.siteSettings.enable_emoji}}
52+
<img src={{emojiUrlFor "pencil"}} alt="pencil" class="emoji" />
53+
{{else}}
54+
{{icon "sticky-note"}}
55+
{{/if}}
56+
</DButton>
57+
{{/if}}
58+
</div>
59+
</template>
60+
}

assets/javascripts/discourse-user-notes/connectors/user-card-post-names/show-user-notes-on-card.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

assets/javascripts/discourse-user-notes/templates/connectors/user-card-post-names/show-user-notes-on-card.hbs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)