1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+helm/sidebar-item.tsx
Sebastian Malton 76f48df56b
Fix rerendering of KubeObject views every 30s (#4801)
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
2022-02-03 09:11:28 -05:00

45 lines
1.4 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import React from "react";
import { withInjectables } from "@ogre-tools/injectable-react";
import type { IComputedValue } from "mobx";
import { observer } from "mobx-react";
import { isActiveRoute } from "../../navigation";
import { Icon } from "../icon";
import { SidebarItem } from "../layout/sidebar-item";
import type { TabLayoutRoute } from "../layout/tab-layout";
import { TabRoutesSidebarItems } from "../layout/tab-routes-sidebar-items";
import { helmRoute, helmURL } from "../../../common/routes";
import networkRouteTabsInjectable from "./route-tabs.injectable";
export interface HelmSidebarItemProps {}
interface Dependencies {
routes: IComputedValue<TabLayoutRoute[]>;
}
const NonInjectedHelmSidebarItem = observer(({ routes }: Dependencies & HelmSidebarItemProps) => {
const tabRoutes = routes.get();
return (
<SidebarItem
id="helm"
text="Helm"
isActive={isActiveRoute(helmRoute)}
url={helmURL()}
icon={<Icon material="apps"/>}
>
<TabRoutesSidebarItems routes={tabRoutes} />
</SidebarItem>
);
});
export const HelmSidebarItem = withInjectables<Dependencies, HelmSidebarItemProps>(NonInjectedHelmSidebarItem, {
getProps: (di, props) => ({
routes: di.inject(networkRouteTabsInjectable),
...props,
}),
});