mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 12:53:13 +03:00
e5e68ff55b
no refs - when a site has no labels, the bulk action on labels - add/remove - was throwing an error - fixes the bug and adds disabled state for add/remove label bulk action UI
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
import {alias} from '@ember/object/computed';
|
|
import {not} from '@ember/object/computed';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default ModalComponent.extend({
|
|
membersStats: service(),
|
|
selectedLabel: null,
|
|
|
|
// Allowed actions
|
|
confirm: () => {},
|
|
isDisabled: not('selectedLabel'),
|
|
member: alias('model'),
|
|
|
|
actions: {
|
|
confirm() {
|
|
this.removeLabelTask.perform();
|
|
},
|
|
|
|
setLabel(label) {
|
|
this.set('selectedLabel', label);
|
|
}
|
|
},
|
|
|
|
removeLabelTask: task(function* () {
|
|
try {
|
|
const response = yield this.confirm(this.selectedLabel);
|
|
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()
|
|
});
|