mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Fix extension sidebar items sometimes being expandable - Change <TabRoutesSidebarItems> to be just a helper function Signed-off-by: Sebastian Malton <sebastian@malton.name> * Actual fix Signed-off-by: Sebastian Malton <sebastian@malton.name>
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
|
import type { IComputedValue } from "mobx";
|
|
import { observer } from "mobx-react";
|
|
import React from "react";
|
|
import { storageRoute, storageURL } from "../../../common/routes";
|
|
import { isActiveRoute } from "../../navigation";
|
|
import { Icon } from "../icon";
|
|
import { SidebarItem } from "../layout/sidebar-item";
|
|
import type { TabLayoutRoute } from "../layout/tab-layout";
|
|
import { renderTabRoutesSidebarItems } from "../layout/tab-routes-sidebar-items";
|
|
import storageRouteTabsInjectable from "./route-tabs.injectable";
|
|
|
|
export interface StorageSidebarItemProps {}
|
|
|
|
interface Dependencies {
|
|
routes: IComputedValue<TabLayoutRoute[]>;
|
|
}
|
|
|
|
const NonInjectedStorageSidebarItem = observer(({ routes }: Dependencies & StorageSidebarItemProps) => {
|
|
const tabRoutes = routes.get();
|
|
|
|
return (
|
|
<SidebarItem
|
|
id="storage"
|
|
text="Storage"
|
|
isActive={isActiveRoute(storageRoute)}
|
|
isHidden={tabRoutes.length == 0}
|
|
url={storageURL()}
|
|
icon={<Icon svg="storage"/>}
|
|
>
|
|
{renderTabRoutesSidebarItems(tabRoutes)}
|
|
</SidebarItem>
|
|
);
|
|
});
|
|
|
|
export const StorageSidebarItem = withInjectables<Dependencies, StorageSidebarItemProps>(NonInjectedStorageSidebarItem, {
|
|
getProps: (di, props) => ({
|
|
routes: di.inject(storageRouteTabsInjectable),
|
|
...props,
|
|
}),
|
|
});
|