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

30 lines
839 B
JavaScript

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