From 48e0ab2142bd4e7eee4485f00f998ba5d07cb77d Mon Sep 17 00:00:00 2001 From: Levente Balogh Date: Fri, 3 Feb 2023 09:01:34 +0100 Subject: [PATCH] Plugins: Case-sensitive routes for standalone pages (#62779) * feat: extend the RouteDescription witha `sensitive` property * feat: use case-sensitive routes for custom plugin standalone pages * fix: hcheck for `/a/` instead of `/a` --- public/app/AppWrapper.tsx | 1 + public/app/core/navigation/types.ts | 1 + public/app/features/plugins/routes.tsx | 2 ++ 3 files changed, 4 insertions(+) diff --git a/public/app/AppWrapper.tsx b/public/app/AppWrapper.tsx index 879c4c5ad7d..77017d0f853 100644 --- a/public/app/AppWrapper.tsx +++ b/public/app/AppWrapper.tsx @@ -58,6 +58,7 @@ export class AppWrapper extends React.Component { diff --git a/public/app/core/navigation/types.ts b/public/app/core/navigation/types.ts index d0c628aa576..8ccd484eb19 100644 --- a/public/app/core/navigation/types.ts +++ b/public/app/core/navigation/types.ts @@ -19,4 +19,5 @@ export interface RouteDescriptor { routeName?: string; chromeless?: boolean; exact?: boolean; + sensitive?: boolean; } diff --git a/public/app/features/plugins/routes.tsx b/public/app/features/plugins/routes.tsx index 6e26112cb68..1b043628d65 100644 --- a/public/app/features/plugins/routes.tsx +++ b/public/app/features/plugins/routes.tsx @@ -18,10 +18,12 @@ export function getAppPluginRoutes(): RouteDescriptor[] { const pluginNavSection = getRootSectionForNode(navItem); const appPluginUrl = `/a/${navItem.pluginId}`; const path = isStandalonePluginPage(navItem.id) ? navItem.url || appPluginUrl : appPluginUrl; // Only standalone pages can use core URLs, otherwise we fall back to "/a/:pluginId" + const isSensitive = isStandalonePluginPage(navItem.id) && !navItem.url?.startsWith('/a/'); // Have case-sensitive URLs only for standalone pages that have custom URLs return { path, exact: false, // route everything under this path to the plugin, so it can define more routes under this path + sensitive: isSensitive, component: () => , }; });