From c56bfd51de4c582ee34835bf1caeb8e96d8be275 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 4 Oct 2023 14:28:58 +0100 Subject: [PATCH] Fixed posts list hrefs showing "mobiledoc-editor" and added "editor-beta" redirects no issue - switched posts list over to using the `lexical-editor.edit` route so it uses the `/editor/` href rather than `/mobiledoc-editor/` - added redirect handling for the `/editor-beta/*` urls to our generic 404 route so anyone upgrading with the beta URLs still open in tabs or saved won't hit a 404 --- .../app/components/posts-list/list-item.hbs | 4 ++-- ghost/admin/app/routes/error404.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ghost/admin/app/components/posts-list/list-item.hbs b/ghost/admin/app/components/posts-list/list-item.hbs index fbf47f2d92..a3a21b58db 100644 --- a/ghost/admin/app/components/posts-list/list-item.hbs +++ b/ghost/admin/app/components/posts-list/list-item.hbs @@ -45,7 +45,7 @@ {{/unless}} {{else}} - +

{{#if @post.featured}} {{svg-jar "star-fill" class="gh-featured-post"}} @@ -206,7 +206,7 @@ {{else}} - + {{svg-jar "pen" title="Go to Editor"}} diff --git a/ghost/admin/app/routes/error404.js b/ghost/admin/app/routes/error404.js index 1dfcb35c41..a63a9d138d 100644 --- a/ghost/admin/app/routes/error404.js +++ b/ghost/admin/app/routes/error404.js @@ -1,9 +1,28 @@ import Route from '@ember/routing/route'; +import {inject as service} from '@ember/service'; export default class Error404Route extends Route { controllerName = 'error'; templateName = 'error'; + @service router; + + beforeModel(transition) { + // handle redirects for old routes + if (transition.to?.params?.path?.startsWith?.('editor-beta')) { + const [, type, postId] = transition.to.params.path.split('/'); + + const route = postId ? 'lexical-editor.edit' : 'lexical-editor.new'; + const models = [type]; + + if (postId) { + models.push(postId); + } + + return this.router.transitionTo(route, ...models); + } + } + model() { return { status: 404