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
Peter Zimon 81945b22ef
Updated notifications design (#1498)
no issue

- updating toaster design for better discoverability
2020-02-27 09:19:29 +00:00

38 lines
1.1 KiB
JavaScript

import Component from '@ember/component';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default Component.extend({
session: service(),
store: service(),
notifications: service(),
actions: {
addYourself() {
return this.add.perform();
}
},
add: task(function* () {
const member = this.store.createRecord('member', {
email: this.get('session.user.email'),
name: this.get('session.user.name')
});
try {
// NOTE: has to be before member.save() is performed otherwise component is
// destroyed before notification is shown
this.notifications.showNotification('Member added'.htmlSafe(),
{
description: 'You\'ve successfully added yourself as a member.'
}
);
return yield member.save();
} catch (error) {
if (error) {
this.notifications.showAPIError(error, {key: 'member.save'});
}
}
}).drop()
});