mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
attempt 1 to fix opening bug
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
4b660633dd
commit
c426eb9899
9 files changed
+161
-39
No files matched your search
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
|
||||
import { catalogCategoryRegistry } from "../catalog/catalog-category-registry";
|
||||
import { CatalogEntity, CatalogEntityActionContext, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||
import { clusterActivateHandler, clusterDeleteHandler, clusterDisconnectHandler } from "../cluster-ipc";
|
||||
import { CatalogEntity, CatalogEntityAddMenuContext, CatalogEntityContextMenuContext, CatalogEntityMetadata, CatalogEntityStatus } from "../catalog";
|
||||
import { clusterActivateHandler, clusterDeleteHandler, clusterDisconnectHandler, navigateToClusterHandler } from "../cluster-ipc";
|
||||
import { ClusterStore } from "../cluster-store";
|
||||
import { onNewWindowForClusterHandler, requestMain } from "../ipc";
|
||||
import { CatalogCategory, CatalogCategorySpec } from "../catalog";
|
||||
@@ -90,8 +90,8 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
|
||||
}
|
||||
}
|
||||
|
||||
async onRun(context: CatalogEntityActionContext) {
|
||||
context.navigate(`/cluster/${this.metadata.uid}`);
|
||||
async onRun() {
|
||||
requestMain(navigateToClusterHandler, this.getId());
|
||||
}
|
||||
|
||||
onDetailsOpen(): void {
|
||||
@@ -107,7 +107,7 @@ export class KubernetesCluster extends CatalogEntity<KubernetesClusterMetadata,
|
||||
{
|
||||
title: "Open",
|
||||
icon: "open_in_full",
|
||||
onClick: () => this.onRun(context),
|
||||
onClick: () => this.onRun(),
|
||||
},
|
||||
{
|
||||
title: "Open in new window",
|
||||
|
||||
@@ -19,11 +19,45 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { observable } from "mobx";
|
||||
import { action, observable } from "mobx";
|
||||
import type { ClusterId } from "./cluster-store";
|
||||
import { iter, Singleton } from "./utils";
|
||||
|
||||
export interface ClusterFrameInfo {
|
||||
frameId: number;
|
||||
processId: number
|
||||
processId: number;
|
||||
windowId: number;
|
||||
}
|
||||
|
||||
export const clusterFrameMap = observable.map<string, ClusterFrameInfo>();
|
||||
export class ClusterFrames extends Singleton {
|
||||
private mapping = observable.map<ClusterId, ClusterFrameInfo>();
|
||||
|
||||
public getAllFrameInfo(): ClusterFrameInfo[] {
|
||||
return [...this.mapping.values()];
|
||||
}
|
||||
|
||||
public set(clusterId: ClusterId, info: ClusterFrameInfo): void {
|
||||
this.mapping.set(clusterId, info);
|
||||
}
|
||||
|
||||
public getFrameInfoByClusterId(clusterId: ClusterId): ClusterFrameInfo | undefined {
|
||||
return this.mapping.get(clusterId);
|
||||
}
|
||||
|
||||
public getFrameInfoByFrameId(frameId: number): ClusterFrameInfo | undefined {
|
||||
return iter.find(this.mapping.values(), frameInfo => frameInfo.frameId === frameId);
|
||||
}
|
||||
|
||||
public clearInfoForCluster(clusterId: ClusterId): void {
|
||||
this.mapping.delete(clusterId);
|
||||
}
|
||||
|
||||
@action
|
||||
public clearInfoForWindow(windowId: number): void {
|
||||
for (const [clusterId, frameInfo] of this.mapping) {
|
||||
if (frameInfo.windowId === windowId) {
|
||||
this.mapping.delete(clusterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
export const navigateToClusterHandler = "navigate:to-cluster";
|
||||
export const clusterActivateHandler = "cluster:activate";
|
||||
export const clusterSetFrameIdHandler = "cluster:set-frame-id";
|
||||
export const clusterVisibilityHandler = "cluster:visibility";
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
import { ipcMain, ipcRenderer, remote, webContents } from "electron";
|
||||
import { toJS } from "../utils/toJS";
|
||||
import logger from "../../main/logger";
|
||||
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
||||
import { ClusterFrames } from "../cluster-frames";
|
||||
import type { Disposer } from "../utils";
|
||||
|
||||
const subFramesChannel = "ipc:get-sub-frames";
|
||||
@@ -41,10 +41,6 @@ export function ipcMainHandle(channel: string, listener: (event: Electron.IpcMai
|
||||
});
|
||||
}
|
||||
|
||||
function getSubFrames(): ClusterFrameInfo[] {
|
||||
return Array.from(clusterFrameMap.values());
|
||||
}
|
||||
|
||||
export function broadcastMessage(channel: string, ...args: any[]) {
|
||||
const views = (webContents || remote?.webContents)?.getAllWebContents();
|
||||
|
||||
@@ -56,7 +52,7 @@ export function broadcastMessage(channel: string, ...args: any[]) {
|
||||
|
||||
const subFramesP = ipcRenderer
|
||||
? requestMain(subFramesChannel)
|
||||
: Promise.resolve(getSubFrames());
|
||||
: Promise.resolve(ClusterFrames.getInstance().getAllFrameInfo());
|
||||
|
||||
subFramesP
|
||||
.then(subFrames => {
|
||||
@@ -88,7 +84,7 @@ export function ipcRendererOn(channel: string, listener: (event: Electron.IpcRen
|
||||
}
|
||||
|
||||
export function bindBroadcastHandlers() {
|
||||
ipcMainHandle(subFramesChannel, () => getSubFrames());
|
||||
ipcMainHandle(subFramesChannel, () => ClusterFrames.getInstance().getAllFrameInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,3 +55,9 @@ export * from "./type-narrowing";
|
||||
import * as iter from "./iter";
|
||||
|
||||
export { iter };
|
||||
|
||||
export type NeverPartial<T> = {
|
||||
[P in keyof T]?: never;
|
||||
};
|
||||
|
||||
export type OnlyOneOf<T> = { [K in keyof T]-?: Required<Pick<T, K>> & NeverPartial<Pick<T, Exclude<keyof T, K>>>; }[keyof T];
|
||||
Reference in new issue
Block a user