From 249abfad670d2d33e0bf57242e996be70ce4c37a Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 20 Sep 2021 06:01:05 -0400 Subject: [PATCH 1/4] Fix reference error when opening cluster view (#3824) Signed-off-by: Sebastian Malton --- src/renderer/api/catalog-entity-registry.ts | 18 +++++++++++++++++- src/renderer/components/app.tsx | 10 ++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/renderer/api/catalog-entity-registry.ts b/src/renderer/api/catalog-entity-registry.ts index 7b09ff273b..d731e2562a 100644 --- a/src/renderer/api/catalog-entity-registry.ts +++ b/src/renderer/api/catalog-entity-registry.ts @@ -31,7 +31,7 @@ import { once } from "lodash"; export type EntityFilter = (entity: CatalogEntity) => any; export class CatalogEntityRegistry { - @observable.ref activeEntity: CatalogEntity; + @observable protected activeEntityId: string | undefined = undefined; protected _entities = observable.map([], { deep: true }); protected filters = observable.set([], { deep: false, @@ -46,6 +46,22 @@ export class CatalogEntityRegistry { makeObservable(this); } + get activeEntity(): CatalogEntity | null { + return this._entities.get(this.activeEntityId) || null; + } + + set activeEntity(raw: CatalogEntity | string | null) { + if (raw) { + const id = typeof raw === "string" + ? raw + : raw.getId(); + + this.activeEntityId = id; + } else { + this.activeEntityId = undefined; + } + } + init() { ipcRendererOn("catalog:items", (event, items: (CatalogEntityData & CatalogEntityKindData)[]) => { this.updateItems(items); diff --git a/src/renderer/components/app.tsx b/src/renderer/components/app.tsx index 3f8dbf7d8b..c7d60f3b4f 100755 --- a/src/renderer/components/app.tsx +++ b/src/renderer/components/app.tsx @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import React from "react"; -import { observable, makeObservable, reaction } from "mobx"; +import { observable, makeObservable } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; import { Redirect, Route, Router, Switch } from "react-router"; import { history } from "../navigation"; @@ -97,13 +97,7 @@ export class App extends React.Component { await cluster.whenReady; // cluster.activate() is done at this point - const activeEntityDisposer = reaction(() => catalogEntityRegistry.getById(App.clusterId), (entity) => { - if (!entity) { - return; - } - catalogEntityRegistry.activeEntity = entity; - activeEntityDisposer(); - }, {fireImmediately: true}); + catalogEntityRegistry.activeEntity = App.clusterId; ExtensionLoader.getInstance().loadOnClusterRenderer(); setTimeout(() => { From ae726f936e92e6a4fd2a435338388a7c9fa57087 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Mon, 20 Sep 2021 15:15:26 +0300 Subject: [PATCH 2/4] Fix node-fetch load on renderer (#3836) * fix node-fetch load on renderer Signed-off-by: Jari Kolehmainen * cleanup Signed-off-by: Jari Kolehmainen * cleanup Signed-off-by: Jari Kolehmainen --- src/main/window-manager.ts | 2 -- webpack.main.ts | 39 +------------------------------------- webpack.renderer.ts | 3 +++ 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index be6d71498e..80e3224fd4 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -31,7 +31,6 @@ import { IpcRendererNavigationEvents } from "../renderer/navigation/events"; import logger from "./logger"; import { productName } from "../common/vars"; import { LensProxy } from "./lens-proxy"; -import * as path from "path"; function isHideable(window: BrowserWindow | null): boolean { return Boolean(window && !window.isDestroyed()); @@ -85,7 +84,6 @@ export class WindowManager extends Singleton { titleBarStyle: "hiddenInset", backgroundColor: "#1e2124", webPreferences: { - preload: path.join(__static, "build", "preload.js"), nodeIntegration: true, nodeIntegrationInSubFrames: true, enableRemoteModule: true, diff --git a/webpack.main.ts b/webpack.main.ts index 33d9daf6af..62e51bf4a2 100755 --- a/webpack.main.ts +++ b/webpack.main.ts @@ -22,7 +22,7 @@ import path from "path"; import type webpack from "webpack"; import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"; -import { isProduction, mainDir, buildDir, isDevelopment, preloadEntrypoint } from "./src/common/vars"; +import { isProduction, mainDir, buildDir, isDevelopment } from "./src/common/vars"; import nodeExternals from "webpack-node-externals"; import ProgressBarPlugin from "progress-bar-webpack-plugin"; import * as vars from "./src/common/vars"; @@ -68,41 +68,4 @@ configs.push((): webpack.Configuration => { }; }); -configs.push((): webpack.Configuration => { - console.info("WEBPACK:preload", vars); - - return { - context: __dirname, - target: "electron-main", - mode: isProduction ? "production" : "development", - devtool: isProduction ? "source-map" : "cheap-eval-source-map", - cache: isDevelopment, - entry: { - main: path.resolve(preloadEntrypoint), - }, - output: { - libraryTarget: "global", - path: buildDir, - filename: "preload.js" - }, - resolve: { - extensions: [".json", ".js", ".ts"], - mainFields: ["main"] - }, - module: { - rules: [ - { - test: /\.node$/, - use: "node-loader" - }, - getTSLoader(/\.ts$/) - ] - }, - plugins: [ - new ProgressBarPlugin(), - new ForkTsCheckerPlugin(), - ].filter(Boolean) - }; -}); - export default configs; diff --git a/webpack.renderer.ts b/webpack.renderer.ts index 5be6ba09dc..5e43213bd0 100755 --- a/webpack.renderer.ts +++ b/webpack.renderer.ts @@ -79,6 +79,9 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura ".ts", ".tsx", ] }, + externals: { + "node-fetch": "commonjs node-fetch" + }, optimization: { minimize: false }, From 9c516cbde4198b5b1bcd914fb372fd5e4a9601df Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 20 Sep 2021 09:54:12 -0400 Subject: [PATCH 3/4] Fix error due to async validators for (#3823) Signed-off-by: Sebastian Malton --- src/renderer/components/input/input.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/input/input.tsx b/src/renderer/components/input/input.tsx index e5276ffcb5..f9054ceeb8 100644 --- a/src/renderer/components/input/input.tsx +++ b/src/renderer/components/input/input.tsx @@ -91,7 +91,7 @@ const defaultProps: Partial = { export class Input extends React.Component { static defaultProps = defaultProps as object; - public input: InputElement; + public input: InputElement | null = null; public validators: InputValidator[] = []; public state: State = { @@ -191,7 +191,7 @@ export class Input extends React.Component { } } - this.input.setCustomValidity(errors.length ? errors[0].toString() : ""); + this.input?.setCustomValidity(errors.length ? errors[0].toString() : ""); } setValidation(errors: React.ReactNode[]) { From b34230ff2cb3bdee44b24905b5b14f920cc81bf9 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 21 Sep 2021 08:38:49 +0300 Subject: [PATCH 4/4] v5.2.3 Signed-off-by: Jari Kolehmainen --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 412f717dff..ffcbbcee0a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "productName": "OpenLens", "description": "OpenLens - Open Source IDE for Kubernetes", "homepage": "https://github.com/lensapp/lens", - "version": "5.2.2", + "version": "5.2.3", "main": "static/build/main.js", "copyright": "© 2021 OpenLens Authors", "license": "MIT",