mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 16:38:22 +03:00
3653cfbfbf
no issue - moved `document-title` Route extension's functionality into the `ui` service - updates the title each time the router service emits a route changed event - `ui.updateDocumentTitle()` can now be called directly from components rather than the confusing `this.send('updateDocumentTitle')` bubbling behaviour - refactored the `titleToken` implementation to use the now-formalised `RouteInfo`'s `metadata` field (https://github.com/emberjs/rfcs/blob/master/text/0398-RouteInfo-Metadata.md#appendix-a)
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import CurrentUserSettings from '../../../mixins/current-user-settings';
|
|
import UnsplashObject from 'ghost-admin/models/unsplash-integration';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default AuthenticatedRoute.extend(CurrentUserSettings, {
|
|
config: service(),
|
|
settings: service(),
|
|
|
|
// reload settings to ensure we have latest values and pre-configure
|
|
// Unsplash to be active if the server doesn't have any unsplash setting
|
|
beforeModel() {
|
|
this._super(...arguments);
|
|
let {settings} = this;
|
|
|
|
return this.get('session.user')
|
|
.then(this.transitionAuthor())
|
|
.then(this.transitionEditor())
|
|
.then(this.settings.reload())
|
|
.then(() => {
|
|
if (settings.get('unsplash')) {
|
|
return;
|
|
}
|
|
|
|
// server doesn't have any unsplash settings by default but it can provide
|
|
// overrides via config:
|
|
// - isActive: use as default but allow settings override
|
|
// - applicationId: total override, no field is shown if present
|
|
let unsplash = UnsplashObject.create({
|
|
isActive: true
|
|
});
|
|
|
|
settings.set('unsplash', unsplash);
|
|
});
|
|
},
|
|
|
|
actions: {
|
|
save() {
|
|
this.controller.send('save');
|
|
},
|
|
|
|
willTransition(transition) {
|
|
let controller = this.controller;
|
|
let modelIsDirty = controller.dirtyAttributes;
|
|
|
|
if (modelIsDirty) {
|
|
transition.abort();
|
|
controller.send('toggleLeaveSettingsModal', transition);
|
|
return;
|
|
}
|
|
}
|
|
},
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Unsplash'
|
|
};
|
|
}
|
|
});
|