2021-08-13 14:41:34 +03:00
|
|
|
import ModalComponent from 'ghost-admin/components/modal-base';
|
2022-01-21 22:25:47 +03:00
|
|
|
import {alias, not} from '@ember/object/computed';
|
2021-08-13 14:41:34 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {task} from 'ember-concurrency';
|
|
|
|
|
|
|
|
export default ModalComponent.extend({
|
|
|
|
membersStats: service(),
|
|
|
|
selectedLabel: null,
|
|
|
|
|
|
|
|
// Allowed actions
|
|
|
|
confirm: () => {},
|
2021-09-10 07:49:25 +03:00
|
|
|
isDisabled: not('selectedLabel'),
|
2021-08-13 14:41:34 +03:00
|
|
|
member: alias('model'),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
confirm() {
|
2021-08-13 19:20:46 +03:00
|
|
|
this.removeLabelTask.perform();
|
2021-08-13 14:41:34 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
setLabel(label) {
|
|
|
|
this.set('selectedLabel', label);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-08-13 19:20:46 +03:00
|
|
|
removeLabelTask: task(function* () {
|
2021-08-13 14:41:34 +03:00
|
|
|
try {
|
2021-09-08 09:36:03 +03:00
|
|
|
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;
|
2021-08-13 14:41:34 +03:00
|
|
|
}
|
|
|
|
}).drop()
|
|
|
|
});
|