Ghost/ghost/admin/app/components/modal-delete-snippet.js
Kevin Ansfield 1bd4b5cda7 Added delete button with confirmation to snippets in card menus
no issue

- show a delete icon when a snippet is hovered in plus/slash menus
- show a confirmation dialog when the delete icon is clicked
- keep menus open whilst displaying the delete confirmation dialog
2020-10-26 17:09:39 +00:00

28 lines
715 B
JavaScript

import ModalComponent from 'ghost-admin/components/modal-base';
import {alias} from '@ember/object/computed';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default ModalComponent.extend({
router: service(),
notifications: service(),
snippet: alias('model'),
actions: {
confirm() {
this.deleteSnippet.perform();
}
},
deleteSnippet: task(function* (snippet) {
try {
yield this.confirm(snippet);
} catch (error) {
this.notifications.showAPIError(error, {key: 'snippet.delete.failed'});
} finally {
this.send('closeModal');
}
}).drop()
});