mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import injectService from 'ember-service/inject';
|
|
import ModalComponent from 'ghost-admin/components/modals/base';
|
|
|
|
export default ModalComponent.extend({
|
|
|
|
submitting: false,
|
|
|
|
ghostPaths: injectService(),
|
|
notifications: injectService(),
|
|
store: injectService(),
|
|
ajax: injectService(),
|
|
|
|
_deleteAll() {
|
|
let deleteUrl = this.get('ghostPaths.url').api('db');
|
|
return this.get('ajax').del(deleteUrl);
|
|
},
|
|
|
|
_unloadData() {
|
|
this.get('store').unloadAll('post');
|
|
this.get('store').unloadAll('tag');
|
|
},
|
|
|
|
_showSuccess() {
|
|
this.get('notifications').showAlert('All content deleted from database.', {type: 'success', key: 'all-content.delete.success'});
|
|
},
|
|
|
|
_showFailure(error) {
|
|
this.get('notifications').showAPIError(error, {key: 'all-content.delete'});
|
|
},
|
|
|
|
actions: {
|
|
confirm() {
|
|
this.set('submitting', true);
|
|
|
|
this._deleteAll().then(() => {
|
|
this._unloadData();
|
|
this._showSuccess();
|
|
}).catch((error) => {
|
|
this._showFailure(error);
|
|
}).finally(() => {
|
|
this.send('closeModal');
|
|
});
|
|
}
|
|
}
|
|
});
|