mirror of https://github.com/grafana/grafana.git
				
				
				
			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`
This commit is contained in:
		
							parent
							
								
									cf650c9349
								
							
						
					
					
						commit
						48e0ab2142
					
				|  | @ -58,6 +58,7 @@ export class AppWrapper extends React.Component<AppWrapperProps, AppWrapperState | ||||||
|     return ( |     return ( | ||||||
|       <Route |       <Route | ||||||
|         exact={route.exact === undefined ? true : route.exact} |         exact={route.exact === undefined ? true : route.exact} | ||||||
|  |         sensitive={route.sensitive === undefined ? false : route.sensitive} | ||||||
|         path={route.path} |         path={route.path} | ||||||
|         key={route.path} |         key={route.path} | ||||||
|         render={(props) => { |         render={(props) => { | ||||||
|  |  | ||||||
|  | @ -19,4 +19,5 @@ export interface RouteDescriptor { | ||||||
|   routeName?: string; |   routeName?: string; | ||||||
|   chromeless?: boolean; |   chromeless?: boolean; | ||||||
|   exact?: boolean; |   exact?: boolean; | ||||||
|  |   sensitive?: boolean; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -18,10 +18,12 @@ export function getAppPluginRoutes(): RouteDescriptor[] { | ||||||
|       const pluginNavSection = getRootSectionForNode(navItem); |       const pluginNavSection = getRootSectionForNode(navItem); | ||||||
|       const appPluginUrl = `/a/${navItem.pluginId}`; |       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 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 { |       return { | ||||||
|         path, |         path, | ||||||
|         exact: false, // route everything under this path to the plugin, so it can define more routes under this 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} />, |         component: () => <AppRootPage pluginId={navItem.pluginId} pluginNavSection={pluginNavSection} />, | ||||||
|       }; |       }; | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue