diff --git a/src/common/catalog-entities/kubernetes-cluster.ts b/src/common/catalog-entities/kubernetes-cluster.ts index cd217d3a02..7c6727ada5 100644 --- a/src/common/catalog-entities/kubernetes-cluster.ts +++ b/src/common/catalog-entities/kubernetes-cluster.ts @@ -21,11 +21,12 @@ import { catalogCategoryRegistry } from "../catalog/catalog-category-registry"; import { CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog"; -import { clusterDisconnectHandler } from "../cluster-ipc"; +import { clusterActivateHandler, clusterDisconnectHandler } from "../cluster-ipc"; import { ClusterStore } from "../cluster-store"; import { requestMain } from "../ipc"; import { productName } from "../vars"; import { CatalogCategory, CatalogCategorySpec } from "../catalog"; +import { app } from "electron"; export type KubernetesClusterSpec = { kubeconfigPath: string; @@ -40,6 +41,38 @@ export class KubernetesCluster extends CatalogEntity { + if (app) { + const cluster = ClusterStore.getInstance().getById(this.metadata.uid); + + if (!cluster) return; + + await cluster.activate(); + + return; + } + + await requestMain(clusterActivateHandler, this.metadata.uid, false); + + return; + } + + async disconnect(): Promise { + if (app) { + const cluster = ClusterStore.getInstance().getById(this.metadata.uid); + + if (!cluster) return; + + cluster.disconnect(); + + return; + } + + await requestMain(clusterDisconnectHandler, this.metadata.uid, false); + + return; + } + async onRun(context: CatalogEntityActionContext) { context.navigate(`/cluster/${this.metadata.uid}`); }