simplify page/menu/registry implementation

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen committed 2020-11-13 09:27:48 +02:00
1 parent 97068f4c07
commit 6d0c07b3d1
14 files changed
+83 -98

No files matched your search

+2 -2
View File
@@ -74,11 +74,11 @@ export class App extends React.Component {
}
renderExtensionRoutes() {
return clusterPageRegistry.getItems().map(({ id: pageId, components: { Page }, exact, routePath, subPages }) => {
return clusterPageRegistry.getItems().map(({ components: { Page }, exact, routePath, subPages }) => {
const Component = () => {
if (subPages) {
const tabs: TabLayoutRoute[] = subPages.map(({ exact, routePath, components: { Page } }) => {
const menuItem = clusterPageMenuRegistry.getById(pageId);
const menuItem = clusterPageMenuRegistry.getByRoutePath(routePath);
if (!menuItem) return;
return {
routePath, exact,
@@ -70,7 +70,7 @@ export class ClusterManager extends React.Component {
<Route component={ClusterView} {...clusterViewRoute} />
<Route component={ClusterSettings} {...clusterSettingsRoute} />
{globalPageRegistry.getItems().map(({ routePath, exact, components: { Page } }) => {
return <Route key={routePath} path={routePath} component={Page} exact={exact}/>
return <Route key={routePath} path={routePath} component={Page} exact={true}/>
})}
<Redirect exact to={this.startUrl}/>
</Switch>
@@ -148,8 +148,8 @@ export class ClustersMenu extends React.Component<Props> {
)}
</div>
<div className="extensions">
{globalPageMenuRegistry.getItems().map(({ id: menuItemId, title, url, components: { Icon } }) => {
const registeredPage = globalPageRegistry.getById(menuItemId);
{globalPageMenuRegistry.getItems().map(({ title, url, components: { Icon } }) => {
const registeredPage = globalPageRegistry.getByUrl(url);
if (!registeredPage) return;
const { routePath, exact } = registeredPage;
return (
+3 -2
View File
@@ -191,8 +191,9 @@ export class Sidebar extends React.Component<Props> {
>
{this.renderCustomResources()}
</SidebarNavItem>
{clusterPageMenuRegistry.getItems().map(({ id: menuItemId, title, url, components: { Icon } }) => {
const registeredPage = clusterPageRegistry.getById(menuItemId);
{clusterPageMenuRegistry.getItems().map(({ title, url, components: { Icon } }) => {
const registeredPage = clusterPageRegistry.getByUrl(url);
console.log(url, registeredPage)
if (!registeredPage) return;
const { routePath, exact } = registeredPage;
return (