mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
window-manager tweaks
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
25e904d2d5
commit
b05ed9822d
@ -79,6 +79,8 @@ export class Cluster implements ClusterModel {
|
|||||||
const proxyPort = await this.contextHandler.resolveProxyPort();
|
const proxyPort = await this.contextHandler.resolveProxyPort();
|
||||||
this.kubeconfigManager = new KubeconfigManager(this, proxyPort);
|
this.kubeconfigManager = new KubeconfigManager(this, proxyPort);
|
||||||
this.url = this.contextHandler.url
|
this.url = this.contextHandler.url
|
||||||
|
// todo: verify api url
|
||||||
|
// this.apiUrl = kubeConfig.getCurrentCluster().server;
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
logger.debug(`[CLUSTER]: init done (id="${this.id}", context="${this.contextName}")`);
|
logger.debug(`[CLUSTER]: init done (id="${this.id}", context="${this.contextName}")`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -4,15 +4,12 @@ import windowStateKeeper from "electron-window-state"
|
|||||||
import type { ClusterId } from "../common/cluster-store";
|
import type { ClusterId } from "../common/cluster-store";
|
||||||
import { clusterStore } 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 {
|
export class WindowManager {
|
||||||
protected activeView: BrowserWindow;
|
protected activeView: BrowserWindow;
|
||||||
protected views = new Map<ClusterId, BrowserWindow>();
|
protected views = new Map<ClusterId, BrowserWindow>();
|
||||||
|
|
||||||
protected disposers = [
|
protected disposers = [
|
||||||
// auto-destroy view when cluster removed
|
// auto-destroy views for removed clusters
|
||||||
reaction(() => clusterStore.removedClusters.toJS(), removedClusters => {
|
reaction(() => clusterStore.removedClusters.toJS(), removedClusters => {
|
||||||
removedClusters.forEach(cluster => {
|
removedClusters.forEach(cluster => {
|
||||||
this.destroyView(cluster.id);
|
this.destroyView(cluster.id);
|
||||||
@ -45,23 +42,24 @@ export class WindowManager {
|
|||||||
this.splashWindow.hide();
|
this.splashWindow.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
async showView(clusterId: ClusterId) {
|
async activateView(clusterId: ClusterId) {
|
||||||
const cluster = clusterStore.getById(clusterId);
|
const cluster = clusterStore.getById(clusterId);
|
||||||
if (!cluster) {
|
if (!cluster) {
|
||||||
throw new Error(`Can't load lens for non-existing cluster="${clusterId}"`);
|
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);
|
const view = this.getView(clusterId);
|
||||||
if (view !== activeView) {
|
if (view !== currentView) {
|
||||||
this.activeView = view;
|
this.activeView = view;
|
||||||
if (activeView) {
|
|
||||||
view.setBounds(activeView.getBounds()); // update position from previous window
|
|
||||||
}
|
|
||||||
const url = cluster.apiUrl.href;
|
const url = cluster.apiUrl.href;
|
||||||
const isLoaded = url === view.webContents.getURL();
|
const isLoaded = url === view.webContents.getURL();
|
||||||
if (!isLoaded) {
|
if (!isLoaded) {
|
||||||
await view.loadURL(url);
|
await view.loadURL(url);
|
||||||
}
|
}
|
||||||
|
if (currentView) {
|
||||||
|
view.setBounds(currentView.getBounds()); // refresh position for "invisible swap"
|
||||||
|
currentView.hide();
|
||||||
|
}
|
||||||
view.show();
|
view.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,10 +73,8 @@ export class WindowManager {
|
|||||||
y: this.windowState.y,
|
y: this.windowState.y,
|
||||||
width: this.windowState.width,
|
width: this.windowState.width,
|
||||||
height: this.windowState.height,
|
height: this.windowState.height,
|
||||||
backgroundColor: "#1e2124",
|
|
||||||
titleBarStyle: "hidden",
|
titleBarStyle: "hidden",
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
// partition: "lens-app", // todo: reuse session?
|
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user