mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
simplify page/menu/registry implementation
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
97068f4c07
commit
6d0c07b3d1
14 files changed
+83
-98
No files matched your search
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in new issue
Block a user