[v9.3.x] Plugins: Case-sensitive routes for standalone pages (#62839)

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`

(cherry picked from commit 48e0ab2142)

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-02-06 05:35:10 -05:00
committed by GitHub
parent 516386219c
commit c98610dce5
3 changed files with 4 additions and 0 deletions
+1
View File
@@ -61,6 +61,7 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState
return (
<Route
exact={route.exact === undefined ? true : route.exact}
sensitive={route.sensitive === undefined ? false : route.sensitive}
path={route.path}
key={route.path}
render={(props) => {
+1
View File
@@ -19,4 +19,5 @@ export interface RouteDescriptor {
routeName?: string;
chromeless?: boolean;
exact?: boolean;
sensitive?: boolean;
}
+2
View File
@@ -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: () => <AppRootPage pluginId={navItem.pluginId} pluginNavSection={pluginNavSection} />,
};
});