mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Clean up
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
7ba834c5ba
commit
a0030cbd8a
@ -80,7 +80,7 @@ export function SidebarCluster({ clusterEntity }: { clusterEntity: CatalogEntity
|
|||||||
contextMenu.menuItems = [{ title, onClick }];
|
contextMenu.menuItems = [{ title, onClick }];
|
||||||
clusterEntity.onContextMenuOpen(contextMenu);
|
clusterEntity.onContextMenuOpen(contextMenu);
|
||||||
|
|
||||||
setOpened(true);
|
toggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggle = () => {
|
const toggle = () => {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ import { Storage } from "../+storage";
|
|||||||
import { Network } from "../+network";
|
import { Network } from "../+network";
|
||||||
import { crdStore } from "../+custom-resources/crd.store";
|
import { crdStore } from "../+custom-resources/crd.store";
|
||||||
import { CustomResources } from "../+custom-resources/custom-resources";
|
import { CustomResources } from "../+custom-resources/custom-resources";
|
||||||
import { isActiveRoute, navigate } from "../../navigation";
|
import { isActiveRoute } from "../../navigation";
|
||||||
import { isAllowedResource } from "../../../common/utils/allowed-resource";
|
import { isAllowedResource } from "../../../common/utils/allowed-resource";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import { ClusterPageMenuRegistration, ClusterPageMenuRegistry, ClusterPageRegistry, getExtensionPageUrl } from "../../../extensions/registries";
|
import { ClusterPageMenuRegistration, ClusterPageMenuRegistry, ClusterPageRegistry, getExtensionPageUrl } from "../../../extensions/registries";
|
||||||
@ -41,12 +41,6 @@ import { Apps } from "../+apps";
|
|||||||
import * as routes from "../../../common/routes";
|
import * as routes from "../../../common/routes";
|
||||||
import { Config } from "../+config";
|
import { Config } from "../+config";
|
||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
import { HotbarIcon } from "../hotbar/hotbar-icon";
|
|
||||||
import { makeObservable, observable } from "mobx";
|
|
||||||
import type { CatalogEntityContextMenuContext } from "../../../common/catalog";
|
|
||||||
import { HotbarStore } from "../../../common/hotbar-store";
|
|
||||||
import { broadcastMessage } from "../../../common/ipc";
|
|
||||||
import { IpcRendererNavigationEvents } from "../../navigation/events";
|
|
||||||
import { SidebarCluster } from "./sidebar-cluster";
|
import { SidebarCluster } from "./sidebar-cluster";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -56,21 +50,6 @@ interface Props {
|
|||||||
@observer
|
@observer
|
||||||
export class Sidebar extends React.Component<Props> {
|
export class Sidebar extends React.Component<Props> {
|
||||||
static displayName = "Sidebar";
|
static displayName = "Sidebar";
|
||||||
@observable private contextMenu: CatalogEntityContextMenuContext = {
|
|
||||||
menuItems: [],
|
|
||||||
navigate: (url: string, forceMainFrame = true) => {
|
|
||||||
if (forceMainFrame) {
|
|
||||||
broadcastMessage(IpcRendererNavigationEvents.NAVIGATE_IN_APP, url);
|
|
||||||
} else {
|
|
||||||
navigate(url);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(props: Props) {
|
|
||||||
super(props);
|
|
||||||
makeObservable(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
crdStore.reloadAll();
|
crdStore.reloadAll();
|
||||||
@ -199,45 +178,6 @@ export class Sidebar extends React.Component<Props> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCluster() {
|
|
||||||
if (!this.clusterEntity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { metadata, spec } = this.clusterEntity;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.cluster} tabIndex={0}>
|
|
||||||
<HotbarIcon
|
|
||||||
uid={metadata.uid}
|
|
||||||
title={metadata.name}
|
|
||||||
source={metadata.source}
|
|
||||||
src={spec.icon?.src}
|
|
||||||
className="mr-5"
|
|
||||||
onClick={() => navigate("/")}
|
|
||||||
menuItems={this.contextMenu.menuItems}
|
|
||||||
onMenuOpen={() => {
|
|
||||||
const hotbarStore = HotbarStore.getInstance();
|
|
||||||
const isAddedToActive = HotbarStore.getInstance().isAddedToActive(this.clusterEntity);
|
|
||||||
const title = isAddedToActive
|
|
||||||
? "Remove from Hotbar"
|
|
||||||
: "Add to Hotbar";
|
|
||||||
const onClick = isAddedToActive
|
|
||||||
? () => hotbarStore.removeFromHotbar(metadata.uid)
|
|
||||||
: () => hotbarStore.addToHotbar(this.clusterEntity);
|
|
||||||
|
|
||||||
this.contextMenu.menuItems = [{ title, onClick }];
|
|
||||||
this.clusterEntity.onContextMenuOpen(this.contextMenu);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className={styles.clusterName}>
|
|
||||||
{metadata.name}
|
|
||||||
</div>
|
|
||||||
<Icon material="arrow_drop_down"/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
get clusterEntity() {
|
get clusterEntity() {
|
||||||
return catalogEntityRegistry.activeEntity;
|
return catalogEntityRegistry.activeEntity;
|
||||||
}
|
}
|
||||||
@ -247,7 +187,6 @@ export class Sidebar extends React.Component<Props> {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cssNames("flex flex-col", className)} data-testid="cluster-sidebar">
|
<div className={cssNames("flex flex-col", className)} data-testid="cluster-sidebar">
|
||||||
{/* {this.renderCluster()} */}
|
|
||||||
<SidebarCluster clusterEntity={this.clusterEntity}/>
|
<SidebarCluster clusterEntity={this.clusterEntity}/>
|
||||||
<div className={styles.sidebarNav}>
|
<div className={styles.sidebarNav}>
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user