From 7ac7e73a058489121dc4074b65dc0b939dcecf5d Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 5 Jun 2020 08:49:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20members=20list=20not=20r?= =?UTF-8?q?efreshing=20after=20adding=20yourself?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - passed in the `refreshData` action to the `` component and called it after creating the member - converted `` to a glimmer component --- .../app/components/gh-members-no-members.hbs | 6 +-- .../app/components/gh-members-no-members.js | 45 +++++++++++-------- ghost/admin/app/controllers/members.js | 2 +- ghost/admin/app/templates/members.hbs | 2 +- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/ghost/admin/app/components/gh-members-no-members.hbs b/ghost/admin/app/components/gh-members-no-members.hbs index afaae21cae..456d739ed8 100644 --- a/ghost/admin/app/components/gh-members-no-members.hbs +++ b/ghost/admin/app/components/gh-members-no-members.hbs @@ -1,14 +1,14 @@
{{!--

Get started with one of the following options

--}} - - +
Manually add a member - + Import members from CSV diff --git a/ghost/admin/app/components/gh-members-no-members.js b/ghost/admin/app/components/gh-members-no-members.js index 1eafbacdbb..c4e37097f5 100644 --- a/ghost/admin/app/components/gh-members-no-members.js +++ b/ghost/admin/app/components/gh-members-no-members.js @@ -1,38 +1,45 @@ -import Component from '@ember/component'; +import Component from '@glimmer/component'; +import {action} from '@ember/object'; import {inject as service} from '@ember/service'; -import {task} from 'ember-concurrency'; +import {task} from 'ember-concurrency-decorators'; -export default Component.extend({ - session: service(), - store: service(), - notifications: service(), +export default class GhMembersNoMembersComponent extends Component { + @service session; + @service store; + @service notifications; - actions: { - addYourself() { - return this.add.perform(); - } - }, + @action + addYourself() { + return this.addTask.perform(); + } + + @task({drop: true}) + *addTask() { + const user = yield this.session.user; - add: task(function* () { const member = this.store.createRecord('member', { - email: this.get('session.user.email'), - name: this.get('session.user.name') + email: user.get('email'), + name: user.get('name') }); try { - // NOTE: has to be before member.save() is performed otherwise component is - // destroyed before notification is shown + yield member.save(); + + if (this.args.afterCreate) { + this.args.afterCreate(); + } + this.notifications.showNotification('Member added'.htmlSafe(), { description: 'You\'ve successfully added yourself as a member.' } ); - return yield member.save(); + return member; } catch (error) { if (error) { this.notifications.showAPIError(error, {key: 'member.save'}); } } - }).drop() -}); + } +} diff --git a/ghost/admin/app/controllers/members.js b/ghost/admin/app/controllers/members.js index 29ed23d9d5..0c08b75877 100644 --- a/ghost/admin/app/controllers/members.js +++ b/ghost/admin/app/controllers/members.js @@ -172,7 +172,7 @@ export default class MembersController extends Controller { } } - @task + @task({restartable: true}) *fetchMembersTask(params) { // params is undefined when called as a "refresh" of the model let {label, searchParam} = typeof params === 'undefined' ? this : params; diff --git a/ghost/admin/app/templates/members.hbs b/ghost/admin/app/templates/members.hbs index 82f5a954d7..160024e16b 100644 --- a/ghost/admin/app/templates/members.hbs +++ b/ghost/admin/app/templates/members.hbs @@ -71,7 +71,7 @@ {{svg-jar "members-placeholder" class="gh-members-placeholder"}} {{#if this.showingAll}}

No members yet

- + {{else}}

No members match the current filter

{{/if}}