mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
85d7932e45
refs https://github.com/TryGhost/Team/issues/559
refs 054a5f15f5
- with the update of `ember-promise-modals` we started to get deprecation warnings when using `modals.open('modal-component-name')`
- upcoming Ember build updates will introduce tree shaking but using run-time lookup of modal components by name works against that because it's not statically analysable
- switched to importing components and passing the component class directly, eg. `modals.open(ModalComponent)`
- standardized modal component class names with a `MyModal` style to get better behaviour in code editors when it auto generates imports
- dropped the modal defaults from the modals service because we can now use a static `modalOptions` property on the modal components themselves when we want to override the defaults
32 lines
943 B
JavaScript
32 lines
943 B
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default class DeletePostModal extends Component {
|
|
@service notifications;
|
|
@service router;
|
|
|
|
@task({drop: true})
|
|
*deletePostTask() {
|
|
try {
|
|
const {post} = this.args.data;
|
|
|
|
if (post.isDeleted) {
|
|
return true;
|
|
}
|
|
|
|
// 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');
|
|
return true;
|
|
} catch (error) {
|
|
this.notifications.showAPIError(error, {key: 'post.delete.failed'});
|
|
} finally {
|
|
this.args.close();
|
|
}
|
|
}
|
|
}
|