mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 16:42:17 +03:00
cc4ff8c6d4
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
30 lines
822 B
JavaScript
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();
|
|
}
|
|
}
|
|
}
|