mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix open in new window
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
b86b118e3e
commit
78ea32eaa3
@ -26,7 +26,6 @@ import { clusterActivateHandler, clusterSetFrameIdHandler, clusterVisibilityHand
|
|||||||
import { ClusterId, ClusterStore } from "../../common/cluster-store";
|
import { ClusterId, ClusterStore } from "../../common/cluster-store";
|
||||||
import { appEventBus } from "../../common/event-bus";
|
import { appEventBus } from "../../common/event-bus";
|
||||||
import { ipcMainHandle, onNewWindowForClusterHandler } from "../../common/ipc";
|
import { ipcMainHandle, onNewWindowForClusterHandler } from "../../common/ipc";
|
||||||
import { IpcRendererNavigationEvents } from "../../renderer/navigation/events";
|
|
||||||
import { catalogEntityRegistry } from "../catalog";
|
import { catalogEntityRegistry } from "../catalog";
|
||||||
import { ClusterManager } from "../cluster-manager";
|
import { ClusterManager } from "../cluster-manager";
|
||||||
import { bundledKubectlPath } from "../kubectl";
|
import { bundledKubectlPath } from "../kubectl";
|
||||||
@ -163,10 +162,7 @@ export function initIpcMainHandlers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const wm = WindowManager.getInstance();
|
await WindowManager.getInstance().navigate(`/cluster/${clusterId}`, { clusterId }, { windowId: true });
|
||||||
const window = await wm.openNewWindow();
|
|
||||||
|
|
||||||
window.webContents.send(IpcRendererNavigationEvents.NAVIGATE_IN_APP, `/cluster/${clusterId}`);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("Failed to load url for new cluster window", error);
|
logger.error("Failed to load url for new cluster window", error);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,17 @@ export interface SendToViewArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NavigateFrameInfoSpecifier {
|
export interface NavigateFrameInfoSpecifier {
|
||||||
windowId?: number;
|
/**
|
||||||
|
* The windowId of the window to navigate to or `true` to open a new window
|
||||||
|
*/
|
||||||
|
windowId?: number | true;
|
||||||
|
/**
|
||||||
|
* The clusterId that should have a related frame to navigate to
|
||||||
|
*/
|
||||||
clusterId?: string;
|
clusterId?: string;
|
||||||
|
/**
|
||||||
|
* The specific frame to navigate to
|
||||||
|
*/
|
||||||
frameId?: number;
|
frameId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,12 +167,12 @@ export class WindowManager extends Singleton {
|
|||||||
return browserWindow;
|
return browserWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ensureWindow(windowId?: number): Promise<BrowserWindow> {
|
async ensureWindow(windowId?: number | true): Promise<BrowserWindow> {
|
||||||
// This needs to be ready to hear the IPC message before the window is loaded
|
// This needs to be ready to hear the IPC message before the window is loaded
|
||||||
let viewHasLoaded = Promise.resolve();
|
let viewHasLoaded = Promise.resolve();
|
||||||
let browserWindow: BrowserWindow;
|
let browserWindow: BrowserWindow;
|
||||||
|
|
||||||
if (this.windows.size === 0) {
|
if (this.windows.size === 0 || windowId === true) {
|
||||||
viewHasLoaded = new Promise<void>(resolve => {
|
viewHasLoaded = new Promise<void>(resolve => {
|
||||||
ipcMain.once(IpcRendererNavigationEvents.LOADED, () => resolve());
|
ipcMain.once(IpcRendererNavigationEvents.LOADED, () => resolve());
|
||||||
});
|
});
|
||||||
@ -236,8 +245,8 @@ export class WindowManager extends Singleton {
|
|||||||
* Get the naviate target
|
* Get the naviate target
|
||||||
* @param specifics The fallback options for specifying a target
|
* @param specifics The fallback options for specifying a target
|
||||||
*/
|
*/
|
||||||
private getNavigateTarget(specifics: NavigateFrameInfoSpecifier[]): [ClusterFrameInfo | undefined, number | undefined] {
|
private getNavigateTarget(specifics: NavigateFrameInfoSpecifier[]): [ClusterFrameInfo | undefined, number | true | undefined] {
|
||||||
function* helper(): Iterable<ClusterFrameInfo | number | undefined> {
|
function* helper(): Iterable<ClusterFrameInfo | number | true | undefined> {
|
||||||
const clusterFrames = ClusterFrames.getInstance();
|
const clusterFrames = ClusterFrames.getInstance();
|
||||||
|
|
||||||
for (const fallback of specifics) {
|
for (const fallback of specifics) {
|
||||||
@ -251,7 +260,7 @@ export class WindowManager extends Singleton {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof fallback.windowId === "number") {
|
if (typeof fallback.windowId === "number" || fallback.windowId === true) {
|
||||||
yield fallback.windowId;
|
yield fallback.windowId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,7 +270,7 @@ export class WindowManager extends Singleton {
|
|||||||
|
|
||||||
const target = iter.first(iter.keepDefined(helper()));
|
const target = iter.first(iter.keepDefined(helper()));
|
||||||
|
|
||||||
if (typeof target === "number") {
|
if (typeof target === "number" || target === true) {
|
||||||
return [undefined, target];
|
return [undefined, target];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user