mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add LensRendererExtension.navigate (#1345)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
deb4773b44
commit
4222359bd6
@ -5,6 +5,7 @@ import type {
|
|||||||
} from "./registries"
|
} from "./registries"
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { LensExtension } from "./lens-extension"
|
import { LensExtension } from "./lens-extension"
|
||||||
|
import { ipcRenderer } from "electron"
|
||||||
|
|
||||||
export class LensRendererExtension extends LensExtension {
|
export class LensRendererExtension extends LensExtension {
|
||||||
@observable.shallow globalPages: PageRegistration[] = []
|
@observable.shallow globalPages: PageRegistration[] = []
|
||||||
@ -15,4 +16,8 @@ export class LensRendererExtension extends LensExtension {
|
|||||||
@observable.shallow statusBarItems: StatusBarRegistration[] = []
|
@observable.shallow statusBarItems: StatusBarRegistration[] = []
|
||||||
@observable.shallow kubeObjectDetailItems: KubeObjectDetailRegistration[] = []
|
@observable.shallow kubeObjectDetailItems: KubeObjectDetailRegistration[] = []
|
||||||
@observable.shallow kubeObjectMenuItems: KubeObjectMenuRegistration[] = []
|
@observable.shallow kubeObjectMenuItems: KubeObjectMenuRegistration[] = []
|
||||||
|
|
||||||
|
navigate(location: string) {
|
||||||
|
ipcRenderer.emit("renderer:navigate", location)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,7 +122,7 @@ export class WindowManager extends Singleton {
|
|||||||
async navigate(url: string, frameId?: number) {
|
async navigate(url: string, frameId?: number) {
|
||||||
await this.ensureMainWindow();
|
await this.ensureMainWindow();
|
||||||
this.sendToView({
|
this.sendToView({
|
||||||
channel: "menu:navigate",
|
channel: "renderer:navigate",
|
||||||
frameId: frameId,
|
frameId: frameId,
|
||||||
data: [url],
|
data: [url],
|
||||||
})
|
})
|
||||||
@ -131,7 +131,7 @@ export class WindowManager extends Singleton {
|
|||||||
reload() {
|
reload() {
|
||||||
const frameId = clusterStore.getById(this.activeClusterId)?.frameId;
|
const frameId = clusterStore.getById(this.activeClusterId)?.frameId;
|
||||||
if (frameId) {
|
if (frameId) {
|
||||||
this.sendToView({ channel: "menu:reload", frameId });
|
this.sendToView({ channel: "renderer:reload", frameId });
|
||||||
} else {
|
} else {
|
||||||
webContents.getFocusedWebContents()?.reload();
|
webContents.getFocusedWebContents()?.reload();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,12 +110,12 @@ if (process.isMainFrame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle navigation via IPC (e.g. from top menu)
|
// Handle navigation via IPC (e.g. from top menu)
|
||||||
ipcRenderer.on("menu:navigate", (event, location: LocationDescriptor) => {
|
ipcRenderer.on("renderer:navigate", (event, location: LocationDescriptor) => {
|
||||||
logger.info(`[IPC]: ${event.type} ${JSON.stringify(location)}`, event);
|
logger.info(`[IPC]: ${event.type} ${JSON.stringify(location)}`, event);
|
||||||
navigate(location);
|
navigate(location);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reload dashboard window
|
// Reload dashboard window
|
||||||
ipcRenderer.on("menu:reload", () => {
|
ipcRenderer.on("renderer:reload", () => {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user