mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 19:48:50 +03:00
🐛 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
This commit is contained in:
parent
7b49d05e96
commit
7ac7e73a05
@ -1,6 +1,6 @@
|
|||||||
<div class="flex flex-column items-stretch">
|
<div class="flex flex-column items-stretch">
|
||||||
{{!-- <p class="">Get started with one of the following options</p> --}}
|
{{!-- <p class="">Get started with one of the following options</p> --}}
|
||||||
<button class="gh-btn gh-btn-green" onclick={{action "addYourself"}}>
|
<button class="gh-btn gh-btn-green" {{on "click" this.addYourself}}>
|
||||||
<span>Add yourself as a member to test</span>
|
<span>Add yourself as a member to test</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@ -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 {inject as service} from '@ember/service';
|
||||||
import {task} from 'ember-concurrency';
|
import {task} from 'ember-concurrency-decorators';
|
||||||
|
|
||||||
export default Component.extend({
|
export default class GhMembersNoMembersComponent extends Component {
|
||||||
session: service(),
|
@service session;
|
||||||
store: service(),
|
@service store;
|
||||||
notifications: service(),
|
@service notifications;
|
||||||
|
|
||||||
actions: {
|
@action
|
||||||
addYourself() {
|
addYourself() {
|
||||||
return this.add.perform();
|
return this.addTask.perform();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
add: task(function* () {
|
@task({drop: true})
|
||||||
|
*addTask() {
|
||||||
|
const user = yield this.session.user;
|
||||||
|
|
||||||
const member = this.store.createRecord('member', {
|
const member = this.store.createRecord('member', {
|
||||||
email: this.get('session.user.email'),
|
email: user.get('email'),
|
||||||
name: this.get('session.user.name')
|
name: user.get('name')
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// NOTE: has to be before member.save() is performed otherwise component is
|
yield member.save();
|
||||||
// destroyed before notification is shown
|
|
||||||
|
if (this.args.afterCreate) {
|
||||||
|
this.args.afterCreate();
|
||||||
|
}
|
||||||
|
|
||||||
this.notifications.showNotification('Member added'.htmlSafe(),
|
this.notifications.showNotification('Member added'.htmlSafe(),
|
||||||
{
|
{
|
||||||
description: 'You\'ve successfully added yourself as a member.'
|
description: 'You\'ve successfully added yourself as a member.'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return yield member.save();
|
return member;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
this.notifications.showAPIError(error, {key: 'member.save'});
|
this.notifications.showAPIError(error, {key: 'member.save'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).drop()
|
}
|
||||||
});
|
}
|
||||||
|
@ -172,7 +172,7 @@ export default class MembersController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@task
|
@task({restartable: true})
|
||||||
*fetchMembersTask(params) {
|
*fetchMembersTask(params) {
|
||||||
// params is undefined when called as a "refresh" of the model
|
// params is undefined when called as a "refresh" of the model
|
||||||
let {label, searchParam} = typeof params === 'undefined' ? this : params;
|
let {label, searchParam} = typeof params === 'undefined' ? this : params;
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
{{svg-jar "members-placeholder" class="gh-members-placeholder"}}
|
{{svg-jar "members-placeholder" class="gh-members-placeholder"}}
|
||||||
{{#if this.showingAll}}
|
{{#if this.showingAll}}
|
||||||
<h3>No members yet</h3>
|
<h3>No members yet</h3>
|
||||||
<GhMembersNoMembers />
|
<GhMembersNoMembers @afterCreate={{this.refreshData}} />
|
||||||
{{else}}
|
{{else}}
|
||||||
<h3>No members match the current filter</h3>
|
<h3>No members match the current filter</h3>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Loading…
Reference in New Issue
Block a user