diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 8368e2fd31..ce08019d90 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -79,6 +79,8 @@ export class Cluster implements ClusterModel { const proxyPort = await this.contextHandler.resolveProxyPort(); this.kubeconfigManager = new KubeconfigManager(this, proxyPort); this.url = this.contextHandler.url + // todo: verify api url + // this.apiUrl = kubeConfig.getCurrentCluster().server; this.initialized = true; logger.debug(`[CLUSTER]: init done (id="${this.id}", context="${this.contextName}")`); } catch (err) { diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index 8a7eb6cf7a..b781752751 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -4,15 +4,12 @@ import windowStateKeeper from "electron-window-state" import type { ClusterId } from "../common/cluster-store"; import { clusterStore } from "../common/cluster-store"; -// todo: smooth switching btw clusters (e.g. wait ready-state before switching window) -// todo: devtools + manage main-window size btw views - export class WindowManager { protected activeView: BrowserWindow; protected views = new Map(); protected disposers = [ - // auto-destroy view when cluster removed + // auto-destroy views for removed clusters reaction(() => clusterStore.removedClusters.toJS(), removedClusters => { removedClusters.forEach(cluster => { this.destroyView(cluster.id); @@ -45,23 +42,24 @@ export class WindowManager { this.splashWindow.hide(); } - async showView(clusterId: ClusterId) { + async activateView(clusterId: ClusterId) { const cluster = clusterStore.getById(clusterId); if (!cluster) { throw new Error(`Can't load lens for non-existing cluster="${clusterId}"`); } - const activeView = this.activeView; + const currentView = this.activeView; const view = this.getView(clusterId); - if (view !== activeView) { + if (view !== currentView) { this.activeView = view; - if (activeView) { - view.setBounds(activeView.getBounds()); // update position from previous window - } const url = cluster.apiUrl.href; const isLoaded = url === view.webContents.getURL(); if (!isLoaded) { await view.loadURL(url); } + if (currentView) { + view.setBounds(currentView.getBounds()); // refresh position for "invisible swap" + currentView.hide(); + } view.show(); } } @@ -75,10 +73,8 @@ export class WindowManager { y: this.windowState.y, width: this.windowState.width, height: this.windowState.height, - backgroundColor: "#1e2124", titleBarStyle: "hidden", webPreferences: { - // partition: "lens-app", // todo: reuse session? nodeIntegration: true, }, });