Ghost/ghost/admin/app/components/settings/integrations/delete-webhook-modal.js
2022-09-08 09:18:56 +01:00

29 lines
748 B
JavaScript

import Component from '@glimmer/component';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default class DeleteWebhookModal extends Component {
@service notifications;
@service router;
@task({drop: true})
*deleteWebhookTask() {
try {
const {webhook} = this.args.data;
if (webhook.isDeleted) {
return true;
}
yield webhook.destroyRecord();
this.notifications.closeAlerts('webhook.delete');
return true;
} catch (error) {
this.notifications.showAPIError(error, {key: 'webhook.delete.failed'});
} finally {
this.args.close();
}
}
}