Skip to content

Commit

Permalink
DEV: Modernize user card connector and resolve deprecations (#96)
Browse files Browse the repository at this point in the history
Removes deprecated `parentView` access, and `getOwner`
  • Loading branch information
davidtaylorhq authored Jul 3, 2024
1 parent d0170d0 commit 31e41f2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 57 deletions.
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>
}

This file was deleted.

This file was deleted.

0 comments on commit 31e41f2

Please sign in to comment.