mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'refactor-ipc' into split-cluster-to-managed-cluster
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
commit
1d910739e2
8 files changed
+62
-48
No files matched your search
@@ -37,12 +37,12 @@ export class BaseStore<T = any> extends Singleton {
|
||||
return path.basename(this.storeConfig.path);
|
||||
}
|
||||
|
||||
get syncRendererChannel() {
|
||||
return `store-sync-renderer:${this.name}`
|
||||
protected get syncRendererChannel() {
|
||||
return `store-sync-renderer:${this.path}`
|
||||
}
|
||||
|
||||
get syncMainChannel() {
|
||||
return `store-sync-main:${this.name}`
|
||||
protected get syncMainChannel() {
|
||||
return `store-sync-main:${this.path}`
|
||||
}
|
||||
|
||||
get path() {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { observable } from "mobx"
|
||||
|
||||
export const clusterFrameMap = observable.map<string, number>();
|
||||
@@ -4,6 +4,7 @@ import { appEventBus } from "./event-bus"
|
||||
import { ResourceApplier } from "../main/resource-applier";
|
||||
import { ipcMain } from "electron";
|
||||
import { ClusterManager } from "../main/cluster-manager";
|
||||
import { clusterFrameMap } from "./cluster-frames"
|
||||
|
||||
export const clusterActivateHandler = "cluster:activate"
|
||||
export const clusterSetFrameIdHandler = "cluster:set-frame-id"
|
||||
@@ -23,7 +24,7 @@ if (ipcMain) {
|
||||
handleRequest(clusterSetFrameIdHandler, (event, clusterId: ClusterId, frameId?: number) => {
|
||||
const managedCluster = getById(clusterId);
|
||||
if (managedCluster) {
|
||||
if (frameId) managedCluster.cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates
|
||||
clusterFrameMap.set(managedCluster.cluster.id, frameId)
|
||||
return managedCluster.cluster.pushState();
|
||||
}
|
||||
})
|
||||
@@ -34,7 +35,11 @@ if (ipcMain) {
|
||||
|
||||
handleRequest(clusterDisconnectHandler, (event, clusterId: ClusterId) => {
|
||||
appEventBus.emit({name: "cluster", action: "stop"});
|
||||
return getById(clusterId)?.disconnect();
|
||||
const managedCluster = getById(clusterId);
|
||||
if (managedCluster) {
|
||||
managedCluster.disconnect();
|
||||
clusterFrameMap.delete(managedCluster.id)
|
||||
}
|
||||
})
|
||||
|
||||
handleRequest(clusterKubectlApplyAllHandler, (event, clusterId: ClusterId, resources: string[]) => {
|
||||
|
||||
+4
-6
@@ -2,8 +2,9 @@
|
||||
// https://www.electronjs.org/docs/api/ipc-main
|
||||
// https://www.electronjs.org/docs/api/ipc-renderer
|
||||
|
||||
import { ipcMain, ipcRenderer, webContents, remote } from "electron"
|
||||
import { ipcMain, ipcRenderer, webContents, remote } from "electron";
|
||||
import logger from "../main/logger";
|
||||
import { clusterFrameMap } from "./cluster-frames";
|
||||
|
||||
export function handleRequest(channel: string, listener: (...args: any[]) => any) {
|
||||
ipcMain.handle(channel, listener)
|
||||
@@ -15,11 +16,8 @@ export async function requestMain(channel: string, ...args: any[]) {
|
||||
|
||||
async function getSubFrames(): Promise<number[]> {
|
||||
const subFrames: number[] = [];
|
||||
const { clusterStore } = await import("./cluster-store");
|
||||
clusterStore.clustersList.forEach(cluster => {
|
||||
if (cluster.frameId) {
|
||||
subFrames.push(cluster.frameId)
|
||||
}
|
||||
clusterFrameMap.forEach((frameId, _) => {
|
||||
subFrames.push(frameId)
|
||||
});
|
||||
return subFrames;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user