mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
a122711043
refs https://github.com/TryGhost/Team/issues/559 - moved the modal component class and template into a `components/modals/` directory to keep the top-level dir cleaner - migrated component class to glimmer syntax - moved route transition behaviour directly into the class to avoid weird route-action indirection
27 lines
846 B
JavaScript
27 lines
846 B
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency-decorators';
|
|
|
|
export default class DeletePostModalComponent extends Component {
|
|
@service notifications;
|
|
@service router;
|
|
|
|
@task
|
|
*deletePostTask() {
|
|
try {
|
|
const {post} = this.args.data;
|
|
|
|
// clear the data store and post of any unsaved client-generated tags before deleting
|
|
post.updateTags();
|
|
yield post.destroyRecord();
|
|
|
|
this.notifications.closeAlerts('post.delete');
|
|
this.router.transitionTo(post.displayName === 'page' ? 'pages' : 'posts');
|
|
} catch (error) {
|
|
this.notifications.showAPIError(error, {key: 'post.delete.failed'});
|
|
} finally {
|
|
this.args.close();
|
|
}
|
|
}
|
|
}
|