mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
1 parent
6df56b5471
commit
33d7036939
16 files changed
+182
-160
No files matched your search
@@ -15,7 +15,6 @@ export interface ClusterModel {
|
||||
id: ClusterId;
|
||||
contextName: string;
|
||||
kubeConfigPath: string;
|
||||
port?: number;
|
||||
kubeConfig?: string;
|
||||
workspace?: string;
|
||||
preferences?: ClusterPreferences;
|
||||
@@ -56,6 +55,10 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
return Array.from(this.clusters.values());
|
||||
}
|
||||
|
||||
@computed get inactiveClusters() {
|
||||
return Array.from(this.clusters.values()).filter(cluster => !cluster.initialized);
|
||||
}
|
||||
|
||||
getById(id: ClusterId): Cluster {
|
||||
return this.clusters.get(id);
|
||||
}
|
||||
@@ -97,8 +100,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
clusters.forEach(clusterModel => {
|
||||
let cluster = currentClusters.get(clusterModel.id);
|
||||
if (cluster) {
|
||||
Object.assign(cluster, clusterModel);
|
||||
cluster.mergeModel(clusterModel);
|
||||
cluster.updateModel(clusterModel);
|
||||
} else {
|
||||
cluster = new Cluster(clusterModel);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
// https://www.electronjs.org/docs/api/ipc-main
|
||||
// https://www.electronjs.org/docs/api/ipc-renderer
|
||||
|
||||
import { ipcMain, ipcRenderer } from "electron"
|
||||
import { ipcMain, ipcRenderer, webContents } from "electron"
|
||||
import logger from "../main/logger";
|
||||
|
||||
export interface IpcOptions {
|
||||
export type IpcChannel = string;
|
||||
|
||||
export interface IpcMessageOptions {
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
@@ -13,12 +15,16 @@ export interface IpcMessageHandler {
|
||||
(...args: any[]): any;
|
||||
}
|
||||
|
||||
export async function invokeMessage(channel: string, ...args: any[]) {
|
||||
export function sendMessageToRenderer(channel: IpcChannel, ...args: any[]) {
|
||||
webContents.getFocusedWebContents().send(channel, ...args);
|
||||
}
|
||||
|
||||
export async function invokeMessage(channel: IpcChannel, ...args: any[]) {
|
||||
logger.debug(`[IPC]: invoke channel "${channel}"`, { args });
|
||||
return ipcRenderer.invoke(channel, ...args);
|
||||
}
|
||||
|
||||
export function onMessage(channel: string, handler: IpcMessageHandler, options: IpcOptions = {}) {
|
||||
export function handleMessage(channel: IpcChannel, handler: IpcMessageHandler, options: IpcMessageOptions = {}) {
|
||||
const { timeout = 0 } = options;
|
||||
ipcMain.handle(channel, async (event, ...args: any[]) => {
|
||||
logger.debug(`[IPC]: handle "${channel}"`, { event, args });
|
||||
@@ -41,8 +47,8 @@ export function onMessage(channel: string, handler: IpcMessageHandler, options:
|
||||
})
|
||||
}
|
||||
|
||||
export function onMessages(messages: Record<string, IpcMessageHandler>, options?: IpcOptions) {
|
||||
export function handleMessages(messages: Record<string, IpcMessageHandler>, options?: IpcMessageOptions) {
|
||||
Object.entries(messages).forEach(([channel, handler]) => {
|
||||
onMessage(channel, handler, options);
|
||||
handleMessage(channel, handler, options);
|
||||
})
|
||||
}
|
||||
@@ -6,6 +6,7 @@ export enum ClusterIpcMessage {
|
||||
CLUSTER_REMOVE = "cluster-remove",
|
||||
CLUSTER_REMOVE_WORKSPACE = "cluster-remove-all-from-workspace",
|
||||
CLUSTER_EVENTS = "cluster-events-count",
|
||||
CLUSTER_REFRESH = "cluster-refresh",
|
||||
FEATURE_INSTALL = "cluster-feature-install",
|
||||
FEATURE_UPGRADE = "cluster-feature-upgrade",
|
||||
FEATURE_REMOVE = "cluster-feature-remove",
|
||||
|
||||
Reference in new issue
Block a user