2021-10-05 22:44:27 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
2022-02-09 13:49:38 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2021-10-05 22:44:27 +03:00
|
|
|
|
2022-03-14 13:52:04 +03:00
|
|
|
export default class ConfirmDeleteThemeModal extends Component {
|
2021-10-05 22:44:27 +03:00
|
|
|
@service ghostPaths;
|
|
|
|
@service notifications;
|
|
|
|
@service utils;
|
|
|
|
|
|
|
|
@action
|
|
|
|
downloadTheme(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
this.utils.downloadFile(`${this.ghostPaths.apiRoot}/themes/${this.args.data.theme.name}/download/`);
|
|
|
|
}
|
|
|
|
|
|
|
|
@task
|
|
|
|
*deleteThemeTask() {
|
|
|
|
try {
|
|
|
|
yield this.args.data.theme.destroyRecord();
|
2021-10-19 21:35:03 +03:00
|
|
|
// we need to unload from the store here so that uploading another
|
|
|
|
// theme with the same "id" doesn't attempt to update the deleted record
|
|
|
|
this.args.data.theme.unloadRecord();
|
2021-10-05 22:44:27 +03:00
|
|
|
this.args.close();
|
|
|
|
return true;
|
|
|
|
} catch (error) {
|
|
|
|
// TODO: show error in modal rather than generic message
|
|
|
|
this.notifications.showAPIError(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|