mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Roman <ixrock@gmail.com> Co-authored-by: Sebastian Malton <sebastian@malton.name> Co-authored-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Lauri Nevala <lauri.nevala@gmail.com> Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { createIpcChannel } from "./ipc";
|
|
import { ClusterId, clusterStore } from "./cluster-store";
|
|
import { tracker } from "./tracker";
|
|
|
|
export const clusterIpc = {
|
|
init: createIpcChannel({
|
|
channel: "cluster:init",
|
|
handle: async (clusterId: ClusterId, frameId: number) => {
|
|
const cluster = clusterStore.getById(clusterId);
|
|
if (cluster) {
|
|
cluster.frameId = frameId; // save cluster's webFrame.routingId to be able to send push-updates
|
|
return cluster.pushState();
|
|
}
|
|
},
|
|
}),
|
|
activate: createIpcChannel({
|
|
channel: "cluster:activate",
|
|
handle: (clusterId: ClusterId) => {
|
|
return clusterStore.getById(clusterId)?.activate();
|
|
},
|
|
}),
|
|
|
|
disconnect: createIpcChannel({
|
|
channel: "cluster:disconnect",
|
|
handle: (clusterId: ClusterId) => {
|
|
tracker.event("cluster", "stop");
|
|
return clusterStore.getById(clusterId)?.disconnect();
|
|
},
|
|
}),
|
|
|
|
installFeature: createIpcChannel({
|
|
channel: "cluster:install-feature",
|
|
handle: async (clusterId: ClusterId, feature: string, config?: any) => {
|
|
tracker.event("cluster", "install", feature);
|
|
const cluster = clusterStore.getById(clusterId);
|
|
if (cluster) {
|
|
await cluster.installFeature(feature, config)
|
|
} else {
|
|
throw `${clusterId} is not a valid cluster id`;
|
|
}
|
|
}
|
|
}),
|
|
|
|
uninstallFeature: createIpcChannel({
|
|
channel: "cluster:uninstall-feature",
|
|
handle: (clusterId: ClusterId, feature: string) => {
|
|
tracker.event("cluster", "uninstall", feature);
|
|
return clusterStore.getById(clusterId)?.uninstallFeature(feature)
|
|
}
|
|
}),
|
|
|
|
upgradeFeature: createIpcChannel({
|
|
channel: "cluster:upgrade-feature",
|
|
handle: (clusterId: ClusterId, feature: string, config?: any) => {
|
|
tracker.event("cluster", "upgrade", feature);
|
|
return clusterStore.getById(clusterId)?.upgradeFeature(feature, config)
|
|
}
|
|
}),
|
|
} |