mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Simplify dependencies for a component
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Mikko Aspiala <mikko.aspiala@houston-inc.com>
This commit is contained in:
parent
cfaf5f9402
commit
293cdb87ec
@ -37,16 +37,12 @@ import { ClusterMetadataKey, initialNodeShellImage, ClusterStatus } from "../com
|
||||
import { disposer, storedKubeConfigFolder, toJS } from "../common/utils";
|
||||
import type { Response } from "request";
|
||||
|
||||
export interface IHasName {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cluster
|
||||
*
|
||||
* @beta
|
||||
*/
|
||||
export class Cluster implements ClusterModel, ClusterState, IHasName {
|
||||
export class Cluster implements ClusterModel, ClusterState {
|
||||
/** Unique id for a cluster */
|
||||
public readonly id: ClusterId;
|
||||
private kubeCtl: Kubectl;
|
||||
|
||||
@ -25,7 +25,8 @@ import { hideDetails } from "../../kube-detail-params";
|
||||
import { apiManager } from "../../../../common/k8s-api/api-manager";
|
||||
import { KubeObjectMenuRegistry } from "../../../../extensions/registries";
|
||||
import { getActiveClusterEntity } from "../../../api/catalog-entity-registry";
|
||||
|
||||
import type { KubeObjectMenuDependencies } from "../kube-object-menu";
|
||||
import type { KubeObject } from "../../../../common/k8s-api/kube-object";
|
||||
|
||||
interface Props {
|
||||
Component: React.ReactType<any>
|
||||
@ -36,12 +37,12 @@ export const InjectNaive = ({ Component, ...props }: Props) => {
|
||||
const kubeObjectMenuRegistry = KubeObjectMenuRegistry.getInstance();
|
||||
const cluster = getActiveClusterEntity();
|
||||
|
||||
const dependencies = {
|
||||
const dependencies: KubeObjectMenuDependencies<KubeObject> = {
|
||||
clusterName: cluster.name,
|
||||
editResourceTab,
|
||||
hideDetails,
|
||||
apiManager,
|
||||
kubeObjectMenuRegistry,
|
||||
cluster,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -32,7 +32,6 @@ import type {
|
||||
} from "../../../extensions/registries";
|
||||
import type { IGettableStore } from "../../../common/k8s-api/api-manager";
|
||||
import type { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { IHasName } from "../../../main/cluster";
|
||||
import { ConfirmDialog } from "../confirm-dialog";
|
||||
import asyncFn from "@async-fn/jest";
|
||||
|
||||
@ -40,7 +39,6 @@ describe("kube-object-menu", () => {
|
||||
let hideDetailsStub: () => void;
|
||||
let editResourceTabStub: () => void;
|
||||
let apiManagerStub: IGettableStore;
|
||||
let clusterStub: IHasName;
|
||||
let kubeObjectMenuRegistryStub: IHasGettableItemsForKind;
|
||||
let objectStub: KubeObject | null;
|
||||
let dependencies: KubeObjectMenuDependencies<KubeObject>;
|
||||
@ -63,8 +61,6 @@ describe("kube-object-menu", () => {
|
||||
): TKubeObjectStore | undefined => undefined,
|
||||
};
|
||||
|
||||
clusterStub = { name: "Some cluster name" };
|
||||
|
||||
const MenuItemComponentStub: React.FC = () => <div>Some menu item</div>;
|
||||
|
||||
const dynamicMenuItemStub: KubeObjectMenuRegistration = {
|
||||
@ -85,8 +81,8 @@ describe("kube-object-menu", () => {
|
||||
editResourceTabStub = () => {};
|
||||
|
||||
dependencies = {
|
||||
clusterName: "Some cluster name",
|
||||
apiManager: apiManagerStub,
|
||||
cluster: clusterStub,
|
||||
kubeObjectMenuRegistry: kubeObjectMenuRegistryStub,
|
||||
hideDetails: hideDetailsStub,
|
||||
editResourceTab: editResourceTabStub,
|
||||
|
||||
@ -27,12 +27,11 @@ import identity from "lodash/identity";
|
||||
|
||||
import type { IHasGettableItemsForKind } from "../../../extensions/registries";
|
||||
import type { IGettableStore } from "../../../common/k8s-api/api-manager";
|
||||
import type { IHasName } from "../../../main/cluster";
|
||||
|
||||
export interface KubeObjectMenuDependencies<TKubeObject>{
|
||||
apiManager: IGettableStore;
|
||||
kubeObjectMenuRegistry: IHasGettableItemsForKind;
|
||||
cluster: IHasName;
|
||||
clusterName: string,
|
||||
hideDetails: () => void;
|
||||
editResourceTab: (kubeObject: TKubeObject) => void;
|
||||
}
|
||||
@ -93,7 +92,7 @@ export class KubeObjectMenu<
|
||||
}
|
||||
|
||||
const breadcrumbParts = [
|
||||
this.dependencies.cluster?.name,
|
||||
this.dependencies.clusterName,
|
||||
object.getNs(),
|
||||
object.kind,
|
||||
object.getName(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user