-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Modernize user card connector and resolve deprecations (#96)
Removes deprecated `parentView` access, and `getOwner`
- Loading branch information
1 parent
d0170d0
commit 31e41f2
Showing
3 changed files
with
54 additions
and
57 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...ascripts/discourse-user-notes/connectors/user-card-post-names/show-user-notes-on-card.gjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Component from "@glimmer/component"; | ||
import { action } from "@ember/object"; | ||
import { service } from "@ember/service"; | ||
import DButton from "discourse/components/d-button"; | ||
import emoji from "discourse/helpers/emoji"; | ||
import icon from "discourse-common/helpers/d-icon"; | ||
import I18n from "I18n"; | ||
import { showUserNotes } from "discourse/plugins/discourse-user-notes/discourse-user-notes/lib/user-notes"; | ||
|
||
export default class extends Component { | ||
static shouldRender(args, context) { | ||
const { siteSettings, currentUser } = context; | ||
return siteSettings.user_notes_enabled && currentUser?.staff; | ||
} | ||
|
||
@service siteSettings; | ||
@service currentUser; | ||
@service store; | ||
|
||
get userNotesCount() { | ||
return parseInt( | ||
this.args.outletArgs.user.get("user_notes_count") || | ||
this.args.outletArgs.user.get("custom_fields.user_notes_count") || | ||
0, | ||
10 | ||
); | ||
} | ||
|
||
@action | ||
showUserNotes() { | ||
showUserNotes(this.store, this.args.outletArgs.user.id); | ||
} | ||
|
||
<template> | ||
<div class="show-user-notes-on-card"> | ||
{{#if this.userNotesCount}} | ||
<DButton | ||
@translatedTitle={{I18n.t | ||
"user_notes.show" | ||
count=this.userNotesCount | ||
}} | ||
@action={{this.showUserNotes}} | ||
class="btn-flat" | ||
> | ||
{{#if this.siteSettings.enable_emoji}} | ||
{{emoji "pencil"}} | ||
{{else}} | ||
{{icon "sticky-note"}} | ||
{{/if}} | ||
</DButton> | ||
{{/if}} | ||
</div> | ||
</template> | ||
} |
39 changes: 0 additions & 39 deletions
39
...vascripts/discourse-user-notes/connectors/user-card-post-names/show-user-notes-on-card.js
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...iscourse-user-notes/templates/connectors/user-card-post-names/show-user-notes-on-card.hbs
This file was deleted.
Oops, something went wrong.