mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 04:13:30 +03:00
57b1ab4800
no issue - part of ember upgrades - removed all unnecessary usage of `.get` - cleaned up imports where we had imports from the same module across multiple lines - standardized on importing specific computed helpers rather than using `computed.foo` - switched tests from using `wait()` to `settled()`
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
import {alias, 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.addLabelTask.perform();
|
|
},
|
|
|
|
setLabel(label) {
|
|
this.set('selectedLabel', label);
|
|
}
|
|
},
|
|
|
|
addLabelTask: 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()
|
|
});
|