mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix extension cluster pages re-render when they are registered as a sub-menu item
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
a9d2a9ea0d
commit
c9a28fe626
@ -51,6 +51,8 @@ import { sum } from "lodash";
|
|||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class App extends React.Component {
|
export class App extends React.Component {
|
||||||
|
private extensionRoutes: Map<ClusterPageMenuRegistration, JSX.Element> = new Map();
|
||||||
|
|
||||||
static async init() {
|
static async init() {
|
||||||
const frameId = webFrame.routingId;
|
const frameId = webFrame.routingId;
|
||||||
const clusterId = getHostedClusterId();
|
const clusterId = getHostedClusterId();
|
||||||
@ -145,21 +147,27 @@ export class App extends React.Component {
|
|||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderExtensionTabLayoutRoutes() {
|
renderExtensionTabLayoutRoutes(): JSX.Element[] {
|
||||||
return clusterPageMenuRegistry.getRootItems().map((menu, index) => {
|
return clusterPageMenuRegistry.getRootItems().map((menu, index) => {
|
||||||
const tabRoutes = this.getTabLayoutRoutes(menu);
|
let route = this.extensionRoutes.get(menu);
|
||||||
|
if (route) {
|
||||||
|
return route;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tabRoutes = this.getTabLayoutRoutes(menu);
|
||||||
if (tabRoutes.length > 0) {
|
if (tabRoutes.length > 0) {
|
||||||
const pageComponent = () => <TabLayout tabs={tabRoutes} />;
|
const pageComponent = () => <TabLayout tabs={tabRoutes} />;
|
||||||
|
route = <Route key={`extension-tab-layout-route-${index}`} component={pageComponent} path={tabRoutes.map((tab) => tab.routePath)} />;
|
||||||
return <Route key={`extension-tab-layout-route-${index}`} component={pageComponent} path={tabRoutes.map((tab) => tab.routePath)} />;
|
this.extensionRoutes.set(menu, route);
|
||||||
} else {
|
} else {
|
||||||
const page = clusterPageRegistry.getByPageMenuTarget(menu.target);
|
const page = clusterPageRegistry.getByPageMenuTarget(menu.target);
|
||||||
|
|
||||||
if (page) {
|
if (page) {
|
||||||
return <Route key={`extension-tab-layout-route-${index}`} path={page.routePath} exact={page.exact} component={page.components.Page}/>;
|
route = <Route key={`extension-tab-layout-route-${index}`} path={page.routePath} exact={page.exact} component={page.components.Page}/>;
|
||||||
|
this.extensionRoutes.set(menu, route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return route;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user