diff --git a/src/common/cluster-ipc.ts b/src/common/cluster-ipc.ts index 416802d537..d5584dd536 100644 --- a/src/common/cluster-ipc.ts +++ b/src/common/cluster-ipc.ts @@ -9,24 +9,24 @@ export const clusterIpc = { const cluster = clusterStore.getById(clusterId); if (cluster) { await cluster.refreshStatus(); - cluster.pushState(); + return cluster.pushState(); } }, }), disconnect: createIpcChannel({ channel: "cluster:disconnect", - handle: (clusterId: ClusterId) => { + handle: (clusterId: ClusterId = clusterStore.activeClusterId) => { tracker.event("cluster", "stop"); - clusterStore.getById(clusterId)?.disconnect(); + return clusterStore.getById(clusterId)?.disconnect(); }, }), reconnect: createIpcChannel({ channel: "cluster:reconnect", - handle: (clusterId: ClusterId) => { + handle: (clusterId: ClusterId = clusterStore.activeClusterId) => { tracker.event("cluster", "reconnect"); - clusterStore.getById(clusterId)?.reconnect(); + return clusterStore.getById(clusterId)?.reconnect(); }, }), } \ No newline at end of file diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 1edeb41ee2..f753f078fa 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -334,13 +334,14 @@ export class Cluster implements ClusterModel { }) } - pushState = (clusterState = this.getState()) => { - logger.debug(`[CLUSTER]: push-state`, clusterState); + pushState = (state = this.getState()): ClusterState => { + logger.debug(`[CLUSTER]: push-state`, state); broadcastIpc({ // webContentId: viewId, // todo: send to cluster-view only channel: "cluster:state", - args: [clusterState], - }) + args: [state], + }); + return state; } // get cluster system meta, e.g. use in "logger" diff --git a/src/renderer/components/cluster-manager/clusters-menu.tsx b/src/renderer/components/cluster-manager/clusters-menu.tsx index 8ae269b683..809aa8853b 100644 --- a/src/renderer/components/cluster-manager/clusters-menu.tsx +++ b/src/renderer/components/cluster-manager/clusters-menu.tsx @@ -19,10 +19,10 @@ import { clusterSettingsURL } from "../+cluster-settings"; import { landingURL } from "../+landing-page"; import { Tooltip, TooltipContent } from "../tooltip"; import { ConfirmDialog } from "../confirm-dialog"; +import { clusterIpc } from "../../../common/cluster-ipc"; // fixme: refresh all cluster-icon badges in background (events-count per cluster) // fixme: allow to rearrange clusters with drag&drop -// fixme: disconnect cluster from context-menu interface Props { className?: IClassName; @@ -57,6 +57,7 @@ export class ClustersMenu extends React.Component { label: _i18n._(t`Disconnect`), click: () => { navigate(landingURL()); + clusterIpc.disconnect.invokeFromRenderer(); } })) } @@ -100,12 +101,13 @@ export class ClustersMenu extends React.Component { )}
{clusters.map(cluster => { + const isActive = cluster.isReady && cluster.id === clusterStore.activeClusterId; return ( this.showCluster(cluster.id)} onContextMenu={() => this.showContextMenu(cluster)} />