mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
85d7932e45
refs https://github.com/TryGhost/Team/issues/559
refs 054a5f15f5
- with the update of `ember-promise-modals` we started to get deprecation warnings when using `modals.open('modal-component-name')`
- upcoming Ember build updates will introduce tree shaking but using run-time lookup of modal components by name works against that because it's not statically analysable
- switched to importing components and passing the component class directly, eg. `modals.open(ModalComponent)`
- standardized modal component class names with a `MyModal` style to get better behaviour in code editors when it auto generates imports
- dropped the modal defaults from the modals service because we can now use a static `modalOptions` property on the modal components themselves when we want to override the defaults
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default class ConfirmDeleteThemeModal extends Component {
|
|
@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();
|
|
// 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();
|
|
this.args.close();
|
|
return true;
|
|
} catch (error) {
|
|
// TODO: show error in modal rather than generic message
|
|
this.notifications.showAPIError(error);
|
|
}
|
|
}
|
|
}
|