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[] {
|
||||
const routes: TabLayoutRoute[] = [];
|
||||
|
||||
if (!menu.id) {
|
||||
return routes;
|
||||
return [];
|
||||
}
|
||||
|
||||
ClusterPageMenuRegistry.getInstance().getSubItems(menu).forEach((subMenu) => {
|
||||
const subPage = ClusterPageRegistry.getInstance().getByPageTarget(subMenu.target);
|
||||
const routes: TabLayoutRoute[] = [];
|
||||
const subMenus = ClusterPageMenuRegistry.getInstance().getSubItems(menu);
|
||||
const clusterPageRegistry= ClusterPageRegistry.getInstance();
|
||||
|
||||
if (subPage) {
|
||||
const { extensionId, id: pageId } = subPage;
|
||||
for (const subMenu of subMenus) {
|
||||
const page = clusterPageRegistry.getByPageTarget(subMenu.target);
|
||||
|
||||
if (!page) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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: subPage.url,
|
||||
routePath: url,
|
||||
url: getExtensionPageUrl({ extensionId, pageId, params: subMenu.target.params }),
|
||||
title: subMenu.title,
|
||||
component: subPage.components.Page,
|
||||
component: components.Page,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return routes;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user