From 688336647d04b77760a250c2fee84bfed36e78af Mon Sep 17 00:00:00 2001
From: Janne Savolainen
Date: Wed, 22 Feb 2023 18:58:05 +0200
Subject: [PATCH 01/21] Extract injection token for application information to
separate NPM package (#7211)
* Introduce dummy package for application
Signed-off-by: Janne Savolainen
* Introduce application information token in application Feature
Signed-off-by: Janne Savolainen
* Switch to using applicationInformationToken from application feature
Signed-off-by: Janne Savolainen
---------
Signed-off-by: Janne Savolainen
---
package-lock.json | 19 +++++++-
packages/core/package.json | 1 +
.../welcome-route-config.injectable.ts | 4 +-
packages/core/src/common/library.ts | 2 -
.../vars/application-copyright.injectable.ts | 2 +-
.../application-description.injectable.ts | 2 +-
...application-information-fake-injectable.ts | 30 +++++++++++++
.../application-information-injectable.ts | 20 ---------
.../vars/application-information-token.ts | 15 -------
...ormation.global-override-for-injectable.ts | 24 ----------
.../bundled-kubectl-version.injectable.ts | 4 +-
.../content-security-policy.injectable.ts | 4 +-
.../common/vars/product-name.injectable.ts | 2 +-
.../common/vars/sentry-dsn-url.injectable.ts | 4 +-
.../store-migration-version.injectable.ts | 2 +-
.../publish-is-configured.injectable.ts | 4 +-
.../store-migrations/snap.injectable.ts | 2 +-
packages/core/src/main/getDi.ts | 12 +----
packages/core/src/main/getDiForUnitTesting.ts | 7 +--
.../create-electron-window.injectable.ts | 2 +-
.../migrations/currentVersion.injectable.ts | 2 +-
packages/core/src/renderer/getDi.tsx | 12 +----
.../core/src/renderer/getDiForUnitTesting.tsx | 7 +--
packages/open-lens/package.json | 1 +
.../application-information.injectable.ts | 44 ++++++++++++++++---
.../technical-features/application/README.md | 18 ++++++++
.../technical-features/application/index.ts | 3 ++
.../application/jest.config.js | 2 +
.../application/package.json | 34 ++++++++++++++
.../src/application-information-token.ts | 24 ++++++++++
.../application/tsconfig.json | 3 ++
.../application/webpack.config.js | 1 +
32 files changed, 201 insertions(+), 112 deletions(-)
create mode 100644 packages/core/src/common/vars/application-information-fake-injectable.ts
delete mode 100644 packages/core/src/common/vars/application-information-injectable.ts
delete mode 100644 packages/core/src/common/vars/application-information-token.ts
delete mode 100644 packages/core/src/common/vars/application-information.global-override-for-injectable.ts
create mode 100644 packages/technical-features/application/README.md
create mode 100644 packages/technical-features/application/index.ts
create mode 100644 packages/technical-features/application/jest.config.js
create mode 100644 packages/technical-features/application/package.json
create mode 100644 packages/technical-features/application/src/application-information-token.ts
create mode 100644 packages/technical-features/application/tsconfig.json
create mode 100644 packages/technical-features/application/webpack.config.js
diff --git a/package-lock.json b/package-lock.json
index ea90dd7e37..f5e29555c3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3281,6 +3281,10 @@
"@jridgewell/sourcemap-codec": "1.4.14"
}
},
+ "node_modules/@k8slens/application": {
+ "resolved": "packages/technical-features/application",
+ "link": true
+ },
"node_modules/@k8slens/bump-version-for-cron": {
"resolved": "packages/bump-version-for-cron",
"link": true
@@ -32254,7 +32258,7 @@
"dependencies": {
"@astronautlabs/jsonpath": "^1.1.0",
"@hapi/call": "^9.0.1",
- "@hapi/subtext": "^7.0.4",
+ "@hapi/subtext": "^7.1.0",
"@k8slens/node-fetch": "^6.4.0-beta.13",
"@kubernetes/client-node": "^0.18.1",
"@material-ui/styles": "^4.11.5",
@@ -32461,6 +32465,7 @@
"node": ">=16 <17"
},
"peerDependencies": {
+ "@k8slens/application": "^6.4.0-beta.13",
"@types/byline": "^4.2.33",
"@types/chart.js": "^2.9.36",
"@types/color": "^3.0.3",
@@ -34095,6 +34100,7 @@
}
},
"packages/infrastructure/webpack": {
+ "name": "@k8slens/webpack",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
@@ -34291,6 +34297,7 @@
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
+ "@k8slens/application": "^6.4.0-beta.13",
"@k8slens/core": "^6.4.0-beta.13",
"@k8slens/ensure-binaries": "^6.4.0-beta.13",
"@k8slens/generate-tray-icons": "^6.4.0-beta.13",
@@ -34534,6 +34541,16 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.12.tgz",
"integrity": "sha512-vzLe5NaNMjIE3mcddFVGlAXN1LEWueUsMsOJWaT6wWMJGyljHAWHznqfnKUQWGzu7TLPrGvWdNAsvQYW+C0xtw==",
"dev": true
+ },
+ "packages/technical-features/application": {
+ "name": "@k8slens/application",
+ "version": "6.4.0-beta.13",
+ "license": "MIT",
+ "peerDependencies": {
+ "@ogre-tools/fp": "^12.0.1",
+ "@ogre-tools/injectable": "^12.0.1",
+ "lodash": "^4.17.15"
+ }
}
}
}
diff --git a/packages/core/package.json b/packages/core/package.json
index 4e9ae7c9bf..f6d58909aa 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -330,6 +330,7 @@
"xterm-addon-fit": "^0.5.0"
},
"peerDependencies": {
+ "@k8slens/application": "^6.4.0-beta.13",
"@types/byline": "^4.2.33",
"@types/chart.js": "^2.9.36",
"@types/color": "^3.0.3",
diff --git a/packages/core/src/common/front-end-routing/routes/welcome/welcome-route-config.injectable.ts b/packages/core/src/common/front-end-routing/routes/welcome/welcome-route-config.injectable.ts
index d7aadf2f91..9883c1476b 100644
--- a/packages/core/src/common/front-end-routing/routes/welcome/welcome-route-config.injectable.ts
+++ b/packages/core/src/common/front-end-routing/routes/welcome/welcome-route-config.injectable.ts
@@ -2,13 +2,13 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "../../../vars/application-information-token";
const welcomeRouteConfigInjectable = getInjectable({
id: "welcome-route-config",
- instantiate: (di) => di.inject(applicationInformationToken).config.welcomeRoute,
+ instantiate: (di) => di.inject(applicationInformationToken).welcomeRoute,
});
export default welcomeRouteConfigInjectable;
diff --git a/packages/core/src/common/library.ts b/packages/core/src/common/library.ts
index f4aee75513..bc625eb3dd 100644
--- a/packages/core/src/common/library.ts
+++ b/packages/core/src/common/library.ts
@@ -4,6 +4,4 @@
*/
// @experimental
-export { applicationInformationToken } from "./vars/application-information-token";
-export type { ApplicationInformation } from "./vars/application-information-token";
export { bundledExtensionInjectionToken } from "../extensions/extension-discovery/bundled-extension-token";
diff --git a/packages/core/src/common/vars/application-copyright.injectable.ts b/packages/core/src/common/vars/application-copyright.injectable.ts
index 0630c98cb6..440a20b5d1 100644
--- a/packages/core/src/common/vars/application-copyright.injectable.ts
+++ b/packages/core/src/common/vars/application-copyright.injectable.ts
@@ -2,8 +2,8 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "./application-information-token";
const applicationCopyrightInjectable = getInjectable({
id: "application-copyright",
diff --git a/packages/core/src/common/vars/application-description.injectable.ts b/packages/core/src/common/vars/application-description.injectable.ts
index 8dabb8f629..2b562df7a1 100644
--- a/packages/core/src/common/vars/application-description.injectable.ts
+++ b/packages/core/src/common/vars/application-description.injectable.ts
@@ -2,8 +2,8 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "./application-information-token";
const applicationDescriptionInjectable = getInjectable({
id: "application-description",
diff --git a/packages/core/src/common/vars/application-information-fake-injectable.ts b/packages/core/src/common/vars/application-information-fake-injectable.ts
new file mode 100644
index 0000000000..c881c4c8ca
--- /dev/null
+++ b/packages/core/src/common/vars/application-information-fake-injectable.ts
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) OpenLens Authors. All rights reserved.
+ * Licensed under MIT License. See LICENSE in root directory for more information.
+ */
+
+import { getInjectable } from "@ogre-tools/injectable";
+import { applicationInformationToken } from "@k8slens/application";
+
+export const applicationInformationFakeInjectable = getInjectable({
+ id: "application-information-fake",
+
+ instantiate: () => ({
+ name: "some-product-name",
+ productName: "some-product-name",
+ version: "6.0.0",
+ updatingIsEnabled: false,
+ k8sProxyVersion: "0.2.1",
+ bundledKubectlVersion: "1.23.3",
+ bundledHelmVersion: "3.7.2",
+ sentryDsn: "",
+ contentSecurityPolicy:
+ "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:",
+
+ welcomeRoute: "/welcome",
+ copyright: "some-copyright-information",
+ description: "some-descriptive-text",
+ }),
+
+ injectionToken: applicationInformationToken,
+});
diff --git a/packages/core/src/common/vars/application-information-injectable.ts b/packages/core/src/common/vars/application-information-injectable.ts
deleted file mode 100644
index 8530257a3a..0000000000
--- a/packages/core/src/common/vars/application-information-injectable.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright (c) OpenLens Authors. All rights reserved.
- * Licensed under MIT License. See LICENSE in root directory for more information.
- */
-import { getInjectable } from "@ogre-tools/injectable";
-import packageJson from "../../../package.json";
-import { applicationInformationToken } from "../../common/vars/application-information-token";
-
-const applicationInformationInjectable = getInjectable({
- id: "application-information",
- injectionToken: applicationInformationToken,
- instantiate: () => {
- const { version, config, productName, build, copyright, description, name } = packageJson;
-
- return { version, config, productName, build, copyright, description, name };
- },
- causesSideEffects: true,
-});
-
-export default applicationInformationInjectable;
diff --git a/packages/core/src/common/vars/application-information-token.ts b/packages/core/src/common/vars/application-information-token.ts
deleted file mode 100644
index 67b187478a..0000000000
--- a/packages/core/src/common/vars/application-information-token.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Copyright (c) OpenLens Authors. All rights reserved.
- * Licensed under MIT License. See LICENSE in root directory for more information.
- */
-
-import { getInjectionToken } from "@ogre-tools/injectable";
-import type packageJson from "../../../package.json";
-
-export type ApplicationInformation = Pick & {
- build: Partial & { publish?: unknown[] };
-};
-
-export const applicationInformationToken = getInjectionToken({
- id: "application-information-token",
-});
diff --git a/packages/core/src/common/vars/application-information.global-override-for-injectable.ts b/packages/core/src/common/vars/application-information.global-override-for-injectable.ts
deleted file mode 100644
index e0b886fa65..0000000000
--- a/packages/core/src/common/vars/application-information.global-override-for-injectable.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Copyright (c) OpenLens Authors. All rights reserved.
- * Licensed under MIT License. See LICENSE in root directory for more information.
- */
-
-import { getGlobalOverride } from "../test-utils/get-global-override";
-import applicationInformationInjectable from "./application-information-injectable";
-
-export default getGlobalOverride(applicationInformationInjectable, () => ({
- name: "some-product-name",
- productName: "some-product-name",
- version: "6.0.0",
- build: {} as any,
- config: {
- k8sProxyVersion: "0.2.1",
- bundledKubectlVersion: "1.23.3",
- bundledHelmVersion: "3.7.2",
- sentryDsn: "",
- contentSecurityPolicy: "script-src 'unsafe-eval' 'self'; frame-src http://*.localhost:*/; img-src * data:",
- welcomeRoute: "/welcome",
- },
- copyright: "some-copyright-information",
- description: "some-descriptive-text",
-}));
diff --git a/packages/core/src/common/vars/bundled-kubectl-version.injectable.ts b/packages/core/src/common/vars/bundled-kubectl-version.injectable.ts
index c15457a2c0..bf3228e44f 100644
--- a/packages/core/src/common/vars/bundled-kubectl-version.injectable.ts
+++ b/packages/core/src/common/vars/bundled-kubectl-version.injectable.ts
@@ -2,12 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "./application-information-token";
const bundledKubectlVersionInjectable = getInjectable({
id: "bundled-kubectl-version",
- instantiate: (di) => di.inject(applicationInformationToken).config.bundledKubectlVersion,
+ instantiate: (di) => di.inject(applicationInformationToken).bundledKubectlVersion,
});
export default bundledKubectlVersionInjectable;
diff --git a/packages/core/src/common/vars/content-security-policy.injectable.ts b/packages/core/src/common/vars/content-security-policy.injectable.ts
index b516571d2f..56d70e3e97 100644
--- a/packages/core/src/common/vars/content-security-policy.injectable.ts
+++ b/packages/core/src/common/vars/content-security-policy.injectable.ts
@@ -2,12 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "./application-information-token";
const contentSecurityPolicyInjectable = getInjectable({
id: "content-security-policy",
- instantiate: (di) => di.inject(applicationInformationToken).config.contentSecurityPolicy,
+ instantiate: (di) => di.inject(applicationInformationToken).contentSecurityPolicy,
});
export default contentSecurityPolicyInjectable;
diff --git a/packages/core/src/common/vars/product-name.injectable.ts b/packages/core/src/common/vars/product-name.injectable.ts
index aa156e427f..6437af3c6c 100644
--- a/packages/core/src/common/vars/product-name.injectable.ts
+++ b/packages/core/src/common/vars/product-name.injectable.ts
@@ -2,8 +2,8 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "./application-information-token";
const productNameInjectable = getInjectable({
id: "product-name",
diff --git a/packages/core/src/common/vars/sentry-dsn-url.injectable.ts b/packages/core/src/common/vars/sentry-dsn-url.injectable.ts
index 1fa48b95f1..0ca6cab9e5 100644
--- a/packages/core/src/common/vars/sentry-dsn-url.injectable.ts
+++ b/packages/core/src/common/vars/sentry-dsn-url.injectable.ts
@@ -2,12 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "./application-information-token";
const sentryDataSourceNameInjectable = getInjectable({
id: "sentry-data-source-name",
- instantiate: (di) => di.inject(applicationInformationToken).config.sentryDsn,
+ instantiate: (di) => di.inject(applicationInformationToken).sentryDsn,
});
export default sentryDataSourceNameInjectable;
diff --git a/packages/core/src/common/vars/store-migration-version.injectable.ts b/packages/core/src/common/vars/store-migration-version.injectable.ts
index 4a4b232da8..6dfbff2e94 100644
--- a/packages/core/src/common/vars/store-migration-version.injectable.ts
+++ b/packages/core/src/common/vars/store-migration-version.injectable.ts
@@ -2,8 +2,8 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "./application-information-token";
const storeMigrationVersionInjectable = getInjectable({
id: "store-migration-version",
diff --git a/packages/core/src/features/application-update/main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable.ts b/packages/core/src/features/application-update/main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable.ts
index 8581cb4860..de451ad5aa 100644
--- a/packages/core/src/features/application-update/main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable.ts
+++ b/packages/core/src/features/application-update/main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable.ts
@@ -2,12 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
+import { applicationInformationToken } from "@k8slens/application";
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "../../../../../common/vars/application-information-token";
const publishIsConfiguredInjectable = getInjectable({
id: "publish-is-configured",
- instantiate: (di) => Boolean(di.inject(applicationInformationToken).build.publish?.length),
+ instantiate: (di) => Boolean(di.inject(applicationInformationToken).updatingIsEnabled),
});
export default publishIsConfiguredInjectable;
diff --git a/packages/core/src/main/cluster/store-migrations/snap.injectable.ts b/packages/core/src/main/cluster/store-migrations/snap.injectable.ts
index e09874c0e5..d4efc37612 100644
--- a/packages/core/src/main/cluster/store-migrations/snap.injectable.ts
+++ b/packages/core/src/main/cluster/store-migrations/snap.injectable.ts
@@ -6,12 +6,12 @@
// Fix embedded kubeconfig paths under snap config
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken } from "../../../common/vars/application-information-token";
import { clusterStoreMigrationInjectionToken } from "../../../common/cluster-store/migration-token";
import loggerInjectable from "../../../common/logger.injectable";
import isSnapPackageInjectable from "../../../common/vars/is-snap-package.injectable";
import type { ClusterModel } from "../../../common/cluster-types";
import pathExistsSyncInjectable from "../../../common/fs/path-exists-sync.injectable";
+import { applicationInformationToken } from "@k8slens/application";
const clusterStoreSnapMigrationInjectable = getInjectable({
id: "cluster-store-snap-migration",
diff --git a/packages/core/src/main/getDi.ts b/packages/core/src/main/getDi.ts
index db7decece8..e325e66ed5 100644
--- a/packages/core/src/main/getDi.ts
+++ b/packages/core/src/main/getDi.ts
@@ -3,15 +3,5 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { createContainer } from "@ogre-tools/injectable";
-import { runInAction } from "mobx";
-import applicationInformationInjectable from "../common/vars/application-information-injectable";
-export const getDi = () => {
- const di = createContainer("main");
-
- runInAction(() => {
- di.register(applicationInformationInjectable);
- });
-
- return di;
-};
+export const getDi = () => createContainer("main");
diff --git a/packages/core/src/main/getDiForUnitTesting.ts b/packages/core/src/main/getDiForUnitTesting.ts
index 1698997e36..5e923433fa 100644
--- a/packages/core/src/main/getDiForUnitTesting.ts
+++ b/packages/core/src/main/getDiForUnitTesting.ts
@@ -29,9 +29,9 @@ import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
import electronInjectable from "./utils/resolve-system-proxy/electron.injectable";
import initializeClusterManagerInjectable from "./cluster/initialize-manager.injectable";
import type { GlobalOverride } from "../common/test-utils/get-global-override";
-import applicationInformationInjectable from "../common/vars/application-information-injectable";
import nodeEnvInjectionToken from "../common/vars/node-env-injection-token";
import { getOverrideFsWithFakes } from "../test-utils/override-fs-with-fakes";
+import { applicationInformationFakeInjectable } from "../common/vars/application-information-fake-injectable";
export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) {
const {
@@ -57,9 +57,10 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {})
.filter(isInjectable)
) as Injectable[];
+ registerMobX(di);
+
runInAction(() => {
- registerMobX(di);
- di.register(applicationInformationInjectable);
+ di.register(applicationInformationFakeInjectable);
chunk(100)(injectables).forEach(chunkInjectables => {
di.register(...chunkInjectables);
diff --git a/packages/core/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts b/packages/core/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts
index 0f8c84668b..b53f58c838 100644
--- a/packages/core/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts
+++ b/packages/core/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts
@@ -13,9 +13,9 @@ import openLinkInBrowserInjectable from "../../../../common/utils/open-link-in-b
import getAbsolutePathInjectable from "../../../../common/path/get-absolute-path.injectable";
import lensResourcesDirInjectable from "../../../../common/vars/lens-resources-dir.injectable";
import isLinuxInjectable from "../../../../common/vars/is-linux.injectable";
-import { applicationInformationToken } from "../../../../common/vars/application-information-token";
import pathExistsSyncInjectable from "../../../../common/fs/path-exists-sync.injectable";
import lensProxyCertificateInjectable from "../../../../common/certificate/lens-proxy-certificate.injectable";
+import { applicationInformationToken } from "@k8slens/application";
export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover";
diff --git a/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts b/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts
index a424743697..2e26f4996b 100644
--- a/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts
+++ b/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts
@@ -7,8 +7,8 @@ import { docsUrl, slackUrl } from "../../../common/vars";
import type { WeblinkData } from "../../../common/weblinks-store/weblink-store";
import { getInjectable } from "@ogre-tools/injectable";
import { weblinkStoreMigrationInjectionToken } from "../../../common/weblinks-store/migration-token";
-import { applicationInformationToken } from "../../../common/vars/application-information-token";
import { lensDocumentationWeblinkId, lensSlackWeblinkId } from "../links";
+import { applicationInformationToken } from "@k8slens/application";
const currentVersionWeblinkStoreMigrationInjectable = getInjectable({
id: "current-version-weblink-store-migration",
diff --git a/packages/core/src/renderer/getDi.tsx b/packages/core/src/renderer/getDi.tsx
index de61d5ab67..77d665760c 100644
--- a/packages/core/src/renderer/getDi.tsx
+++ b/packages/core/src/renderer/getDi.tsx
@@ -4,15 +4,5 @@
*/
import { createContainer } from "@ogre-tools/injectable";
-import { runInAction } from "mobx";
-import applicationInformationInjectable from "../common/vars/application-information-injectable";
-export const getDi = () => {
- const di = createContainer("renderer");
-
- runInAction(() => {
- di.register(applicationInformationInjectable);
- });
-
- return di;
-};
+export const getDi = () => createContainer("renderer");
diff --git a/packages/core/src/renderer/getDiForUnitTesting.tsx b/packages/core/src/renderer/getDiForUnitTesting.tsx
index ac42796d9b..07cc70ef80 100644
--- a/packages/core/src/renderer/getDiForUnitTesting.tsx
+++ b/packages/core/src/renderer/getDiForUnitTesting.tsx
@@ -18,8 +18,8 @@ import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
import watchHistoryStateInjectable from "./remote-helpers/watch-history-state.injectable";
import legacyOnChannelListenInjectable from "./ipc/legacy-channel-listen.injectable";
import type { GlobalOverride } from "../common/test-utils/get-global-override";
-import applicationInformationInjectable from "../common/vars/application-information-injectable";
import nodeEnvInjectionToken from "../common/vars/node-env-injection-token";
+import { applicationInformationFakeInjectable } from "../common/vars/application-information-fake-injectable";
export const getDiForUnitTesting = (
opts: { doGeneralOverrides?: boolean } = {},
@@ -45,9 +45,10 @@ export const getDiForUnitTesting = (
.filter(isInjectable)
) as Injectable[];
+ registerMobX(di);
+
runInAction(() => {
- registerMobX(di);
- di.register(applicationInformationInjectable);
+ di.register(applicationInformationFakeInjectable);
chunk(100)(injectables).forEach((chunkInjectables) => {
di.register(...chunkInjectables);
diff --git a/packages/open-lens/package.json b/packages/open-lens/package.json
index 37ec8cb07b..8507be2395 100644
--- a/packages/open-lens/package.json
+++ b/packages/open-lens/package.json
@@ -195,6 +195,7 @@
}
},
"dependencies": {
+ "@k8slens/application": "^6.4.0-beta.13",
"@k8slens/core": "^6.4.0-beta.13",
"@k8slens/ensure-binaries": "^6.4.0-beta.13",
"@k8slens/generate-tray-icons": "^6.4.0-beta.13",
diff --git a/packages/open-lens/src/common/application-information.injectable.ts b/packages/open-lens/src/common/application-information.injectable.ts
index 603ea171ad..49e95f4bdc 100644
--- a/packages/open-lens/src/common/application-information.injectable.ts
+++ b/packages/open-lens/src/common/application-information.injectable.ts
@@ -1,15 +1,49 @@
-
+/**
+ * Copyright (c) OpenLens Authors. All rights reserved.
+ * Licensed under MIT License. See LICENSE in root directory for more information.
+ */
import { getInjectable } from "@ogre-tools/injectable";
-import { applicationInformationToken, ApplicationInformation } from "@k8slens/core/common";
import packageJson from "../../package.json";
+import { applicationInformationToken } from "@k8slens/application";
const applicationInformationInjectable = getInjectable({
id: "application-information",
injectionToken: applicationInformationToken,
- instantiate: () => {
- const { version, config, productName, build, copyright, description, name } = packageJson;
- return { version, config, productName, build, copyright, description, name } as ApplicationInformation;
+ instantiate: () => {
+ const {
+ version,
+
+ config: {
+ bundledHelmVersion,
+ bundledKubectlVersion,
+ contentSecurityPolicy,
+ k8sProxyVersion,
+ sentryDsn,
+ welcomeRoute,
+ },
+
+ productName,
+ build,
+ copyright,
+ description,
+ name,
+ } = packageJson;
+
+ return {
+ version,
+ productName,
+ copyright,
+ description,
+ name,
+ k8sProxyVersion,
+ bundledKubectlVersion,
+ bundledHelmVersion,
+ sentryDsn,
+ contentSecurityPolicy,
+ welcomeRoute,
+ updatingIsEnabled: (build as any)?.publish?.length > 0,
+ };
},
causesSideEffects: true,
});
diff --git a/packages/technical-features/application/README.md b/packages/technical-features/application/README.md
new file mode 100644
index 0000000000..451e211c85
--- /dev/null
+++ b/packages/technical-features/application/README.md
@@ -0,0 +1,18 @@
+# @k8slens/application
+
+This package contains stuff related to creating Lens-applications.
+
+In the beginning it will contain just the injection tokens used to configure the application.
+
+## Install
+```bash
+$ npm install @k8slens/application
+```
+
+
+## Usage
+
+As of now, this package doesn't do anything alone. It just provides you way to register implementation for contract.
+
+Future ambition is that all stuff related to how applications are built will be relocated here.
+
diff --git a/packages/technical-features/application/index.ts b/packages/technical-features/application/index.ts
new file mode 100644
index 0000000000..8686f83dd1
--- /dev/null
+++ b/packages/technical-features/application/index.ts
@@ -0,0 +1,3 @@
+export { applicationInformationToken } from "./src/application-information-token";
+export type { ApplicationInformation } from "./src/application-information-token";
+
diff --git a/packages/technical-features/application/jest.config.js b/packages/technical-features/application/jest.config.js
new file mode 100644
index 0000000000..23be80353b
--- /dev/null
+++ b/packages/technical-features/application/jest.config.js
@@ -0,0 +1,2 @@
+module.exports =
+ require("@k8slens/jest").monorepoPackageConfig(__dirname).configForReact;
diff --git a/packages/technical-features/application/package.json b/packages/technical-features/application/package.json
new file mode 100644
index 0000000000..e5d08f6c49
--- /dev/null
+++ b/packages/technical-features/application/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "@k8slens/application",
+ "private": false,
+ "version": "6.4.0-beta.13",
+ "description": "Package for creating Lens applications",
+ "type": "commonjs",
+ "files": [
+ "dist"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/lensapp/monorepo.git"
+ },
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts",
+ "author": {
+ "name": "OpenLens Authors",
+ "email": "info@k8slens.dev"
+ },
+ "license": "MIT",
+ "homepage": "https://github.com/lensapp/lens",
+ "scripts": {
+ "build": "lens-build",
+ "build:remove": "lens-remove-build",
+ "code-style:fix": "lens-fix-code-style",
+ "code-style:verify": "lens-verify-code-style",
+ "test": "lens-test"
+ },
+ "peerDependencies": {
+ "@ogre-tools/fp": "^12.0.1",
+ "@ogre-tools/injectable": "^12.0.1",
+ "lodash": "^4.17.15"
+ }
+}
diff --git a/packages/technical-features/application/src/application-information-token.ts b/packages/technical-features/application/src/application-information-token.ts
new file mode 100644
index 0000000000..2f724044c1
--- /dev/null
+++ b/packages/technical-features/application/src/application-information-token.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) OpenLens Authors. All rights reserved.
+ * Licensed under MIT License. See LICENSE in root directory for more information.
+ */
+import { getInjectionToken } from "@ogre-tools/injectable";
+
+export type ApplicationInformation = {
+ name: string;
+ version: string;
+ productName: string;
+ copyright: string;
+ description: string;
+ k8sProxyVersion: string,
+ bundledKubectlVersion: string,
+ bundledHelmVersion: string,
+ sentryDsn: string,
+ contentSecurityPolicy: string,
+ welcomeRoute: string,
+ updatingIsEnabled: boolean;
+}
+
+export const applicationInformationToken = getInjectionToken({
+ id: "application-information-token",
+});
diff --git a/packages/technical-features/application/tsconfig.json b/packages/technical-features/application/tsconfig.json
new file mode 100644
index 0000000000..a4f6fa613e
--- /dev/null
+++ b/packages/technical-features/application/tsconfig.json
@@ -0,0 +1,3 @@
+{
+ "extends": "@k8slens/typescript/config/base.json"
+}
diff --git a/packages/technical-features/application/webpack.config.js b/packages/technical-features/application/webpack.config.js
new file mode 100644
index 0000000000..3183f30179
--- /dev/null
+++ b/packages/technical-features/application/webpack.config.js
@@ -0,0 +1 @@
+module.exports = require("@k8slens/webpack").configForNode;
From f212c90b1ab1a30eef244283bda19ba4e067fe8f Mon Sep 17 00:00:00 2001
From: Sebastian Malton
Date: Wed, 22 Feb 2023 09:37:53 -0800
Subject: [PATCH 02/21] Remove notarize as unused (#7215)
* Remove notarize as unused
Signed-off-by: Sebastian Malton
* Remove electron-notarize
Signed-off-by: Sebastian Malton
---------
Signed-off-by: Sebastian Malton
---
package-lock.json | 1 -
packages/core/build/notarize.js | 27 ---------------------------
packages/core/package.json | 1 -
3 files changed, 29 deletions(-)
delete mode 100644 packages/core/build/notarize.js
diff --git a/package-lock.json b/package-lock.json
index f5e29555c3..6cea9cb6b0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -32400,7 +32400,6 @@
"dompurify": "^2.4.4",
"electron": "^19.1.9",
"electron-builder": "^23.6.0",
- "electron-notarize": "^0.3.0",
"esbuild": "^0.17.8",
"esbuild-loader": "^2.21.0",
"eslint": "^8.33.0",
diff --git a/packages/core/build/notarize.js b/packages/core/build/notarize.js
deleted file mode 100644
index 0bf1903e59..0000000000
--- a/packages/core/build/notarize.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (c) OpenLens Authors. All rights reserved.
- * Licensed under MIT License. See LICENSE in root directory for more information.
- */
-const { notarize } = require("electron-notarize");
-
-exports.default = async function notarizing(context) {
- const { electronPlatformName, appOutDir } = context;
-
- if (electronPlatformName !== "darwin") {
- return;
- }
-
- if (!process.env.APPLEID || !process.env.APPLEIDPASS) {
- return;
- }
-
- const appName = context.packager.appInfo.productFilename;
-
- return await notarize({
- appBundleId: process.env.APPBUNDLEID || "io.kontena.lens-app",
- appPath: `${appOutDir}/${appName}.app`,
- appleId: process.env.APPLEID,
- appleIdPassword: process.env.APPLEIDPASS,
- ascProvider:process.env.ASCPROVIDER,
- });
-};
diff --git a/packages/core/package.json b/packages/core/package.json
index f6d58909aa..476100d9bf 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -268,7 +268,6 @@
"dompurify": "^2.4.4",
"electron": "^19.1.9",
"electron-builder": "^23.6.0",
- "electron-notarize": "^0.3.0",
"esbuild": "^0.17.8",
"esbuild-loader": "^2.21.0",
"eslint": "^8.33.0",
From a7181047d5b241ac6c41d056289ab9419e769360 Mon Sep 17 00:00:00 2001
From: Janne Savolainen
Date: Thu, 23 Feb 2023 10:54:35 +0200
Subject: [PATCH 03/21] Fix windows not being able to build new Feature
packages (#7220)
* Add missing dev script
Signed-off-by: Janne Savolainen
* Inline all shared scripts to make them work in all environments
Signed-off-by: Janne Savolainen
* Switch to using deterministic fake for path.join in unit test
Signed-off-by: Janne Savolainen
* Make multi export config for webpack not fail when used in windows
Signed-off-by: Janne Savolainen
---------
Signed-off-by: Janne Savolainen
---
package-lock.json | 7 -------
packages/infrastructure/jest/package.json | 3 ---
packages/infrastructure/webpack/bin/build.sh | 2 --
packages/infrastructure/webpack/bin/remove-build.sh | 1 -
packages/infrastructure/webpack/package.json | 6 +-----
.../webpack/src/get-multi-export-config.js | 10 ++++++----
.../webpack/src/get-multi-export-config.test.js | 10 ++++++++++
packages/technical-features/application/package.json | 8 +++-----
8 files changed, 20 insertions(+), 27 deletions(-)
delete mode 100755 packages/infrastructure/webpack/bin/build.sh
delete mode 100755 packages/infrastructure/webpack/bin/remove-build.sh
diff --git a/package-lock.json b/package-lock.json
index 6cea9cb6b0..24cae086b2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -32832,9 +32832,6 @@
"jest-watch-typeahead": "^2.2.1",
"lodash": "^4.17.21",
"ts-jest": "^29.0.3"
- },
- "bin": {
- "lens-test": "bin/test.sh"
}
},
"packages/infrastructure/jest/node_modules/@jest/console": {
@@ -34112,10 +34109,6 @@
"webpack": "^5.75.0",
"webpack-cli": "^4.10.0",
"webpack-node-externals": "^3.0.0"
- },
- "bin": {
- "lens-build": "bin/build.sh",
- "lens-remove-build": "bin/remove-build.sh"
}
},
"packages/infrastructure/webpack/node_modules/sass-loader": {
diff --git a/packages/infrastructure/jest/package.json b/packages/infrastructure/jest/package.json
index b0359441dd..b6e00d1369 100644
--- a/packages/infrastructure/jest/package.json
+++ b/packages/infrastructure/jest/package.json
@@ -15,9 +15,6 @@
},
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
- "bin": {
- "lens-test": "bin/test.sh"
- },
"dependencies": {
"@swc/core": "^1.3.20",
"@swc/jest": "^0.2.23",
diff --git a/packages/infrastructure/webpack/bin/build.sh b/packages/infrastructure/webpack/bin/build.sh
deleted file mode 100755
index 589acdeab2..0000000000
--- a/packages/infrastructure/webpack/bin/build.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-set -e
-webpack $@
diff --git a/packages/infrastructure/webpack/bin/remove-build.sh b/packages/infrastructure/webpack/bin/remove-build.sh
deleted file mode 100755
index f2421c500d..0000000000
--- a/packages/infrastructure/webpack/bin/remove-build.sh
+++ /dev/null
@@ -1 +0,0 @@
-rm -rfv build
diff --git a/packages/infrastructure/webpack/package.json b/packages/infrastructure/webpack/package.json
index 35df41519c..2539a99bb8 100644
--- a/packages/infrastructure/webpack/package.json
+++ b/packages/infrastructure/webpack/package.json
@@ -15,12 +15,8 @@
},
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
- "bin": {
- "lens-build": "bin/build.sh",
- "lens-remove-build": "bin/remove-build.sh"
- },
"scripts": {
- "test:unit": "lens-test"
+ "test:unit": "jest --coverage --runInBand"
},
"dependencies": {
"@types/webpack-env": "^1.18.0",
diff --git a/packages/infrastructure/webpack/src/get-multi-export-config.js b/packages/infrastructure/webpack/src/get-multi-export-config.js
index 02944c25d3..338b3d89d7 100644
--- a/packages/infrastructure/webpack/src/get-multi-export-config.js
+++ b/packages/infrastructure/webpack/src/get-multi-export-config.js
@@ -14,7 +14,7 @@ const {
} = require("lodash/fp");
const { pipeline } = require("@ogre-tools/fp");
-module.exports = (packageJson, dependencies = { nodeConfig, reactConfig }) => {
+module.exports = (packageJson, dependencies = { nodeConfig, reactConfig, joinPath: path.join }) => {
if (!packageJson.lensMultiExportConfig) {
throw new Error(
`Tried to get multi export config for package "${packageJson.name}" but configuration is missing.`
@@ -80,7 +80,9 @@ module.exports = (packageJson, dependencies = { nodeConfig, reactConfig }) => {
};
const toExpectedExport = (externalImportPath) => {
- const entrypointPath = `./${path.join(
+ const posixJoinForPackageJson = path.posix.join;
+
+ const entrypointPath = `./${posixJoinForPackageJson(
"./dist",
externalImportPath,
"index.js"
@@ -89,7 +91,7 @@ const toExpectedExport = (externalImportPath) => {
return [
externalImportPath,
{
- types: `./${path.join("./dist", externalImportPath, "index.d.ts")}`,
+ types: `./${posixJoinForPackageJson("./dist", externalImportPath, "index.d.ts")}`,
default: entrypointPath,
import: entrypointPath,
@@ -114,7 +116,7 @@ const toExportSpecificWebpackConfigFor =
output: {
...baseConfig.output,
- path: path.join(baseConfig.output.path, externalImportPath),
+ path: dependencies.joinPath(baseConfig.output.path, externalImportPath),
},
};
};
diff --git a/packages/infrastructure/webpack/src/get-multi-export-config.test.js b/packages/infrastructure/webpack/src/get-multi-export-config.test.js
index 6cad83919f..b0ce1c2231 100644
--- a/packages/infrastructure/webpack/src/get-multi-export-config.test.js
+++ b/packages/infrastructure/webpack/src/get-multi-export-config.test.js
@@ -1,4 +1,7 @@
import getMultiExportConfig from "./get-multi-export-config";
+import path from 'path';
+
+const joinPathFake = path.posix.join;
describe("get-multi-export-config", () => {
let actual;
@@ -52,6 +55,7 @@ describe("get-multi-export-config", () => {
actual = getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
+ joinPath: joinPathFake,
});
expect(actual).toEqual([
@@ -93,6 +97,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
+ joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@@ -106,6 +111,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
+ joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@@ -119,6 +125,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
+ joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config but exports of package.json for "some-name" did not match exactly:'
@@ -132,6 +139,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
+ joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config for package "some-name" but configuration is missing.'
@@ -145,6 +153,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
+ joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config for package "some-name" but build types "some-invalid" were not any of "node", "react".'
@@ -159,6 +168,7 @@ describe("get-multi-export-config", () => {
getMultiExportConfig(maximalPackageJson, {
nodeConfig: nodeConfigStub,
reactConfig: reactConfigStub,
+ joinPath: joinPathFake,
});
}).toThrow(
'Tried to get multi export config for package "some-name" but entrypoint was missing for "./some-entrypoint".'
diff --git a/packages/technical-features/application/package.json b/packages/technical-features/application/package.json
index e5d08f6c49..91f1a6be34 100644
--- a/packages/technical-features/application/package.json
+++ b/packages/technical-features/application/package.json
@@ -20,11 +20,9 @@
"license": "MIT",
"homepage": "https://github.com/lensapp/lens",
"scripts": {
- "build": "lens-build",
- "build:remove": "lens-remove-build",
- "code-style:fix": "lens-fix-code-style",
- "code-style:verify": "lens-verify-code-style",
- "test": "lens-test"
+ "build": "webpack",
+ "dev": "webpack --mode=development --watch",
+ "test": "jest --coverage --runInBand"
},
"peerDependencies": {
"@ogre-tools/fp": "^12.0.1",
From 898b9039dac07341b42f69df3bc91c47c45c8df8 Mon Sep 17 00:00:00 2001
From: Janne Savolainen
Date: Thu, 23 Feb 2023 13:41:19 +0200
Subject: [PATCH 04/21] Add publish configuration to packages that are public
(#7221)
Signed-off-by: Janne Savolainen
---
packages/infrastructure/jest/package.json | 4 ++++
packages/infrastructure/typescript/package.json | 4 ++++
packages/infrastructure/webpack/package.json | 4 ++++
packages/technical-features/application/package.json | 4 ++++
4 files changed, 16 insertions(+)
diff --git a/packages/infrastructure/jest/package.json b/packages/infrastructure/jest/package.json
index b6e00d1369..6f5ff7c642 100644
--- a/packages/infrastructure/jest/package.json
+++ b/packages/infrastructure/jest/package.json
@@ -4,6 +4,10 @@
"version": "0.0.1",
"description": "Jest configuration and scripts for Lens packages.",
"type": "commonjs",
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
+ },
"repository": {
"type": "git",
"url": "git+https://github.com/lensapp/lens.git"
diff --git a/packages/infrastructure/typescript/package.json b/packages/infrastructure/typescript/package.json
index 918e996042..3469151044 100644
--- a/packages/infrastructure/typescript/package.json
+++ b/packages/infrastructure/typescript/package.json
@@ -4,6 +4,10 @@
"version": "0.0.1",
"description": "Typescript configuration for Lens packages.",
"type": "commonjs",
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
+ },
"repository": {
"type": "git",
"url": "git+https://github.com/lensapp/lens.git"
diff --git a/packages/infrastructure/webpack/package.json b/packages/infrastructure/webpack/package.json
index 2539a99bb8..e79c257f26 100644
--- a/packages/infrastructure/webpack/package.json
+++ b/packages/infrastructure/webpack/package.json
@@ -4,6 +4,10 @@
"version": "0.0.1",
"description": "Webpack configurations and scripts for Lens packages.",
"type": "commonjs",
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
+ },
"repository": {
"type": "git",
"url": "git+https://github.com/lensapp/lens.git"
diff --git a/packages/technical-features/application/package.json b/packages/technical-features/application/package.json
index 91f1a6be34..a78de4da0e 100644
--- a/packages/technical-features/application/package.json
+++ b/packages/technical-features/application/package.json
@@ -7,6 +7,10 @@
"files": [
"dist"
],
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
+ },
"repository": {
"type": "git",
"url": "git+https://github.com/lensapp/monorepo.git"
From 2550b1efbd4ae31f277ffbfef008fb467d4c0ba6 Mon Sep 17 00:00:00 2001
From: Juho Heikka
Date: Thu, 23 Feb 2023 16:03:45 +0200
Subject: [PATCH 05/21] Fix catalog avatar font size (#7226)
Signed-off-by: Juho Heikka
---
.../core/src/renderer/components/+catalog/catalog.module.scss | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/core/src/renderer/components/+catalog/catalog.module.scss b/packages/core/src/renderer/components/+catalog/catalog.module.scss
index 74e4bcc80f..4fe31c4f27 100644
--- a/packages/core/src/renderer/components/+catalog/catalog.module.scss
+++ b/packages/core/src/renderer/components/+catalog/catalog.module.scss
@@ -127,7 +127,7 @@
}
.catalogAvatar {
- font-size: 1.2ch;
+ font-size: 1.2ch !important;
}
.views {
From f2a229cef6107c99b8b61b9bbc4e566ee21f8358 Mon Sep 17 00:00:00 2001
From: Sebastian Malton
Date: Fri, 24 Feb 2023 07:44:19 -0800
Subject: [PATCH 06/21] Fix ApiManager not handling duplicate apiBases of
KubeApis (#7235)
* Add failing unit test
Signed-off-by: Sebastian Malton
* Fix failing unit test
Signed-off-by: Sebastian Malton
---------
Signed-off-by: Sebastian Malton
---
.../k8s-api/__tests__/api-manager.test.ts | 38 +++++++++++++++++--
.../common/k8s-api/api-manager/api-manager.ts | 9 +++--
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/packages/core/src/common/k8s-api/__tests__/api-manager.test.ts b/packages/core/src/common/k8s-api/__tests__/api-manager.test.ts
index b83f52c3f0..2e7e545f76 100644
--- a/packages/core/src/common/k8s-api/__tests__/api-manager.test.ts
+++ b/packages/core/src/common/k8s-api/__tests__/api-manager.test.ts
@@ -19,6 +19,9 @@ import { KubeObject } from "../kube-object";
import { KubeObjectStore } from "../kube-object.store";
import maybeKubeApiInjectable from "../maybe-kube-api.injectable";
+// eslint-disable-next-line no-restricted-imports
+import { KubeApi as ExternalKubeApi } from "../../../extensions/common-api/k8s-api";
+
class TestApi extends KubeApi {
protected async checkPreferredVersion() {
return;
@@ -54,7 +57,7 @@ describe("ApiManager", () => {
});
describe("registerApi", () => {
- it("re-register store if apiBase changed", async () => {
+ it("re-register store if apiBase changed", () => {
const apiBase = "apis/v1/foo";
const fallbackApiBase = "/apis/extensions/v1beta1/foo";
const kubeApi = new TestApi({
@@ -72,21 +75,48 @@ describe("ApiManager", () => {
logger: di.inject(loggerInjectable),
}, kubeApi);
- apiManager.registerApi(apiBase, kubeApi);
+ apiManager.registerApi(kubeApi);
// Define to use test api for ingress store
Object.defineProperty(kubeStore, "api", { value: kubeApi });
- apiManager.registerStore(kubeStore, [kubeApi]);
+ apiManager.registerStore(kubeStore);
// Test that store is returned with original apiBase
expect(apiManager.getStore(kubeApi)).toBe(kubeStore);
// Change apiBase similar as checkPreferredVersion does
Object.defineProperty(kubeApi, "apiBase", { value: fallbackApiBase });
- apiManager.registerApi(fallbackApiBase, kubeApi);
+ apiManager.registerApi(kubeApi);
// Test that store is returned with new apiBase
expect(apiManager.getStore(kubeApi)).toBe(kubeStore);
});
});
+
+ describe("technical tests for autorun", () => {
+ it("given two extensions register apis with the same apibase, settle into using the second", () => {
+ const apiBase = "/apis/aquasecurity.github.io/v1alpha1/vulnerabilityreports";
+ const firstApi = Object.assign(new ExternalKubeApi({
+ objectConstructor: KubeObject,
+ apiBase,
+ kind: "VulnerabilityReport",
+ }), {
+ myField: 1,
+ });
+ const secondApi = Object.assign(new ExternalKubeApi({
+ objectConstructor: KubeObject,
+ apiBase,
+ kind: "VulnerabilityReport",
+ }), {
+ myField: 2,
+ });
+
+ void firstApi;
+ void secondApi;
+
+ expect(apiManager.getApi(apiBase)).toMatchObject({
+ myField: 2,
+ });
+ });
+ });
});
diff --git a/packages/core/src/common/k8s-api/api-manager/api-manager.ts b/packages/core/src/common/k8s-api/api-manager/api-manager.ts
index 81b59ef9c2..0dad9a2a21 100644
--- a/packages/core/src/common/k8s-api/api-manager/api-manager.ts
+++ b/packages/core/src/common/k8s-api/api-manager/api-manager.ts
@@ -41,19 +41,22 @@ export class ApiManager {
const apis = chain(this.dependencies.apis.get().values())
.concat(this.externalApis.values());
const removedApis = new Set(this.apis.values());
+ const newState = new Map(this.apis);
for (const api of apis) {
removedApis.delete(api);
- this.apis.set(api.apiBase, api);
+ newState.set(api.apiBase, api);
}
for (const api of removedApis) {
- for (const [apiBase, storedApi] of this.apis) {
+ for (const [apiBase, storedApi] of newState) {
if (storedApi === api) {
- this.apis.delete(apiBase);
+ newState.delete(apiBase);
}
}
}
+
+ this.apis.replace(newState);
});
}
From dc39dc9c62e85f99695b0aeeb93760f8ff073a1d Mon Sep 17 00:00:00 2001
From: Sebastian Malton
Date: Fri, 24 Feb 2023 07:44:35 -0800
Subject: [PATCH 07/21] Allow extensions to opt-out of KubeApi auto registering
(#7217)
Signed-off-by: Sebastian Malton
---
.../core/src/extensions/common-api/k8s-api.ts | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/packages/core/src/extensions/common-api/k8s-api.ts b/packages/core/src/extensions/common-api/k8s-api.ts
index 0b9a05353f..20e687ff6d 100644
--- a/packages/core/src/extensions/common-api/k8s-api.ts
+++ b/packages/core/src/extensions/common-api/k8s-api.ts
@@ -47,17 +47,29 @@ const getKubeApiDeps = (): KubeApiDependencies => {
};
};
+export interface ExternalKubeApiOptions {
+ /**
+ * If `true` then on creation of the `KubeApi`instance a call to `apiManager.registerApi` will be
+ * made. This is `true` by default to maintain backwards compatability.
+ *
+ * Setting this to `false` might make `KubeObject`'s details drawer stop working.
+ *
+ * @default true
+ */
+ autoRegister?: boolean;
+}
+
// NOTE: this is done to preserve `instanceOf` behaviour
function KubeApiCstr<
Object extends KubeObject = KubeObject,
Data extends KubeJsonApiDataFor
diff --git a/packages/core/src/features/__snapshots__/navigate-to-extension-page.test.tsx.snap b/packages/core/src/features/__snapshots__/navigate-to-extension-page.test.tsx.snap
index b66ac6c4b3..5a864f8096 100644
--- a/packages/core/src/features/__snapshots__/navigate-to-extension-page.test.tsx.snap
+++ b/packages/core/src/features/__snapshots__/navigate-to-extension-page.test.tsx.snap
@@ -107,11 +107,11 @@ exports[`navigate to extension page renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap b/packages/core/src/features/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap
index 28cdcc4b8d..4bd662e2f0 100644
--- a/packages/core/src/features/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap
+++ b/packages/core/src/features/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap
@@ -107,11 +107,11 @@ exports[`add-cluster - navigation using application menu renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap b/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap
index 6e61ea5e5d..0b32c94831 100644
--- a/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap
+++ b/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap
@@ -108,11 +108,11 @@ exports[`installing update when started renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -393,11 +393,11 @@ exports[`installing update when started when user checks for updates renders 1`]
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -678,11 +678,11 @@ exports[`installing update when started when user checks for updates when new up
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -988,11 +988,11 @@ exports[`installing update when started when user checks for updates when new up
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1298,11 +1298,11 @@ exports[`installing update when started when user checks for updates when new up
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1583,11 +1583,11 @@ exports[`installing update when started when user checks for updates when no new
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/application-update/child-features/application-update-using-top-bar/__snapshots__/installing-update-using-topbar-button.test.tsx.snap b/packages/core/src/features/application-update/child-features/application-update-using-top-bar/__snapshots__/installing-update-using-topbar-button.test.tsx.snap
index a4787d0de3..26fd923e16 100644
--- a/packages/core/src/features/application-update/child-features/application-update-using-top-bar/__snapshots__/installing-update-using-topbar-button.test.tsx.snap
+++ b/packages/core/src/features/application-update/child-features/application-update-using-top-bar/__snapshots__/installing-update-using-topbar-button.test.tsx.snap
@@ -133,11 +133,11 @@ exports[`encourage user to update when sufficient time passed since update was d
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -418,11 +418,11 @@ exports[`encourage user to update when sufficient time passed since update was d
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/application-update/child-features/application-update-using-tray/__snapshots__/installing-update-using-tray.test.ts.snap b/packages/core/src/features/application-update/child-features/application-update-using-tray/__snapshots__/installing-update-using-tray.test.ts.snap
index a2ea7a417b..57b2dd6f48 100644
--- a/packages/core/src/features/application-update/child-features/application-update-using-tray/__snapshots__/installing-update-using-tray.test.ts.snap
+++ b/packages/core/src/features/application-update/child-features/application-update-using-tray/__snapshots__/installing-update-using-tray.test.ts.snap
@@ -108,11 +108,11 @@ exports[`installing update using tray when started renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -393,11 +393,11 @@ exports[`installing update using tray when started when user checks for updates
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -678,11 +678,11 @@ exports[`installing update using tray when started when user checks for updates
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -988,11 +988,11 @@ exports[`installing update using tray when started when user checks for updates
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1298,11 +1298,11 @@ exports[`installing update using tray when started when user checks for updates
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1583,11 +1583,11 @@ exports[`installing update using tray when started when user checks for updates
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/application-update/child-features/force-update/__snapshots__/force-update.test.ts.snap b/packages/core/src/features/application-update/child-features/force-update/__snapshots__/force-update.test.ts.snap
index 95101e8294..5dd749857a 100644
--- a/packages/core/src/features/application-update/child-features/force-update/__snapshots__/force-update.test.ts.snap
+++ b/packages/core/src/features/application-update/child-features/force-update/__snapshots__/force-update.test.ts.snap
@@ -133,11 +133,11 @@ exports[`force user to update when too long since update was downloaded when app
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -443,11 +443,11 @@ exports[`force user to update when too long since update was downloaded when app
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -800,11 +800,11 @@ exports[`force user to update when too long since update was downloaded when app
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/__snapshots__/periodical-checking-of-updates.test.ts.snap b/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/__snapshots__/periodical-checking-of-updates.test.ts.snap
index 413477ef9a..e6ae682c92 100644
--- a/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/__snapshots__/periodical-checking-of-updates.test.ts.snap
+++ b/packages/core/src/features/application-update/child-features/periodical-checking-of-updates/__snapshots__/periodical-checking-of-updates.test.ts.snap
@@ -108,11 +108,11 @@ exports[`periodical checking of updates given updater is enabled and configurati
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/application-update/child-features/selection-of-update-stability/__snapshots__/selection-of-update-stability.test.ts.snap b/packages/core/src/features/application-update/child-features/selection-of-update-stability/__snapshots__/selection-of-update-stability.test.ts.snap
index 7da7f42004..9e77201bf3 100644
--- a/packages/core/src/features/application-update/child-features/selection-of-update-stability/__snapshots__/selection-of-update-stability.test.ts.snap
+++ b/packages/core/src/features/application-update/child-features/selection-of-update-stability/__snapshots__/selection-of-update-stability.test.ts.snap
@@ -108,11 +108,11 @@ exports[`selection of update stability when started renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap b/packages/core/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap
index 49d085fc85..c7b284a08e 100644
--- a/packages/core/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap
+++ b/packages/core/src/features/catalog/__snapshots__/opening-entity-details.test.tsx.snap
@@ -108,11 +108,11 @@ exports[`opening catalog entity details panel renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/command-pallet/__snapshots__/keyboard-shortcuts.test.tsx.snap b/packages/core/src/features/command-pallet/__snapshots__/keyboard-shortcuts.test.tsx.snap
index cbe09a0e1c..0269032531 100644
--- a/packages/core/src/features/command-pallet/__snapshots__/keyboard-shortcuts.test.tsx.snap
+++ b/packages/core/src/features/command-pallet/__snapshots__/keyboard-shortcuts.test.tsx.snap
@@ -199,11 +199,11 @@ exports[`Command Pallet: keyboard shortcut tests when on linux renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -575,11 +575,11 @@ exports[`Command Pallet: keyboard shortcut tests when on linux when pressing ESC
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -951,11 +951,11 @@ exports[`Command Pallet: keyboard shortcut tests when on linux when pressing SHI
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1339,11 +1339,11 @@ exports[`Command Pallet: keyboard shortcut tests when on linux when pressing SHI
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1624,11 +1624,11 @@ exports[`Command Pallet: keyboard shortcut tests when on macOS renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1909,11 +1909,11 @@ exports[`Command Pallet: keyboard shortcut tests when on macOS when pressing ESC
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -2194,11 +2194,11 @@ exports[`Command Pallet: keyboard shortcut tests when on macOS when pressing SHI
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -2491,11 +2491,11 @@ exports[`Command Pallet: keyboard shortcut tests when on macOS when pressing SHI
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/entity-settings/__snapshots__/showing-settings-for-correct-entity.test.tsx.snap b/packages/core/src/features/entity-settings/__snapshots__/showing-settings-for-correct-entity.test.tsx.snap
index a61803d059..d176bb9f7d 100644
--- a/packages/core/src/features/entity-settings/__snapshots__/showing-settings-for-correct-entity.test.tsx.snap
+++ b/packages/core/src/features/entity-settings/__snapshots__/showing-settings-for-correct-entity.test.tsx.snap
@@ -108,11 +108,11 @@ exports[`Showing correct entity settings renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap b/packages/core/src/features/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap
index 56aa157f99..53dc28e961 100644
--- a/packages/core/src/features/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap
+++ b/packages/core/src/features/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap
@@ -107,11 +107,11 @@ exports[`extensions - navigation using application menu renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/preferences/__snapshots__/navigation-using-application-menu.test.ts.snap b/packages/core/src/features/preferences/__snapshots__/navigation-using-application-menu.test.ts.snap
index 8fd3eddd42..855c4c54eb 100644
--- a/packages/core/src/features/preferences/__snapshots__/navigation-using-application-menu.test.ts.snap
+++ b/packages/core/src/features/preferences/__snapshots__/navigation-using-application-menu.test.ts.snap
@@ -107,11 +107,11 @@ exports[`preferences - navigation using application menu renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/preferences/__snapshots__/navigation-using-tray.test.ts.snap b/packages/core/src/features/preferences/__snapshots__/navigation-using-tray.test.ts.snap
index 5a65444e9b..c0ab06204e 100644
--- a/packages/core/src/features/preferences/__snapshots__/navigation-using-tray.test.ts.snap
+++ b/packages/core/src/features/preferences/__snapshots__/navigation-using-tray.test.ts.snap
@@ -108,11 +108,11 @@ exports[`show-about-using-tray renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/status-bar/__snapshots__/status-bar-items-originating-from-extensions.test.tsx.snap b/packages/core/src/features/status-bar/__snapshots__/status-bar-items-originating-from-extensions.test.tsx.snap
index 72291a5587..f652074bf8 100644
--- a/packages/core/src/features/status-bar/__snapshots__/status-bar-items-originating-from-extensions.test.tsx.snap
+++ b/packages/core/src/features/status-bar/__snapshots__/status-bar-items-originating-from-extensions.test.tsx.snap
@@ -108,11 +108,11 @@ exports[`status-bar-items-originating-from-extensions when application starts wh
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/top-bar/extension-api/__snapshots__/extendability-using-extension-api.test.tsx.snap b/packages/core/src/features/top-bar/extension-api/__snapshots__/extendability-using-extension-api.test.tsx.snap
index ed49317fcb..179c2bf3f1 100644
--- a/packages/core/src/features/top-bar/extension-api/__snapshots__/extendability-using-extension-api.test.tsx.snap
+++ b/packages/core/src/features/top-bar/extension-api/__snapshots__/extendability-using-extension-api.test.tsx.snap
@@ -108,11 +108,11 @@ exports[`extendability-using-extension-api given an extension with a weakly type
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -402,11 +402,11 @@ exports[`extendability-using-extension-api given an extension with top-bar items
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -687,11 +687,11 @@ exports[`extendability-using-extension-api given an extension with top-bar items
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -972,11 +972,11 @@ exports[`extendability-using-extension-api renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/features/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap b/packages/core/src/features/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap
index 610e62e091..4016a617c3 100644
--- a/packages/core/src/features/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap
+++ b/packages/core/src/features/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap
@@ -107,11 +107,11 @@ exports[`welcome - navigation using application menu renders 1`] = `
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
@@ -1142,11 +1142,11 @@ exports[`welcome - navigation using application menu when navigated somewhere el
If you have any questions or feedback, please join our
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/main/weblinks-store/links.ts b/packages/core/src/main/weblinks-store/links.ts
index ae53b6ec27..a19e7f7548 100644
--- a/packages/core/src/main/weblinks-store/links.ts
+++ b/packages/core/src/main/weblinks-store/links.ts
@@ -10,8 +10,8 @@ export const lensWebsiteLinkName = "Lens Website";
export const lensDocumentationWeblinkId = "lens-documentation-link";
export const lensDocumentationWeblinkName = "Lens Documentation";
-export const lensSlackWeblinkId = "lens-slack-link";
-export const lensSlackWeblinkName = "Lens Community Slack";
+export const lensForumsWeblinkId = "lens-forums-link";
+export const lensForumsWeblinkName = "Lens Forums";
export const lensTwitterWeblinkId = "lens-twitter-link";
export const lensTwitterWeblinkName = "Lens on Twitter";
diff --git a/packages/core/src/main/weblinks-store/migrations/5.1.4.injectable.ts b/packages/core/src/main/weblinks-store/migrations/5.1.4.injectable.ts
index fe27b9ae3e..000937abba 100644
--- a/packages/core/src/main/weblinks-store/migrations/5.1.4.injectable.ts
+++ b/packages/core/src/main/weblinks-store/migrations/5.1.4.injectable.ts
@@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
-import { docsUrl, slackUrl } from "../../../common/vars";
+import { docsUrl, forumsUrl } from "../../../common/vars";
import type { WeblinkData } from "../../../common/weblinks-store/weblink-store";
import { getInjectable } from "@ogre-tools/injectable";
import { weblinkStoreMigrationInjectionToken } from "../../../common/weblinks-store/migration-token";
@@ -20,7 +20,7 @@ const v514WeblinkStoreMigrationInjectable = getInjectable({
weblinks.push(
{ id: "https://k8slens.dev", name: links.lensWebsiteLinkName, url: "https://k8slens.dev" },
{ id: docsUrl, name: links.lensDocumentationWeblinkName, url: docsUrl },
- { id: slackUrl, name: links.lensSlackWeblinkName, url: slackUrl },
+ { id: forumsUrl, name: links.lensForumsWeblinkName, url: forumsUrl },
{ id: "https://twitter.com/k8slens", name: links.lensTwitterWeblinkName, url: "https://twitter.com/k8slens" },
{ id: "https://medium.com/k8slens", name: links.lensBlogWeblinkName, url: "https://medium.com/k8slens" },
{ id: "https://kubernetes.io/docs/home/", name: links.kubernetesDocumentationWeblinkName, url: "https://kubernetes.io/docs/home/" },
diff --git a/packages/core/src/main/weblinks-store/migrations/5.4.5-beta.1.injectable.ts b/packages/core/src/main/weblinks-store/migrations/5.4.5-beta.1.injectable.ts
index dbe580bec3..fc67e4a2f5 100644
--- a/packages/core/src/main/weblinks-store/migrations/5.4.5-beta.1.injectable.ts
+++ b/packages/core/src/main/weblinks-store/migrations/5.4.5-beta.1.injectable.ts
@@ -16,40 +16,40 @@ const v545Beta1WeblinkStoreMigrationInjectable = getInjectable({
const weblinksRaw = store.get("weblinks");
const weblinks = (Array.isArray(weblinksRaw) ? weblinksRaw : []) as WeblinkData[];
- const lensWebsiteLink = weblinks.find(weblink => weblink.name === links.lensWebsiteLinkName);
+ const lensWebsite = weblinks.find(weblink => weblink.name === links.lensWebsiteLinkName);
- if (lensWebsiteLink) {
- lensWebsiteLink.id = links.lensWebsiteWeblinkId;
+ if (lensWebsite) {
+ lensWebsite.id = links.lensWebsiteWeblinkId;
}
- const lensDocumentationWeblinkLink = weblinks.find(weblink => weblink.name === links.lensDocumentationWeblinkName);
+ const lensDocumentationWeblink = weblinks.find(weblink => weblink.name === links.lensDocumentationWeblinkName);
- if (lensDocumentationWeblinkLink) {
- lensDocumentationWeblinkLink.id = links.lensDocumentationWeblinkId;
+ if (lensDocumentationWeblink) {
+ lensDocumentationWeblink.id = links.lensDocumentationWeblinkId;
}
- const lensSlackWeblinkLink = weblinks.find(weblink => weblink.name === links.lensSlackWeblinkName);
+ const lensForumsWeblink = weblinks.find(weblink => weblink.name === links.lensForumsWeblinkName);
- if (lensSlackWeblinkLink) {
- lensSlackWeblinkLink.id = links.lensSlackWeblinkId;
+ if (lensForumsWeblink) {
+ lensForumsWeblink.id = links.lensForumsWeblinkId;
}
- const lensTwitterWeblinkLink = weblinks.find(weblink => weblink.name === links.lensTwitterWeblinkName);
+ const lensTwitterWeblink = weblinks.find(weblink => weblink.name === links.lensTwitterWeblinkName);
- if (lensTwitterWeblinkLink) {
- lensTwitterWeblinkLink.id = links.lensTwitterWeblinkId;
+ if (lensTwitterWeblink) {
+ lensTwitterWeblink.id = links.lensTwitterWeblinkId;
}
- const lensBlogWeblinkLink = weblinks.find(weblink => weblink.name === links.lensBlogWeblinkName);
+ const lensBlogWeblink = weblinks.find(weblink => weblink.name === links.lensBlogWeblinkName);
- if (lensBlogWeblinkLink) {
- lensBlogWeblinkLink.id = links.lensBlogWeblinkId;
+ if (lensBlogWeblink) {
+ lensBlogWeblink.id = links.lensBlogWeblinkId;
}
- const kubernetesDocumentationWeblinkLink = weblinks.find(weblink => weblink.name === links.kubernetesDocumentationWeblinkName);
+ const kubernetesDocumentationWeblink = weblinks.find(weblink => weblink.name === links.kubernetesDocumentationWeblinkName);
- if (kubernetesDocumentationWeblinkLink) {
- kubernetesDocumentationWeblinkLink.id = links.kubernetesDocumentationWeblinkId;
+ if (kubernetesDocumentationWeblink) {
+ kubernetesDocumentationWeblink.id = links.kubernetesDocumentationWeblinkId;
}
store.set("weblinks", weblinks);
diff --git a/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts b/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts
index 2e26f4996b..4b873d78c4 100644
--- a/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts
+++ b/packages/core/src/main/weblinks-store/migrations/currentVersion.injectable.ts
@@ -3,11 +3,11 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
-import { docsUrl, slackUrl } from "../../../common/vars";
+import { docsUrl, forumsUrl } from "../../../common/vars";
import type { WeblinkData } from "../../../common/weblinks-store/weblink-store";
import { getInjectable } from "@ogre-tools/injectable";
import { weblinkStoreMigrationInjectionToken } from "../../../common/weblinks-store/migration-token";
-import { lensDocumentationWeblinkId, lensSlackWeblinkId } from "../links";
+import { lensDocumentationWeblinkId, lensForumsWeblinkId } from "../links";
import { applicationInformationToken } from "@k8slens/application";
const currentVersionWeblinkStoreMigrationInjectable = getInjectable({
@@ -20,10 +20,10 @@ const currentVersionWeblinkStoreMigrationInjectable = getInjectable({
run(store) {
const weblinksRaw = store.get("weblinks");
const weblinks = (Array.isArray(weblinksRaw) ? weblinksRaw : []) as WeblinkData[];
- const slackWeblink = weblinks.find(weblink => weblink.id === lensSlackWeblinkId);
+ const forumsWeblink = weblinks.find(weblink => weblink.id === lensForumsWeblinkId);
- if (slackWeblink) {
- slackWeblink.url = slackUrl;
+ if (forumsWeblink) {
+ forumsWeblink.url = forumsUrl;
}
const docsWeblink = weblinks.find(weblink => weblink.id === lensDocumentationWeblinkId);
@@ -32,7 +32,9 @@ const currentVersionWeblinkStoreMigrationInjectable = getInjectable({
docsWeblink.url = docsUrl;
}
- store.set("weblinks", weblinks);
+ const removedSlackLink = weblinks.filter(weblink => weblink.id !== "lens-slack-link");
+
+ store.set("weblinks", removedSlackLink);
},
};
},
diff --git a/packages/core/src/renderer/components/+welcome/welcome.tsx b/packages/core/src/renderer/components/+welcome/welcome.tsx
index cf413748bc..590eaafee5 100644
--- a/packages/core/src/renderer/components/+welcome/welcome.tsx
+++ b/packages/core/src/renderer/components/+welcome/welcome.tsx
@@ -10,7 +10,7 @@ import type { IComputedValue } from "mobx";
import type { CarouselProps } from "react-material-ui-carousel";
import LegacyCarousel from "react-material-ui-carousel";
import { Icon } from "../icon";
-import { slackUrl } from "../../../common/vars";
+import { forumsUrl } from "../../../common/vars";
import { withInjectables } from "@ogre-tools/injectable-react";
import welcomeMenuItemsInjectable from "./welcome-menu-items/welcome-menu-items.injectable";
import type { WelcomeMenuRegistration } from "./welcome-menu-items/welcome-menu-registration";
@@ -93,12 +93,12 @@ const NonInjectedWelcome = observer(({
{"If you have any questions or feedback, please join our "}
- Lens Community slack channel
+ Lens Forums
.
diff --git a/packages/core/src/renderer/components/error-boundary/error-boundary.tsx b/packages/core/src/renderer/components/error-boundary/error-boundary.tsx
index 75e5cf4689..6e39867109 100644
--- a/packages/core/src/renderer/components/error-boundary/error-boundary.tsx
+++ b/packages/core/src/renderer/components/error-boundary/error-boundary.tsx
@@ -9,7 +9,7 @@ import type { ErrorInfo } from "react";
import React from "react";
import { observer } from "mobx-react";
import { Button } from "../button";
-import { issuesTrackerUrl, slackUrl } from "../../../common/vars";
+import { issuesTrackerUrl, forumsUrl } from "../../../common/vars";
import type { SingleOrMany } from "../../utils";
import type { ObservableHistory } from "mobx-observable-history";
import { withInjectables } from "@ogre-tools/injectable-react";
@@ -53,15 +53,15 @@ class NonInjectedErrorBoundary extends React.Component