1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/gh-members-no-members.js
Kevin Ansfield b75f5965d3 🐛 Fixed members list not refreshing after adding yourself
no issue

- passed in the `refreshData` action to the `<GhMembersNoMembers>` component and called it after creating the member
- converted `<GhMembersNoMembers>` to a glimmer component
2020-06-05 08:50:20 +01:00

46 lines
1.2 KiB
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency-decorators';
export default class GhMembersNoMembersComponent extends Component {
@service session;
@service store;
@service notifications;
@action
addYourself() {
return this.addTask.perform();
}
@task({drop: true})
*addTask() {
const user = yield this.session.user;
const member = this.store.createRecord('member', {
email: user.get('email'),
name: user.get('name')
});
try {
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 member;
} catch (error) {
if (error) {
this.notifications.showAPIError(error, {key: 'member.save'});
}
}
}
}