Ghost/ghost/admin/app/components/collections/delete-collection-modal.js
Naz cc4ff8c6d4 Added collections CRUD UI
refs https://github.com/TryGhost/Team/issues/3168

- This is basic scaffolding for collection resources UI in Admin. For the most part it's a copy-paste of tags code with slight modifications to fit the collections usecase
2023-05-23 17:26:47 +07:00

30 lines
822 B
JavaScript

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