2021-09-14 21:32:07 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
2021-10-04 18:34:13 +03:00
|
|
|
export default class SettingsDesignRoute extends AuthenticatedRoute {
|
2021-10-22 12:46:12 +03:00
|
|
|
@service customThemeSettings;
|
2021-09-14 21:32:07 +03:00
|
|
|
@service feature;
|
|
|
|
@service modals;
|
2021-09-16 22:26:49 +03:00
|
|
|
@service settings;
|
2021-10-22 12:46:12 +03:00
|
|
|
@service themeManagement;
|
2021-10-11 17:24:46 +03:00
|
|
|
@service ui;
|
2021-09-14 21:32:07 +03:00
|
|
|
|
|
|
|
beforeModel() {
|
|
|
|
super.beforeModel(...arguments);
|
|
|
|
|
|
|
|
if (!this.session.user.isAdmin) {
|
|
|
|
return this.transitionTo('site');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.feature.customThemeSettings) {
|
|
|
|
return this.transitionTo('settings');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-04 18:34:13 +03:00
|
|
|
model() {
|
2021-10-22 12:46:12 +03:00
|
|
|
// 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()
|
|
|
|
]);
|
2021-10-04 18:34:13 +03:00
|
|
|
}
|
|
|
|
|
2021-09-14 21:32:07 +03:00
|
|
|
activate() {
|
2021-10-11 17:24:46 +03:00
|
|
|
this.ui.contextualNavMenu = 'design';
|
2021-09-14 21:32:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
deactivate() {
|
2021-10-11 17:24:46 +03:00
|
|
|
this.ui.contextualNavMenu = null;
|
2021-09-16 22:26:49 +03:00
|
|
|
}
|
|
|
|
|
2021-10-18 18:43:02 +03:00
|
|
|
buildRouteInfoMetadata() {
|
|
|
|
return {
|
2021-11-01 20:48:49 +03:00
|
|
|
titleToken: 'Settings - Design',
|
2021-10-18 18:43:02 +03:00
|
|
|
mainClasses: ['gh-main-fullwidth']
|
|
|
|
};
|
|
|
|
}
|
2021-10-19 18:25:37 +03:00
|
|
|
}
|