Ghost/ghost/admin/app/components/modal-unsubscribe-members.js
Rishabh 5bdef5e44e Wired success/error handling for bulk operations on filtered members
closes https://github.com/TryGhost/Team/issues/1028

Bulk operations - add/remove label, unsubscribe - were added to filtered members list behind filtering labs flag as part of introducing filtering on members list. This handles the success/error response on bulk operations and shows them in the popup similar to delete bulk operation.
2021-09-08 12:06:16 +05:30

36 lines
916 B
JavaScript

import ModalComponent from 'ghost-admin/components/modal-base';
import {alias} from '@ember/object/computed';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default ModalComponent.extend({
membersStats: service(),
shouldCancelSubscriptions: false,
// Allowed actions
confirm: () => {},
member: alias('model'),
actions: {
confirm() {
this.unsubscribeMemberTask.perform();
}
},
unsubscribeMemberTask: task(function* () {
try {
const response = yield this.confirm();
this.set('response', response);
this.set('confirmed', true);
} catch (e) {
if (e.payload?.errors) {
this.set('confirmed', true);
this.set('error', e.payload.errors[0].message);
}
throw e;
}
}).drop()
});