Ghost/ghost/admin/app/components/modal-delete-members.js
Kevin Ansfield 72590083f3 Added ability to bulk delete members by label or status (#1883)
refs https://github.com/TryGhost/Team/issues/585
requires https://github.com/TryGhost/Ghost/pull/12082

When a label or status filter is selected on the members screen show a "Delete selected" option in the actions dropdown. Bulk deleted members will _not_ have any subscription data modified in Stripe, if a member should be deleted and have their subscription cancelled it's necessary to do that on a per-member basis.

- updated bulk delete handling to match API
- added link to bulk delete confirmation modal in members actions dropdown (only shown when label, status, or search is used)
- updated testing framework for members
  - added label factory for easier test setup
  - updated `GET /members` and `DEL /members` endpoints to work with label filters
  - updated test selectors for easier reference in tests
2021-04-08 12:06:27 +01:00

32 lines
736 B
JavaScript

import ModalComponent from 'ghost-admin/components/modal-base';
import {task} from 'ember-concurrency';
export default ModalComponent.extend({
confirmed: false,
response: null,
error: null,
// Allowed actions
confirm: () => {},
actions: {
confirm() {
this.deleteMembersTask.perform();
}
},
deleteMembersTask: task(function* () {
try {
this.set('response', yield this.confirm());
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()
});