Ghost/ghost/admin/app/components/settings/labs/delete-all-content-modal.js
2022-09-08 09:18:46 +01:00

29 lines
873 B
JavaScript

import Component from '@glimmer/component';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default class DeleteAllContentModal extends Component {
@service ajax;
@service ghostPaths;
@service notifications;
@service router;
@service store;
@task({drop: true})
*deleteAllTask() {
try {
const deleteUrl = this.ghostPaths.url.api('db');
yield this.ajax.del(deleteUrl);
this.store.unloadAll('post');
this.store.unloadAll('tag');
this.notifications.showAlert('All content deleted from database.', {type: 'success', key: 'all-content.delete.success'});
} catch (error) {
this.notifications.showAPIError(error, {key: 'all-content.delete'});
} finally {
this.args.close();
}
}
}