mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
refactor ipc module
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
02b9ac6b8b
commit
cae880ad85
18 files changed
+176
-214
No files matched your search
@@ -6,7 +6,7 @@ import { ResourceApplier } from "../main/resource-applier"
|
||||
import { Cluster } from "../main/cluster";
|
||||
import logger from "../main/logger";
|
||||
import { app } from "electron"
|
||||
import { clusterIpc } from "../common/cluster-ipc"
|
||||
import { requestMain } from "../common/ipc";
|
||||
|
||||
export interface ClusterFeatureStatus {
|
||||
currentVersion: string;
|
||||
@@ -39,7 +39,7 @@ export abstract class ClusterFeature {
|
||||
if (app) {
|
||||
await new ResourceApplier(cluster).kubectlApplyAll(resources)
|
||||
} else {
|
||||
await clusterIpc.kubectlApplyAll.invokeFromRenderer(cluster.id, resources)
|
||||
await requestMain("cluster:kubectl-apply-all", cluster.id, resources)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ import type { ExtensionId, ExtensionManifest, ExtensionModel, LensExtension } fr
|
||||
import type { LensMainExtension } from "./lens-main-extension"
|
||||
import type { LensRendererExtension } from "./lens-renderer-extension"
|
||||
import path from "path"
|
||||
import { broadcastIpc } from "../common/ipc"
|
||||
import { broadcastMessage, subscribeToBroadcast } from "../common/ipc"
|
||||
import { observable, reaction, toJS, } from "mobx"
|
||||
import logger from "../main/logger"
|
||||
import { app, ipcRenderer, remote } from "electron"
|
||||
import { appEventBus } from "./core-api/event-bus"
|
||||
import { clusterStore } from "./core-api/stores"
|
||||
import {
|
||||
appPreferenceRegistry, clusterFeatureRegistry, clusterPageRegistry, globalPageRegistry,
|
||||
kubeObjectDetailRegistry, kubeObjectMenuRegistry, menuRegistry, statusBarRegistry
|
||||
@@ -27,13 +29,25 @@ export class ExtensionLoader {
|
||||
|
||||
constructor() {
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.on("extensions:loaded", (event, extensions: InstalledExtension[]) => {
|
||||
subscribeToBroadcast("extensions:loaded", (event, extensions: InstalledExtension[]) => {
|
||||
extensions.forEach((ext) => {
|
||||
if (!this.getById(ext.manifestPath)) {
|
||||
this.extensions.set(ext.manifestPath, ext)
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
reaction(() => this.extensions.toJS(), () => {
|
||||
this.broadcastExtensions()
|
||||
})
|
||||
appEventBus.addListener((ev) => {
|
||||
if (ev.name === "app" && ev.action === "dom-ready") {
|
||||
this.broadcastExtensions()
|
||||
}
|
||||
})
|
||||
reaction(() => clusterStore.connectedClustersList, () => {
|
||||
this.broadcastExtensions()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,13 +134,8 @@ export class ExtensionLoader {
|
||||
}
|
||||
}
|
||||
|
||||
broadcastExtensions(frameId?: number) {
|
||||
broadcastIpc({
|
||||
channel: "extensions:loaded",
|
||||
frameId: frameId,
|
||||
frameOnly: !!frameId,
|
||||
args: [this.toJSON().extensions],
|
||||
})
|
||||
broadcastExtensions() {
|
||||
broadcastMessage("extensions:loaded", this.toJSON().extensions)
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
||||
Reference in new issue
Block a user