Ghost/ghost/admin/app/routes/settings/design.js
Arjuna Kristophe Sankar 096dffb817
🐛 Fixed missing active theme breaks design screen (#15602)
closes: https://github.com/TryGhost/Ghost/issues/15505

When starting Ghost with a missing active theme, the design settings screen and change theme screen both end up in a broken state with the user unable to select a new theme as the active one.

The design screen has no default (or blank) slate, and so shows a preview of an empty theme.
- First added a new default screen to serve as a placeholder for when the state contains no active theme.
- Added a check for when there was no active theme, then redirects the user to the default screen .

The change theme screen wants to set an active property on the theme that should be active in the theme list.
- Added a check to see whether there is an active theme set.
- If there isn't one, don't bother trying to add the active property.
2022-10-30 14:14:11 +00:00

53 lines
1.4 KiB
JavaScript

import AdminRoute from 'ghost-admin/routes/authenticated';
import {inject as service} from '@ember/service';
export default class SettingsDesignRoute extends AdminRoute {
@service customThemeSettings;
@service feature;
@service modals;
@service settings;
@service themeManagement;
@service ui;
@service session;
@service store;
model() {
// background refresh of preview
// not doing it on the 'index' route so that we don't reload going to/from the index,
// any actions performed on child routes that need a refresh should trigger it explicitly
this.themeManagement.updatePreviewHtmlTask.perform();
// wait for settings to be loaded - we need the data to be present before display
return Promise.all([
this.settings.reload(),
this.customThemeSettings.load(),
this.store.findAll('theme')
]);
}
beforeModel() {
super.beforeModel(...arguments);
const user = this.session.user;
if (!user.isAdmin) {
return this.transitionTo('settings.staff.user', user);
}
}
activate() {
this.ui.contextualNavMenu = 'design';
}
deactivate() {
this.ui.contextualNavMenu = null;
}
buildRouteInfoMetadata() {
return {
titleToken: 'Settings - Design',
mainClasses: ['gh-main-fullwidth']
};
}
}