mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AppRootPage: Render app plugins without pages (#58776)
fix: render app plugins that don't have a page in includes
This commit is contained in:
@@ -12,8 +12,7 @@ export function getAppPluginRoutes(): RouteDescriptor[] {
|
|||||||
const isStandalonePluginPage = (id: string) => id.startsWith('standalone-plugin-page-/');
|
const isStandalonePluginPage = (id: string) => id.startsWith('standalone-plugin-page-/');
|
||||||
const isPluginNavModelItem = (model: NavModelItem): model is PluginNavModelItem =>
|
const isPluginNavModelItem = (model: NavModelItem): model is PluginNavModelItem =>
|
||||||
'pluginId' in model && 'id' in model;
|
'pluginId' in model && 'id' in model;
|
||||||
|
const explicitAppPluginRoutes = Object.values(navIndex)
|
||||||
return Object.values(navIndex)
|
|
||||||
.filter<PluginNavModelItem>(isPluginNavModelItem)
|
.filter<PluginNavModelItem>(isPluginNavModelItem)
|
||||||
.map((navItem) => {
|
.map((navItem) => {
|
||||||
const pluginNavSection = getRootSectionForNode(navItem);
|
const pluginNavSection = getRootSectionForNode(navItem);
|
||||||
@@ -26,6 +25,17 @@ export function getAppPluginRoutes(): RouteDescriptor[] {
|
|||||||
component: () => <AppRootPage pluginId={navItem.pluginId} pluginNavSection={pluginNavSection} />,
|
component: () => <AppRootPage pluginId={navItem.pluginId} pluginNavSection={pluginNavSection} />,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return [
|
||||||
|
...explicitAppPluginRoutes,
|
||||||
|
|
||||||
|
// Fallback route for plugins that don't have any pages under includes
|
||||||
|
{
|
||||||
|
path: '/a/:pluginId',
|
||||||
|
exact: false, // route everything under this path to the plugin, so it can define more routes under this path
|
||||||
|
component: ({ match }) => <AppRootPage pluginId={match.params.pluginId} pluginNavSection={navIndex.home} />,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PluginNavModelItem extends Omit<NavModelItem, 'pluginId' | 'id'> {
|
interface PluginNavModelItem extends Omit<NavModelItem, 'pluginId' | 'id'> {
|
||||||
|
|||||||
Reference in New Issue
Block a user