2016-05-24 15:06:59 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
2022-09-16 13:58:56 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2014-11-25 23:56:08 +03:00
|
|
|
|
2022-01-17 12:34:55 +03:00
|
|
|
export default class NewRoute extends AuthenticatedRoute {
|
2022-09-16 13:58:56 +03:00
|
|
|
@service feature;
|
|
|
|
@service router;
|
|
|
|
|
|
|
|
beforeModel(transition) {
|
|
|
|
super.beforeModel(...arguments);
|
|
|
|
|
|
|
|
if (this.feature.lexicalEditor) {
|
|
|
|
return this.transitionTo('lexical-editor.new', transition.to.params.type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-07 20:31:03 +03:00
|
|
|
model(params, transition) {
|
|
|
|
let {type: modelName} = params;
|
|
|
|
|
|
|
|
if (!['post','page'].includes(modelName)) {
|
|
|
|
let path = transition.intent.url.replace(/^\//, '');
|
|
|
|
return this.replaceWith('error404', {path, status: 404});
|
|
|
|
}
|
|
|
|
|
2021-07-12 22:19:32 +03:00
|
|
|
return this.store.createRecord(modelName, {authors: [this.session.user]});
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|
2014-06-06 05:18:03 +04:00
|
|
|
|
2018-01-17 16:27:37 +03:00
|
|
|
// there's no specific controller for this route, instead all editor
|
2022-09-16 13:58:56 +03:00
|
|
|
// handling is done on the editor route/controller
|
2018-01-17 16:27:37 +03:00
|
|
|
setupController(controller, newPost) {
|
|
|
|
let editor = this.controllerFor('editor');
|
|
|
|
editor.setPost(newPost);
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|
2019-05-20 18:16:19 +03:00
|
|
|
|
|
|
|
buildRouteInfoMetadata() {
|
|
|
|
return {
|
|
|
|
mainClasses: ['editor-new']
|
|
|
|
};
|
2014-03-10 07:44:08 +04:00
|
|
|
}
|
2022-01-17 12:34:55 +03:00
|
|
|
}
|