From 9ff482f9855fa0cd86010eccabdb4230fc968eae Mon Sep 17 00:00:00 2001 From: Jono M Date: Mon, 11 Dec 2023 14:43:06 +0000 Subject: [PATCH] Updated AdminX routing to work with and without a leading slash (#19312) no issue --- apps/admin-x-framework/src/providers/RoutingProvider.tsx | 2 +- .../src/components/settings/advanced/Integrations.tsx | 2 +- ghost/admin/app/components/admin-x/admin-x-component.js | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/admin-x-framework/src/providers/RoutingProvider.tsx b/apps/admin-x-framework/src/providers/RoutingProvider.tsx index 9a9cd1b303..763ce62490 100644 --- a/apps/admin-x-framework/src/providers/RoutingProvider.tsx +++ b/apps/admin-x-framework/src/providers/RoutingProvider.tsx @@ -111,7 +111,7 @@ const RoutingProvider: React.FC = ({basePath, modals, chil return; } - const newPath = options.route; + const newPath = options.route.replace(/^\//, ''); if (newPath === route) { // No change diff --git a/apps/admin-x-settings/src/components/settings/advanced/Integrations.tsx b/apps/admin-x-settings/src/components/settings/advanced/Integrations.tsx index a3de88ca73..225dd58aee 100644 --- a/apps/admin-x-settings/src/components/settings/advanced/Integrations.tsx +++ b/apps/admin-x-settings/src/components/settings/advanced/Integrations.tsx @@ -42,7 +42,7 @@ const IntegrationItem: React.FC = ({ const handleClick = () => { if (disabled) { - updateRoute({route: 'pro'}); + updateRoute({route: 'pro', isExternal: true}); } else { action(); } diff --git a/ghost/admin/app/components/admin-x/admin-x-component.js b/ghost/admin/app/components/admin-x/admin-x-component.js index 7010138f0a..ac1ca0b79e 100644 --- a/ghost/admin/app/components/admin-x/admin-x-component.js +++ b/ghost/admin/app/components/admin-x/admin-x-component.js @@ -220,6 +220,9 @@ export default class AdminXComponent extends Component { }; externalNavigate = ({route, models = []}) => { + if (!route.startsWith('/')) { + route = `/${route}`; + } this.router.transitionTo(route, ...models); };