mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
1ad2c05d37
no issue - new linting rules that needed fixing: - calling `super` in lifecycle hooks - no usage of String prototype extensions
46 lines
1.1 KiB
JavaScript
46 lines
1.1 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',
|
|
{
|
|
description: 'You\'ve successfully added yourself as a member.'
|
|
}
|
|
);
|
|
|
|
return member;
|
|
} catch (error) {
|
|
if (error) {
|
|
this.notifications.showAPIError(error, {key: 'member.save'});
|
|
}
|
|
}
|
|
}
|
|
}
|