mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
e289b391f1
no issue When we were given a source+ref we were using that to find a theme object from the built-in list of marketplace themes and if it wasn't found redirecting to the change-theme screen. That redirect didn't need to happen because we only need the `ref` and can determine the theme name from that. - passed `ref` through to the install modal as a data argument - updated install modal to get theme name from passed in theme or extracted from passed in `ref` when theme is not known - adjusted "isDefaultTheme" so it always checks against Casper rather than using the `ref: 'default'` value from the list of marketplace themes
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
import Route from '@ember/routing/route';
|
|
import {action} from '@ember/object';
|
|
import {bind} from '@ember/runloop';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class InstallThemeRoute extends Route {
|
|
@service modals;
|
|
@service router;
|
|
|
|
redirect(model, transition) {
|
|
const {source, ref} = transition.to.queryParams || {};
|
|
|
|
if (!source || !ref) {
|
|
this.transitionTo('settings.design.change-theme');
|
|
}
|
|
}
|
|
|
|
// use `didTransition` rather than `activate` so that controller setup has completed
|
|
@action
|
|
didTransition() {
|
|
const installController = this.controllerFor('settings.design.change-theme.install');
|
|
const themesController = this.controllerFor('settings.design.change-theme');
|
|
|
|
const theme = themesController.officialThemes.findBy('ref', installController.ref);
|
|
|
|
this.installModal = this.modals.open('modals/design/install-theme', {
|
|
theme,
|
|
ref: installController.ref,
|
|
onSuccess: () => {
|
|
this.showingSuccessModal = true;
|
|
this.router.transitionTo('settings.design');
|
|
}
|
|
}, {
|
|
beforeClose: bind(this, this.beforeModalClose)
|
|
});
|
|
}
|
|
|
|
deactivate() {
|
|
// leave install modal visible if it's in the success state because
|
|
// we're switching over to the design customisation screen in the bg
|
|
// and don't want to auto-close when this modal closes
|
|
if (this.installModal && !this.showingSuccessModal) {
|
|
this.installModal.close();
|
|
}
|
|
}
|
|
|
|
beforeModalClose() {
|
|
if (!this.showingSuccessModal) {
|
|
this.transitionTo('settings.design.change-theme');
|
|
}
|
|
this.showingSuccessModal = false;
|
|
this.installModal = null;
|
|
}
|
|
}
|