Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if ClusterPageMenuRegistration is a subMenu and has an Icon #3462

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions src/renderer/components/layout/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

routes.push({
routePath: subPage.url,
url: getExtensionPageUrl({ extensionId, pageId, params: subMenu.target.params }),
title: subMenu.title,
component: subPage.components.Page,
});
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: url,
url: getExtensionPageUrl({ extensionId, pageId, params: subMenu.target.params }),
title: subMenu.title,
component: components.Page,
});
}

return routes;
}
Expand Down