mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove windowManager from extension api (#1323)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
6a908cb528
commit
00be4aa184
@ -16,6 +16,3 @@
|
|||||||
* [LensMainExtension](classes/lensmainextension.md)
|
* [LensMainExtension](classes/lensmainextension.md)
|
||||||
* [LensRendererExtension](classes/lensrendererextension.md)
|
* [LensRendererExtension](classes/lensrendererextension.md)
|
||||||
|
|
||||||
## Variables
|
|
||||||
|
|
||||||
* [windowManager](README.md#windowmanager)
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { LensMainExtension, windowManager } from "@k8slens/extensions";
|
import { LensMainExtension } from "@k8slens/extensions";
|
||||||
import { supportPageURL } from "./src/support.route";
|
import { supportPageURL } from "./src/support.route";
|
||||||
|
|
||||||
export default class SupportPageMainExtension extends LensMainExtension {
|
export default class SupportPageMainExtension extends LensMainExtension {
|
||||||
@ -6,8 +6,8 @@ export default class SupportPageMainExtension extends LensMainExtension {
|
|||||||
{
|
{
|
||||||
parentId: "help",
|
parentId: "help",
|
||||||
label: "Support",
|
label: "Support",
|
||||||
click() {
|
click: () => {
|
||||||
windowManager.navigate(supportPageURL());
|
this.navigate(supportPageURL());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
6
extensions/support-page/package-lock.json
generated
6
extensions/support-page/package-lock.json
generated
@ -26,6 +26,12 @@
|
|||||||
"integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
|
"integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/node": {
|
||||||
|
"version": "14.14.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.7.tgz",
|
||||||
|
"integrity": "sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/prop-types": {
|
"@types/prop-types": {
|
||||||
"version": "15.7.3",
|
"version": "15.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
|
||||||
|
|||||||
@ -2,8 +2,6 @@
|
|||||||
export * from "../lens-main-extension"
|
export * from "../lens-main-extension"
|
||||||
export * from "../lens-renderer-extension"
|
export * from "../lens-renderer-extension"
|
||||||
|
|
||||||
import type { WindowManager } from "../../main/window-manager";
|
|
||||||
|
|
||||||
// APIs
|
// APIs
|
||||||
import * as App from "./app"
|
import * as App from "./app"
|
||||||
import * as EventBus from "./event-bus"
|
import * as EventBus from "./event-bus"
|
||||||
@ -12,9 +10,6 @@ import * as Util from "./utils"
|
|||||||
import * as ClusterFeature from "./cluster-feature"
|
import * as ClusterFeature from "./cluster-feature"
|
||||||
import * as Interface from "../interfaces"
|
import * as Interface from "../interfaces"
|
||||||
|
|
||||||
// TODO: allow to expose windowManager.navigate() as Navigation.navigate() in runtime
|
|
||||||
export let windowManager: WindowManager;
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
App,
|
App,
|
||||||
EventBus,
|
EventBus,
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
import type { MenuRegistration } from "./registries/menu-registry";
|
import type { MenuRegistration } from "./registries/menu-registry";
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { LensExtension } from "./lens-extension"
|
import { LensExtension } from "./lens-extension"
|
||||||
|
import { WindowManager } from "../main/window-manager";
|
||||||
|
|
||||||
export class LensMainExtension extends LensExtension {
|
export class LensMainExtension extends LensExtension {
|
||||||
@observable.shallow appMenus: MenuRegistration[] = []
|
@observable.shallow appMenus: MenuRegistration[] = []
|
||||||
|
|
||||||
|
async navigate(location: string, frameId?: number) {
|
||||||
|
await WindowManager.getInstance<WindowManager>().navigate(location, frameId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,5 +8,5 @@ import * as Navigation from "./navigation"
|
|||||||
export {
|
export {
|
||||||
Component,
|
Component,
|
||||||
K8sApi,
|
K8sApi,
|
||||||
Navigation,
|
Navigation
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
export { navigate, hideDetails, showDetails, getDetailsUrl } from "../../renderer/navigation"
|
export { navigate } from "../../renderer/navigation";
|
||||||
|
export { hideDetails, showDetails, getDetailsUrl } from "../../renderer/navigation"
|
||||||
export { RouteProps } from "react-router"
|
export { RouteProps } from "react-router"
|
||||||
export { IURLParams } from "../../common/utils/buildUrl";
|
export { IURLParams } from "../../common/utils/buildUrl";
|
||||||
|
|||||||
@ -78,7 +78,7 @@ app.on("ready", async () => {
|
|||||||
app.exit();
|
app.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
LensExtensionsApi.windowManager = windowManager = new WindowManager(proxyPort);
|
windowManager = WindowManager.getInstance<WindowManager>(proxyPort);
|
||||||
extensionLoader.init(await extensionManager.load()); // call after windowManager to see splash earlier
|
extensionLoader.init(await extensionManager.load()); // call after windowManager to see splash earlier
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { isDevelopment } from "../common/vars";
|
|||||||
export let tray: Tray;
|
export let tray: Tray;
|
||||||
|
|
||||||
// refresh icon when MacOS dark/light theme has changed
|
// refresh icon when MacOS dark/light theme has changed
|
||||||
nativeTheme.on("updated", () => tray?.setImage(getTrayIcon()));
|
nativeTheme?.on("updated", () => tray?.setImage(getTrayIcon()));
|
||||||
|
|
||||||
export function getTrayIcon(isDark = nativeTheme.shouldUseDarkColors): string {
|
export function getTrayIcon(isDark = nativeTheme.shouldUseDarkColors): string {
|
||||||
return path.resolve(
|
return path.resolve(
|
||||||
|
|||||||
@ -7,8 +7,9 @@ import { extensionLoader } from "../extensions/extension-loader";
|
|||||||
import { appEventBus } from "../common/event-bus"
|
import { appEventBus } from "../common/event-bus"
|
||||||
import { initMenu } from "./menu";
|
import { initMenu } from "./menu";
|
||||||
import { initTray } from "./tray";
|
import { initTray } from "./tray";
|
||||||
|
import { Singleton } from "../common/utils";
|
||||||
|
|
||||||
export class WindowManager {
|
export class WindowManager extends Singleton {
|
||||||
protected mainWindow: BrowserWindow;
|
protected mainWindow: BrowserWindow;
|
||||||
protected splashWindow: BrowserWindow;
|
protected splashWindow: BrowserWindow;
|
||||||
protected windowState: windowStateKeeper.State;
|
protected windowState: windowStateKeeper.State;
|
||||||
@ -17,6 +18,7 @@ export class WindowManager {
|
|||||||
@observable activeClusterId: ClusterId;
|
@observable activeClusterId: ClusterId;
|
||||||
|
|
||||||
constructor(protected proxyPort: number) {
|
constructor(protected proxyPort: number) {
|
||||||
|
super();
|
||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
this.initMenu();
|
this.initMenu();
|
||||||
this.initTray();
|
this.initTray();
|
||||||
|
|||||||
@ -11,6 +11,9 @@ import { clusterViewRoute, IClusterViewRouteParams } from "./components/cluster-
|
|||||||
export const history = typeof window !== "undefined" ? createBrowserHistory() : createMemoryHistory();
|
export const history = typeof window !== "undefined" ? createBrowserHistory() : createMemoryHistory();
|
||||||
export const navigation = createObservableHistory(history);
|
export const navigation = createObservableHistory(history);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navigate to a location. Works only in renderer.
|
||||||
|
*/
|
||||||
export function navigate(location: LocationDescriptor) {
|
export function navigate(location: LocationDescriptor) {
|
||||||
const currentLocation = navigation.getPath();
|
const currentLocation = navigation.getPath();
|
||||||
navigation.push(location);
|
navigation.push(location);
|
||||||
@ -60,6 +63,9 @@ export function getDetailsUrl(details: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show details. Works only in renderer.
|
||||||
|
*/
|
||||||
export function showDetails(path: string, resetSelected = true) {
|
export function showDetails(path: string, resetSelected = true) {
|
||||||
navigation.searchParams.merge({
|
navigation.searchParams.merge({
|
||||||
details: path,
|
details: path,
|
||||||
@ -67,6 +73,9 @@ export function showDetails(path: string, resetSelected = true) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide details. Works only in renderer.
|
||||||
|
*/
|
||||||
export function hideDetails() {
|
export function hideDetails() {
|
||||||
showDetails(null)
|
showDetails(null)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user