Fixed "new post" button showing 500 error when editor beta is enabled (#17926)

refs https://github.com/TryGhost/Ghost/pull/17876

- the redirect added for the beta editor was always redirecting to `lexical-editor.edit` even when accessing `editor.new` which resulted in an incorrect route params error and a 500 screen
- switched to redirecting to the correct new/edit route based on the route we're trying to access
This commit is contained in:
Kevin Ansfield 2023-09-01 14:31:40 +01:00 committed by GitHub
parent d790e25cd9
commit a4f6a33fee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,8 +13,14 @@ export default AuthenticatedRoute.extend({
beforeModel(transition) {
// redirect to the beta editor so the post gets auto-migrated
if (this.feature.lexicalEditor) {
const {name} = transition.to;
const {type, post_id: id} = transition.to.params;
return this.router.transitionTo('lexical-editor.edit', type, id);
if (name === 'editor.new') {
return this.router.transitionTo('lexical-editor.new', type);
} else if (name === 'editor.edit') {
return this.router.transitionTo('lexical-editor.edit', type, id);
}
}
},