mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
508119244c
refs https://github.com/TryGhost/Team/issues/1734 refs https://github.com/TryGhost/Team/issues/559 refs https://github.com/TryGhost/Ghost/issues/14101 - switches to newer modal patterns ready for later Ember upgrades
28 lines
727 B
JavaScript
28 lines
727 B
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default class DeleteSnippetModal extends Component {
|
|
@service notifications;
|
|
|
|
@task({drop: true})
|
|
*deleteSnippetTask() {
|
|
try {
|
|
const {snippet} = this.args.data;
|
|
|
|
if (snippet.isDeleted) {
|
|
return true;
|
|
}
|
|
|
|
yield snippet.destroyRecord();
|
|
|
|
this.notifications.closeAlerts('snippet.delete');
|
|
return true;
|
|
} catch (error) {
|
|
this.notifications.showAPIError(error, {key: 'snippet.delete.failed'});
|
|
} finally {
|
|
this.args.close();
|
|
}
|
|
}
|
|
}
|