mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Improve cluster connection visibility (#4266)
This commit is contained in:
1 parent
23d5d40d62
commit
3522485c6f
9 files changed
+229
-207
No files matched your search
@@ -26,7 +26,7 @@ import { Cluster } from "../main/cluster";
|
||||
import migrations from "../migrations/cluster-store";
|
||||
import logger from "../main/logger";
|
||||
import { appEventBus } from "./event-bus";
|
||||
import { ipcMainHandle, ipcMainOn, ipcRendererOn, requestMain } from "./ipc";
|
||||
import { ipcMainHandle, requestMain } from "./ipc";
|
||||
import { disposer, toJS } from "./utils";
|
||||
import type { ClusterModel, ClusterId, ClusterState } from "./cluster-types";
|
||||
|
||||
@@ -37,8 +37,6 @@ export interface ClusterStoreModel {
|
||||
const initialStates = "cluster:states";
|
||||
|
||||
export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
private static StateChannel = "cluster:state";
|
||||
|
||||
clusters = observable.map<ClusterId, Cluster>();
|
||||
|
||||
protected disposer = disposer();
|
||||
@@ -83,21 +81,13 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
|
||||
}
|
||||
}
|
||||
|
||||
handleStateChange = (event: any, clusterId: string, state: ClusterState) => {
|
||||
logger.silly(`[CLUSTER-STORE]: received push-state at ${location.host} (${webFrame.routingId})`, clusterId, state);
|
||||
this.getById(clusterId)?.setState(state);
|
||||
};
|
||||
|
||||
registerIpcListener() {
|
||||
logger.info(`[CLUSTER-STORE] start to listen (${webFrame.routingId})`);
|
||||
const ipc = ipcMain ?? ipcRenderer;
|
||||
|
||||
if (ipcMain) {
|
||||
this.disposer.push(ipcMainOn(ClusterStore.StateChannel, this.handleStateChange));
|
||||
}
|
||||
|
||||
if (ipcRenderer) {
|
||||
this.disposer.push(ipcRendererOn(ClusterStore.StateChannel, this.handleStateChange));
|
||||
}
|
||||
ipc?.on("cluster:state", (event, clusterId: ClusterId, state: ClusterState) => {
|
||||
this.getById(clusterId)?.setState(state);
|
||||
});
|
||||
}
|
||||
|
||||
unregisterIpcListener() {
|
||||
|
||||
@@ -122,6 +122,14 @@ export enum ClusterStatus {
|
||||
Offline = 0,
|
||||
}
|
||||
|
||||
/**
|
||||
* The message format for the "cluster:<cluster-id>:connection-update" channels
|
||||
*/
|
||||
export interface KubeAuthUpdate {
|
||||
message: string;
|
||||
isError: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The OpenLens known static metadata keys
|
||||
*/
|
||||
@@ -173,7 +181,6 @@ export interface ClusterState {
|
||||
disconnected: boolean;
|
||||
accessible: boolean;
|
||||
ready: boolean;
|
||||
failureReason: string;
|
||||
isAdmin: boolean;
|
||||
allowedNamespaces: string[]
|
||||
allowedResources: string[]
|
||||
|
||||
Reference in new issue
Block a user