import React from "react"; import { ipcRenderer, IpcRendererEvent, shell } from "electron"; import { clusterStore } from "../../common/cluster-store"; import { InvalidKubeConfigArgs, InvalidKubeconfigChannel } from "../../common/ipc/invalid-kubeconfig"; import { Notifications, notificationsStore } from "../components/notifications"; import { Button } from "../components/button"; export const invalidKubeconfigHandler = { source: ipcRenderer, channel: InvalidKubeconfigChannel, listener: InvalidKubeconfigListener, verifier: (args: [unknown]): args is InvalidKubeConfigArgs => { return args.length === 1 && typeof args[0] === "string" && !!clusterStore.getById(args[0]); }, }; function InvalidKubeconfigListener(event: IpcRendererEvent, ...[clusterId]: InvalidKubeConfigArgs): void { const notificationId = `invalid-kubeconfig:${clusterId}`; const cluster = clusterStore.getById(clusterId); const contextName = cluster.name !== cluster.contextName ? `(context: ${cluster.contextName})` : ""; Notifications.error( (
Cluster {cluster.name} has invalid kubeconfig {contextName} and cannot be displayed. Please fix the { e.preventDefault(); shell.showItemInFolder(cluster.kubeConfigPath); }}>kubeconfig manually and restart Lens or remove the cluster.
Do you want to remove the cluster now?