mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Warn if ClusterPageMenuRegistration is a subMenu and has an Icon (#3462)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
51b53b3349
commit
270d9d631c
@ -102,26 +102,41 @@ export class Sidebar extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTabLayoutRoutes(menu: ClusterPageMenuRegistration): TabLayoutRoute[] {
|
getTabLayoutRoutes(menu: ClusterPageMenuRegistration): TabLayoutRoute[] {
|
||||||
const routes: TabLayoutRoute[] = [];
|
|
||||||
|
|
||||||
if (!menu.id) {
|
if (!menu.id) {
|
||||||
return routes;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterPageMenuRegistry.getInstance().getSubItems(menu).forEach((subMenu) => {
|
const routes: TabLayoutRoute[] = [];
|
||||||
const subPage = ClusterPageRegistry.getInstance().getByPageTarget(subMenu.target);
|
const subMenus = ClusterPageMenuRegistry.getInstance().getSubItems(menu);
|
||||||
|
const clusterPageRegistry= ClusterPageRegistry.getInstance();
|
||||||
|
|
||||||
if (subPage) {
|
for (const subMenu of subMenus) {
|
||||||
const { extensionId, id: pageId } = subPage;
|
const page = clusterPageRegistry.getByPageTarget(subMenu.target);
|
||||||
|
|
||||||
routes.push({
|
if (!page) {
|
||||||
routePath: subPage.url,
|
continue;
|
||||||
url: getExtensionPageUrl({ extensionId, pageId, params: subMenu.target.params }),
|
|
||||||
title: subMenu.title,
|
|
||||||
component: subPage.components.Page,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
const { extensionId, id: pageId, url, components } = page;
|
||||||
|
|
||||||
|
if (subMenu.components.Icon) {
|
||||||
|
console.warn(
|
||||||
|
"ClusterPageMenuRegistration has components.Icon defined and a valid parentId. Icon will not be displayed",
|
||||||
|
{
|
||||||
|
id: subMenu.id,
|
||||||
|
parentId: subMenu.parentId,
|
||||||
|
target: subMenu.target,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
routes.push({
|
||||||
|
routePath: url,
|
||||||
|
url: getExtensionPageUrl({ extensionId, pageId, params: subMenu.target.params }),
|
||||||
|
title: subMenu.title,
|
||||||
|
component: components.Page,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user