diff --git a/LICENSE b/LICENSE index 208e7c2e9c..42319c9dae 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021 OpenLens Authors. +Copyright (c) 2022 OpenLens Authors. Portions of this software are licensed as follows: diff --git a/package.json b/package.json index 45bb67d9f1..7c038a4f13 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "productName": "OpenLens", "description": "OpenLens - Open Source IDE for Kubernetes", "homepage": "https://github.com/lensapp/lens", - "version": "5.6.0-alpha.0", + "version": "5.6.0-alpha.2", "main": "static/build/main.js", - "copyright": "© 2021 OpenLens Authors", + "copyright": "© 2022 OpenLens Authors", "license": "MIT", "author": { "name": "OpenLens Authors", @@ -234,15 +234,15 @@ "handlebars": "^4.7.7", "history": "^4.10.1", "http-proxy": "^1.18.1", - "immer": "^9.0.14", + "immer": "^9.0.15", "joi": "^17.6.0", "js-yaml": "^4.1.0", "jsdom": "^16.7.0", "lodash": "^4.17.15", "mac-ca": "^1.0.6", - "marked": "^4.0.16", + "marked": "^4.0.17", "md5-file": "^5.0.0", - "mobx": "^6.5.0", + "mobx": "^6.6.0", "mobx-observable-history": "^2.0.3", "mobx-react": "^7.5.0", "mobx-utils": "^6.0.4", @@ -280,7 +280,7 @@ "winston": "^3.7.2", "winston-console-format": "^1.0.8", "winston-transport-browserconsole": "^1.0.5", - "ws": "^8.7.0" + "ws": "^8.8.0" }, "devDependencies": { "@async-fn/jest": "1.6.1", @@ -319,7 +319,7 @@ "@types/md5-file": "^4.0.2", "@types/mini-css-extract-plugin": "^2.4.0", "@types/mock-fs": "^4.13.1", - "@types/node": "^16.11.39", + "@types/node": "^16.11.40", "@types/node-fetch": "^2.6.1", "@types/npm": "^2.0.32", "@types/proper-lockfile": "^4.1.2", @@ -336,7 +336,7 @@ "@types/request": "^2.48.7", "@types/request-promise-native": "^1.0.18", "@types/semver": "^7.3.9", - "@types/sharp": "^0.30.2", + "@types/sharp": "^0.30.4", "@types/spdy": "^3.4.5", "@types/tar": "^4.0.5", "@types/tar-stream": "^2.2.2", @@ -349,7 +349,7 @@ "@types/webpack-dev-server": "^4.7.2", "@types/webpack-env": "^1.17.0", "@types/webpack-node-externals": "^2.5.3", - "@typescript-eslint/eslint-plugin": "^5.27.1", + "@typescript-eslint/eslint-plugin": "^5.28.0", "@typescript-eslint/parser": "^5.27.0", "ansi_up": "^5.1.0", "chart.js": "^2.9.4", @@ -357,20 +357,20 @@ "cli-progress": "^3.11.1", "color": "^3.2.1", "command-line-args": "^5.2.1", - "concurrently": "^7.2.1", + "concurrently": "^7.2.2", "css-loader": "^6.7.1", "deepdash": "^5.3.9", "dompurify": "^2.3.8", "electron": "^15.5.7", "electron-builder": "^23.0.3", "electron-notarize": "^0.3.0", - "esbuild": "^0.14.38", + "esbuild": "^0.14.43", "esbuild-loader": "^2.19.0", - "eslint": "^8.16.0", + "eslint": "^8.17.0", "eslint-plugin-header": "^3.1.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-react": "^7.30.0", - "eslint-plugin-react-hooks": "^4.5.0", + "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-unused-imports": "^2.0.0", "flex.box": "^3.4.4", "fork-ts-checker-webpack-plugin": "^6.5.2", @@ -402,23 +402,23 @@ "react-select-event": "^5.5.0", "react-table": "^7.8.0", "react-window": "^1.8.7", - "sass": "^1.52.2", + "sass": "^1.52.3", "sass-loader": "^12.6.0", "sharp": "^0.30.6", "style-loader": "^3.3.1", "tailwindcss": "^3.0.23", "tar-stream": "^2.2.0", "ts-loader": "^9.2.8", - "ts-node": "^10.7.0", - "type-fest": "^2.13.0", + "ts-node": "^10.8.1", + "type-fest": "^2.13.1", "typed-emitter": "^1.4.0", "typedoc": "0.22.17", "typedoc-plugin-markdown": "^3.11.12", - "typescript": "^4.5.5", + "typescript": "^4.7.3", "typescript-plugin-css-modules": "^3.4.0", "webpack": "^5.73.0", "webpack-cli": "^4.9.2", - "webpack-dev-server": "^4.9.1", + "webpack-dev-server": "^4.9.2", "webpack-node-externals": "^3.0.0", "xterm": "^4.18.0", "xterm-addon-fit": "^0.5.0" diff --git a/scripts/clear-release-pr.mjs b/scripts/create-release-pr.mjs similarity index 93% rename from scripts/clear-release-pr.mjs rename to scripts/create-release-pr.mjs index 4b55384e61..54b6ed17c5 100755 --- a/scripts/clear-release-pr.mjs +++ b/scripts/create-release-pr.mjs @@ -133,7 +133,8 @@ const relaventPrsQuery = await Promise.all( ); const relaventPrs = relaventPrsQuery .filter(query => query.stdout) - .map(query => query.pr); + .map(query => query.pr) + .filter(pr => pr.labels.every(label => label.name !== "skip-changelog")); const enhancementPrLabelName = "enhancement"; const bugfixPrLabelName = "bug"; @@ -152,11 +153,15 @@ const prBodyLines = [ "", ]; +function getPrEntry(pr) { + return `- ${pr.title} (**[#${pr.number}](https://github.com/lensapp/lens/pull/${pr.number})**) https://github.com/${pr.author.login}`; +} + if (enhancementPrs.length > 0) { prBodyLines.push( "## 🚀 Features", "", - ...enhancementPrs.map(pr => `- ${pr.title} (**#${pr.number}**) https://github.com/${pr.author.login}`), + ...enhancementPrs.map(getPrEntry), "", ); } @@ -165,7 +170,7 @@ if (bugfixPrs.length > 0) { prBodyLines.push( "## 🐛 Bug Fixes", "", - ...bugfixPrs.map(pr => `- ${pr.title} (**#${pr.number}**) https://github.com/${pr.author.login}`), + ...bugfixPrs.map(getPrEntry), "", ); } @@ -174,7 +179,7 @@ if (maintenencePrs.length > 0) { prBodyLines.push( "## 🧰 Maintenance", "", - ...maintenencePrs.map(pr => `- ${pr.title} (**#${pr.number}**) https://github.com/${pr.author.login}`), + ...maintenencePrs.map(getPrEntry), "", ); } diff --git a/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap b/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap index 80b0028469..5a952f701b 100644 --- a/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap +++ b/src/behaviours/__snapshots__/extension-special-characters-in-page-registrations.test.tsx.snap @@ -2,6 +2,16 @@ exports[`extension special characters in page registrations renders 1`] = `
+
+
+
+
@@ -10,6 +20,16 @@ exports[`extension special characters in page registrations renders 1`] = ` exports[`extension special characters in page registrations when navigating to route with ID having special characters renders 1`] = `
+
+
+
+
Some page
diff --git a/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap b/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap index c96763fe6e..f73444ff0e 100644 --- a/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap +++ b/src/behaviours/__snapshots__/navigate-to-extension-page.test.tsx.snap @@ -2,6 +2,16 @@ exports[`navigate to extension page renders 1`] = `
+
+
+
+
@@ -10,6 +20,16 @@ exports[`navigate to extension page renders 1`] = ` exports[`navigate to extension page when extension navigates to child route renders 1`] = `
+
+
+
+
Child page
@@ -21,6 +41,16 @@ exports[`navigate to extension page when extension navigates to child route rend exports[`navigate to extension page when extension navigates to route with parameters renders 1`] = `
+
+
+
+
  • @@ -48,6 +78,16 @@ exports[`navigate to extension page when extension navigates to route with param exports[`navigate to extension page when extension navigates to route without parameters renders 1`] = `
    +
    +
    +
    +
    • @@ -75,6 +115,16 @@ exports[`navigate to extension page when extension navigates to route without pa exports[`navigate to extension page when extension navigates to route without parameters when changing page parameters renders 1`] = `
      +
      +
      +
      +
      • diff --git a/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap b/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap index 10e9eb2d39..bd3c3f51e7 100644 --- a/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap +++ b/src/behaviours/__snapshots__/navigating-between-routes.test.tsx.snap @@ -2,6 +2,16 @@ exports[`navigating between routes given route with optional path parameters when navigating to route with path parameters renders 1`] = `
        +
        +
        +
        +
             {
           "someParameter": "some-value",
        @@ -16,6 +26,16 @@ exports[`navigating between routes given route with optional path parameters whe
         
         exports[`navigating between routes given route without path parameters when navigating to route renders 1`] = `
         
        +
        +
        +
        +
        Some component
        diff --git a/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap b/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap index 0fd00133aa..f6067dec05 100644 --- a/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap +++ b/src/behaviours/add-cluster/__snapshots__/navigation-using-application-menu.test.tsx.snap @@ -2,6 +2,16 @@ exports[`add-cluster - navigation using application menu renders 1`] = `
        +
        +
        +
        +
        @@ -10,6 +20,16 @@ exports[`add-cluster - navigation using application menu renders 1`] = ` exports[`add-cluster - navigation using application menu when navigating to add cluster using application menu renders 1`] = `
        +
        +
        +
        +
        +
        +
        +
        +
        @@ -13,6 +23,16 @@ exports[`installing update using tray when started renders 1`] = ` exports[`installing update using tray when started when user checks for updates using tray renders 1`] = `
        +
        +
        +
        +
        @@ -64,6 +84,16 @@ exports[`installing update using tray when started when user checks for updates exports[`installing update using tray when started when user checks for updates using tray when new update is discovered renders 1`] = `
        +
        +
        +
        +
        @@ -155,6 +185,16 @@ exports[`installing update using tray when started when user checks for updates exports[`installing update using tray when started when user checks for updates using tray when new update is discovered when download fails renders 1`] = `
        +
        +
        +
        +
        @@ -286,6 +326,16 @@ exports[`installing update using tray when started when user checks for updates exports[`installing update using tray when started when user checks for updates using tray when new update is discovered when download succeeds renders 1`] = `
        +
        +
        +
        +
        @@ -447,6 +497,16 @@ Lens should restart automatically, if it doesn't please restart manually. Instal exports[`installing update using tray when started when user checks for updates using tray when no new update is discovered renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap b/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap index 7025289254..0e271ef2d3 100644 --- a/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap +++ b/src/behaviours/application-update/__snapshots__/installing-update.test.ts.snap @@ -3,6 +3,16 @@ exports[`installing update when started renders 1`] = `
        +
        +
        +
        +
        @@ -13,6 +23,16 @@ exports[`installing update when started renders 1`] = ` exports[`installing update when started when user checks for updates renders 1`] = `
        +
        +
        +
        +
        @@ -23,6 +43,16 @@ exports[`installing update when started when user checks for updates renders 1`] exports[`installing update when started when user checks for updates when new update is discovered renders 1`] = `
        +
        +
        +
        +
        @@ -33,6 +63,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download fails renders 1`] = `
        +
        +
        +
        +
        @@ -43,6 +83,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download succeeds renders 1`] = `
        +
        +
        +
        +
        @@ -53,6 +103,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download succeeds when user answers not to install the update renders 1`] = `
        +
        +
        +
        +
        @@ -63,6 +123,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when new update is discovered when download succeeds when user answers to install the update renders 1`] = `
        +
        +
        +
        +
        @@ -73,6 +143,16 @@ exports[`installing update when started when user checks for updates when new up exports[`installing update when started when user checks for updates when no new update is discovered renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap b/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap index 84fa35ae04..744a9dfb7e 100644 --- a/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap +++ b/src/behaviours/application-update/__snapshots__/periodical-checking-of-updates.test.ts.snap @@ -3,6 +3,16 @@ exports[`periodical checking of updates given updater is enabled and configuration exists, when started renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap b/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap index dc96c447b0..ea700234da 100644 --- a/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap +++ b/src/behaviours/application-update/__snapshots__/selection-of-update-stability.test.ts.snap @@ -3,6 +3,16 @@ exports[`selection of update stability when started renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/application-update/analytics-for-installing-update.test.ts b/src/behaviours/application-update/analytics-for-installing-update.test.ts new file mode 100644 index 0000000000..c33a3f92af --- /dev/null +++ b/src/behaviours/application-update/analytics-for-installing-update.test.ts @@ -0,0 +1,225 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable"; +import publishIsConfiguredInjectable from "../../main/application-update/publish-is-configured.injectable"; +import type { AsyncFnMock } from "@async-fn/jest"; +import asyncFn from "@async-fn/jest"; +import type { CheckForPlatformUpdates } from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable"; +import checkForPlatformUpdatesInjectable from "../../main/application-update/check-for-platform-updates/check-for-platform-updates.injectable"; +import appEventBusInjectable from "../../common/app-event-bus/app-event-bus.injectable"; +import type { DiContainer } from "@ogre-tools/injectable"; +import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable"; +import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable"; +import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable"; +import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable"; +import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable"; +import periodicalCheckForUpdatesInjectable from "../../main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable"; + +describe("analytics for installing update", () => { + let applicationBuilder: ApplicationBuilder; + let checkForPlatformUpdatesMock: AsyncFnMock; + let downloadPlatformUpdateMock: AsyncFnMock; + let analyticsListenerMock: jest.Mock; + let mainDi: DiContainer; + + beforeEach(async () => { + jest.useFakeTimers(); + + global.Date.now = () => new Date("2015-10-21T07:28:00Z").getTime(); + + applicationBuilder = getApplicationBuilder(); + + analyticsListenerMock = jest.fn(); + + applicationBuilder.beforeApplicationStart(({ mainDi }) => { + mainDi.override(appVersionInjectable, () => "42.0.0"); + + checkForPlatformUpdatesMock = asyncFn(); + + mainDi.override( + checkForPlatformUpdatesInjectable, + () => checkForPlatformUpdatesMock, + ); + + downloadPlatformUpdateMock = asyncFn(); + + mainDi.override(downloadPlatformUpdateInjectable, () => downloadPlatformUpdateMock); + mainDi.override(electronUpdaterIsActiveInjectable, () => true); + + mainDi.override(publishIsConfiguredInjectable, () => true); + + const eventBus = mainDi.inject(appEventBusInjectable); + + eventBus.addListener(analyticsListenerMock); + }); + + mainDi = applicationBuilder.dis.mainDi; + }); + + describe("given application is started and checking updates periodically", () => { + beforeEach(async () => { + mainDi.unoverride(periodicalCheckForUpdatesInjectable); + mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable); + + await applicationBuilder.render(); + + }); + + it("sends event to analytics for being checked periodically", () => { + expect(analyticsListenerMock).toHaveBeenCalledWith({ + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "periodic", + }, + }); + }); + + it("when enough time passes to check for updates again, sends event to analytics for being checked periodically", () => { + analyticsListenerMock.mockClear(); + + jest.advanceTimersByTime(1000 * 60 * 60 * 2); + + expect(analyticsListenerMock).toHaveBeenCalledWith({ + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "periodic", + }, + }); + }); + }); + + describe("when application is started", () => { + beforeEach(async () => { + analyticsListenerMock.mockClear(); + + await applicationBuilder.render(); + }); + + it("sends event to analytics about the current version", () => { + expect(analyticsListenerMock).toHaveBeenCalledWith({ + name: "app", + action: "current-version", + + params: { + version: "42.0.0", + currentDateTime: "2015-10-21T07:28:00Z", + }, + }); + }); + + it("when checking for updates using tray, sends event to analytics for being checked from tray", async () => { + analyticsListenerMock.mockClear(); + + applicationBuilder.tray.click("check-for-updates"); + + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "tray", + }, + }, + ], + ]); + + }); + + it("when checking for updates using application menu, sends event to analytics for being checked from application menu", async () => { + analyticsListenerMock.mockClear(); + + applicationBuilder.applicationMenu.click("root.check-for-updates"); + + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "checking-for-updates", + + params: { + currentDateTime: "2015-10-21T07:28:00Z", + source: "application-menu", + }, + }, + ], + ]); + }); + + describe("given checking for updates, when check for updates resolves with new update being available", () => { + beforeEach(async () => { + const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable); + + processCheckingForUpdates("irrelevant"); + + analyticsListenerMock.mockClear(); + + await checkForPlatformUpdatesMock.resolve({ + updateWasDiscovered: true, + version: "43.0.0", + }); + }); + + it("sends event to analytics about new update being available", () => { + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "update-was-discovered", + + params: { + version: "43.0.0", + currentDateTime: "2015-10-21T07:28:00Z", + }, + }, + ], + ]); + }); + + describe("given update is downloaded", () => { + beforeEach(async () => { + analyticsListenerMock.mockClear(); + + await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: true }); + }); + + it("does not send event to analytics about update downloaded being successful", () => { + expect(analyticsListenerMock).not.toHaveBeenCalled(); + }); + + it("when installing the update, sends event to analytics about installing the update", () => { + const quitAndInstallUpdate = mainDi.inject(quitAndInstallUpdateInjectable); + + quitAndInstallUpdate(); + + expect(analyticsListenerMock.mock.calls).toEqual([ + [ + { + name: "app", + action: "start-installing-update", + + params: { + version: "43.0.0", + currentDateTime: "2015-10-21T07:28:00Z", + updateChannel: "latest", + }, + }, + ], + ]); + }); + }); + }); + }); +}); diff --git a/src/behaviours/application-update/downgrading-version-update.test.ts b/src/behaviours/application-update/downgrading-version-update.test.ts index e8e5635fb3..2abefa1ac8 100644 --- a/src/behaviours/application-update/downgrading-version-update.test.ts +++ b/src/behaviours/application-update/downgrading-version-update.test.ts @@ -22,8 +22,6 @@ describe("downgrading version update", () => { let mainDi: DiContainer; beforeEach(() => { - jest.useFakeTimers(); - applicationBuilder = getApplicationBuilder(); applicationBuilder.beforeApplicationStart(({ mainDi }) => { @@ -79,7 +77,7 @@ describe("downgrading version update", () => { const processCheckingForUpdates = mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(expect.any(Object), { allowDowngrade: downgradeIsAllowed }); }); diff --git a/src/behaviours/application-update/installing-update.test.ts b/src/behaviours/application-update/installing-update.test.ts index 3fec5f6d27..14cd107598 100644 --- a/src/behaviours/application-update/installing-update.test.ts +++ b/src/behaviours/application-update/installing-update.test.ts @@ -4,7 +4,7 @@ */ import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; -import quitAndInstallUpdateInjectable from "../../main/electron-app/features/quit-and-install-update.injectable"; +import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable"; import type { RenderResult } from "@testing-library/react"; import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable"; import publishIsConfiguredInjectable from "../../main/application-update/publish-is-configured.injectable"; @@ -67,7 +67,7 @@ describe("installing update", () => { describe("when started", () => { let rendered: RenderResult; - let processCheckingForUpdates: () => Promise; + let processCheckingForUpdates: (source: string) => Promise; beforeEach(async () => { rendered = await applicationBuilder.render(); @@ -83,7 +83,7 @@ describe("installing update", () => { let processCheckingForUpdatesPromise: Promise; beforeEach(async () => { - processCheckingForUpdatesPromise = processCheckingForUpdates(); + processCheckingForUpdatesPromise = processCheckingForUpdates("irrelevant"); }); it("checks for updates", () => { diff --git a/src/behaviours/application-update/selection-of-update-stability.test.ts b/src/behaviours/application-update/selection-of-update-stability.test.ts index 1792fcd484..1fd6e22dbd 100644 --- a/src/behaviours/application-update/selection-of-update-stability.test.ts +++ b/src/behaviours/application-update/selection-of-update-stability.test.ts @@ -4,7 +4,7 @@ */ import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; -import quitAndInstallUpdateInjectable from "../../main/electron-app/features/quit-and-install-update.injectable"; +import quitAndInstallUpdateInjectable from "../../main/application-update/quit-and-install-update.injectable"; import type { RenderResult } from "@testing-library/react"; import electronUpdaterIsActiveInjectable from "../../main/electron-app/features/electron-updater-is-active.injectable"; import publishIsConfiguredInjectable from "../../main/application-update/publish-is-configured.injectable"; @@ -72,7 +72,7 @@ describe("selection of update stability", () => { describe("when started", () => { let rendered: RenderResult; - let processCheckingForUpdates: () => Promise; + let processCheckingForUpdates: (source: string) => Promise; beforeEach(async () => { rendered = await applicationBuilder.render(); @@ -97,7 +97,7 @@ describe("selection of update stability", () => { selectedUpdateChannel.setValue(updateChannels.alpha.id); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); }); it('checks updates from update channel "alpha"', () => { @@ -191,7 +191,7 @@ describe("selection of update stability", () => { describe("when checking for updates", () => { beforeEach(() => { - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); }); describe('when update from "beta" channel is discovered', () => { @@ -241,7 +241,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object)); }); @@ -259,7 +259,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.latest, expect.any(Object)); }); @@ -273,7 +273,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith( updateChannels.latest, @@ -290,7 +290,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.alpha, expect.any(Object)); }); @@ -304,7 +304,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object)); }); @@ -324,7 +324,7 @@ describe("selection of update stability", () => { const processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable); - processCheckingForUpdates(); + processCheckingForUpdates("irrelevant"); expect(checkForPlatformUpdatesMock).toHaveBeenCalledWith(updateChannels.beta, expect.any(Object)); }); diff --git a/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx b/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx index f270b7d13e..a8c26acc2a 100644 --- a/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx +++ b/src/behaviours/cluster/sidebar-and-tab-navigation-for-core.test.tsx @@ -14,7 +14,7 @@ import { sidebarItemsInjectionToken } from "../../renderer/components/layout/sid import { computed } from "mobx"; import { noop } from "lodash/fp"; import routeIsActiveInjectable from "../../renderer/routes/route-is-active.injectable"; -import { routeInjectionToken } from "../../common/front-end-routing/route-injection-token"; +import { frontEndRouteInjectionToken } from "../../common/front-end-routing/front-end-route-injection-token"; import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import writeJsonFileInjectable from "../../common/fs/write-json-file.injectable"; @@ -337,7 +337,7 @@ const testRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); const testRouteComponentInjectable = getInjectable({ diff --git a/src/behaviours/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx b/src/behaviours/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx index eb7fd0bc05..8ef472f20d 100644 --- a/src/behaviours/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx +++ b/src/behaviours/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx @@ -46,7 +46,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => { const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder); const testExtension = getRendererExtensionFake(extensionStubWithSidebarItems); - await applicationBuilder.addExtensions(testExtension); + await applicationBuilder.extensions.renderer.enable(testExtension); }); describe("given no state for expanded sidebar items exists, and navigated to child sidebar item, when rendered", () => { diff --git a/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx b/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx index aa73936470..c0e0cc88f3 100644 --- a/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx +++ b/src/behaviours/cluster/visibility-of-sidebar-items.test.tsx @@ -10,7 +10,7 @@ import { computed } from "mobx"; import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token"; import React from "react"; import isAllowedResourceInjectable from "../../common/utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../common/front-end-routing/route-injection-token"; +import { frontEndRouteInjectionToken } from "../../common/front-end-routing/front-end-route-injection-token"; import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token"; @@ -83,7 +83,7 @@ const testRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); const testRouteComponentInjectable = getInjectable({ diff --git a/src/behaviours/extension-special-characters-in-page-registrations.test.tsx b/src/behaviours/extension-special-characters-in-page-registrations.test.tsx index 2320d28a1b..20c29d82b5 100644 --- a/src/behaviours/extension-special-characters-in-page-registrations.test.tsx +++ b/src/behaviours/extension-special-characters-in-page-registrations.test.tsx @@ -23,7 +23,7 @@ describe("extension special characters in page registrations", () => { extensionWithPagesHavingSpecialCharacters, ); - await applicationBuilder.addExtensions(testExtension); + await applicationBuilder.extensions.renderer.enable(testExtension); rendered = await applicationBuilder.render(); }); diff --git a/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap b/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap index c14ccb6160..8dd45c656a 100644 --- a/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap +++ b/src/behaviours/extensions/__snapshots__/navigation-using-application-menu.test.ts.snap @@ -2,6 +2,16 @@ exports[`extensions - navigation using application menu renders 1`] = `
        +
        +
        +
        +
        @@ -10,6 +20,16 @@ exports[`extensions - navigation using application menu renders 1`] = ` exports[`extensions - navigation using application menu when navigating to extensions using application menu renders 1`] = `
        +
        +
        +
        +
        { }); describe("when navigating to extensions using application menu", () => { - beforeEach(async () => { - await applicationBuilder.applicationMenu.click("root.extensions"); + beforeEach(() => { + applicationBuilder.applicationMenu.click("root.extensions"); }); it("focuses the window", () => { diff --git a/src/behaviours/helm-charts/__snapshots__/add-custom-helm-repository-in-preferences.test.ts.snap b/src/behaviours/helm-charts/__snapshots__/add-custom-helm-repository-in-preferences.test.ts.snap index 1b1d3a51cc..21803cf04a 100644 --- a/src/behaviours/helm-charts/__snapshots__/add-custom-helm-repository-in-preferences.test.ts.snap +++ b/src/behaviours/helm-charts/__snapshots__/add-custom-helm-repository-in-preferences.test.ts.snap @@ -3,6 +3,16 @@ exports[`add custom helm repository in preferences when navigating to preferences containing helm repositories renders 1`] = `
        +
        +
        +
        +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some active repository -
        -
        - some-url +
        +
        + Some active repository +
        +
        + some-url +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        -
        - Some already active repository -
        -
        - some-url +
        +
        + Some already active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some already active repository -
        -
        - some-url +
        +
        + Some already active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some already active repository -
        -
        - some-url +
        +
        + Some already active repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - Some already active repository -
        -
        - some-url +
        +
        + Some already active repository +
        +
        + some-url +
        +
        +
        +
        +
        +
        +
        +
        +
        -
        - Some already active repository -
        -
        - some-url +
        +
        + Some already active repository +
        +
        + some-url +
        -
        - Some to be added repository -
        -
        - some-other-url +
        +
        + Some to be added repository +
        +
        + some-other-url +
        +
        +
        +
        +
        -
        - Some already active repository -
        -
        - some-url +
        +
        + Some already active repository +
        +
        + some-url +
        -
        - Some to be added repository -
        -
        - some-other-url +
        +
        + Some to be added repository +
        +
        + some-other-url +
        +
        +
        +
        +
        -
        - Some already active repository -
        -
        - some-url +
        +
        + Some already active repository +
        +
        + some-url +
        -
        - Some to be added repository -
        -
        - some-other-url +
        +
        + Some to be added repository +
        +
        + some-other-url +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        -
        - some-repository -
        -
        - some-repository-url +
        +
        + some-repository +
        +
        + some-repository-url +
        -
        - some-other-repository -
        -
        - some-other-repository-url +
        +
        + some-other-repository +
        +
        + some-other-repository-url +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        -
        - some-active-repository -
        -
        - some-url +
        +
        + some-active-repository +
        +
        + some-url +
        +
        +
        +
        +
        -
        - some-active-repository -
        -
        - some-url +
        +
        + some-active-repository +
        +
        + some-url +
        +
        +
        +
        +
        { extensionWithPagesHavingParameters, ); - await applicationBuilder.addExtensions(testExtension); + await applicationBuilder.extensions.renderer.enable(testExtension); rendered = await applicationBuilder.render(); diff --git a/src/behaviours/navigating-between-routes.test.tsx b/src/behaviours/navigating-between-routes.test.tsx index 4def9b383f..ab0240b2a4 100644 --- a/src/behaviours/navigating-between-routes.test.tsx +++ b/src/behaviours/navigating-between-routes.test.tsx @@ -9,8 +9,8 @@ import { computed } from "mobx"; import type { RenderResult } from "@testing-library/react"; import { routeSpecificComponentInjectionToken } from "../renderer/routes/route-specific-component-injection-token"; import { observer } from "mobx-react"; -import type { Route } from "../common/front-end-routing/route-injection-token"; -import { routeInjectionToken } from "../common/front-end-routing/route-injection-token"; +import type { Route } from "../common/front-end-routing/front-end-route-injection-token"; +import { frontEndRouteInjectionToken } from "../common/front-end-routing/front-end-route-injection-token"; import type { ApplicationBuilder } from "../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../renderer/components/test-utils/get-application-builder"; import currentRouteInjectable from "../renderer/routes/current-route.injectable"; @@ -192,7 +192,7 @@ describe("navigating between routes", () => { const testRouteWithoutPathParametersInjectable = getInjectable({ id: "some-route", - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, instantiate: () => ({ path: "/some-path", @@ -214,7 +214,7 @@ const testRouteWithoutPathParametersComponentInjectable = getInjectable({ const routeWithOptionalPathParametersInjectable = getInjectable({ id: "some-route", - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, instantiate: (): Route<{ someParameter?: string; someOtherParameter?: string }> => ({ path: "/some-path/:someParameter?/:someOtherParameter?", diff --git a/src/behaviours/preferences/__snapshots__/closing-preferences.test.tsx.snap b/src/behaviours/preferences/__snapshots__/closing-preferences.test.tsx.snap index 5cdee87f39..13c0967f4d 100644 --- a/src/behaviours/preferences/__snapshots__/closing-preferences.test.tsx.snap +++ b/src/behaviours/preferences/__snapshots__/closing-preferences.test.tsx.snap @@ -2,6 +2,16 @@ exports[`preferences - closing-preferences given accessing preferences directly renders 1`] = `
        +
        +
        +
        +
        +
        +
        +
        +
        @@ -688,6 +708,16 @@ exports[`preferences - closing-preferences given accessing preferences directly exports[`preferences - closing-preferences given accessing preferences directly when navigating to a tab in preferences when preferences are closed renders 1`] = `
        +
        +
        +
        +
        Some front page
        @@ -699,6 +729,16 @@ exports[`preferences - closing-preferences given accessing preferences directly exports[`preferences - closing-preferences given accessing preferences directly when preferences are closed renders 1`] = `
        +
        +
        +
        +
        Some front page
        @@ -710,6 +750,16 @@ exports[`preferences - closing-preferences given accessing preferences directly exports[`preferences - closing-preferences given already in a page and then navigated to preferences renders 1`] = `
        +
        +
        +
        +
        +
        +
        +
        +
        @@ -1396,6 +1456,16 @@ exports[`preferences - closing-preferences given already in a page and then navi exports[`preferences - closing-preferences given already in a page and then navigated to preferences when navigating to a tab in preferences when preferences are closed renders 1`] = `
        +
        +
        +
        +
        @@ -1541,6 +1611,16 @@ exports[`preferences - closing-preferences given already in a page and then navi exports[`preferences - closing-preferences given already in a page and then navigated to preferences when preferences are closed renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/behaviours/preferences/__snapshots__/navigation-to-application-preferences.test.ts.snap b/src/behaviours/preferences/__snapshots__/navigation-to-application-preferences.test.ts.snap index 7cd89769f5..44dd4be6ca 100644 --- a/src/behaviours/preferences/__snapshots__/navigation-to-application-preferences.test.ts.snap +++ b/src/behaviours/preferences/__snapshots__/navigation-to-application-preferences.test.ts.snap @@ -2,6 +2,16 @@ exports[`preferences - navigation to application preferences given in some child page of preferences, when rendered renders 1`] = `
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        @@ -10,6 +20,16 @@ exports[`preferences - navigation using application menu renders 1`] = ` exports[`preferences - navigation using application menu when navigating to preferences using application menu renders 1`] = `
        +
        +
        +
        +
        +
        +
        +
        +
        @@ -13,6 +23,16 @@ exports[`show-about-using-tray renders 1`] = ` exports[`show-about-using-tray when navigating using tray renders 1`] = `
        +
        +
        +
        +
        true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); const testPreferencesRouteComponentInjectable = getInjectable({ @@ -225,7 +225,7 @@ const testFrontPageRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); const testFrontPageRouteComponentInjectable = getInjectable({ diff --git a/src/behaviours/preferences/navigation-to-extension-specific-preferences.test.tsx b/src/behaviours/preferences/navigation-to-extension-specific-preferences.test.tsx index f44fb9bf20..de97d67bcf 100644 --- a/src/behaviours/preferences/navigation-to-extension-specific-preferences.test.tsx +++ b/src/behaviours/preferences/navigation-to-extension-specific-preferences.test.tsx @@ -44,11 +44,11 @@ describe("preferences - navigation to extension specific preferences", () => { }); describe("when extension with specific preferences is enabled", () => { - beforeEach(() => { + beforeEach(async () => { const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder); const testExtension = getRendererExtensionFake(extensionStubWithExtensionSpecificPreferenceItems); - applicationBuilder.addExtensions(testExtension); + await applicationBuilder.extensions.renderer.enable(testExtension); }); it("renders", () => { diff --git a/src/behaviours/preferences/navigation-to-telemetry-preferences.test.tsx b/src/behaviours/preferences/navigation-to-telemetry-preferences.test.tsx index f16c2d809b..42ea181ddc 100644 --- a/src/behaviours/preferences/navigation-to-telemetry-preferences.test.tsx +++ b/src/behaviours/preferences/navigation-to-telemetry-preferences.test.tsx @@ -50,7 +50,7 @@ describe("preferences - navigation to telemetry preferences", () => { const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder); const testExtensionWithTelemetryPreferenceItems = getRendererExtensionFake(extensionStubWithTelemetryPreferenceItems); - applicationBuilder.addExtensions( + applicationBuilder.extensions.renderer.enable( testExtensionWithTelemetryPreferenceItems, ); }); @@ -105,7 +105,7 @@ describe("preferences - navigation to telemetry preferences", () => { ], }); - applicationBuilder.addExtensions( + applicationBuilder.extensions.renderer.enable( testExtensionWithTelemetryPreferenceItems, ); diff --git a/src/behaviours/preferences/navigation-using-application-menu.test.ts b/src/behaviours/preferences/navigation-using-application-menu.test.ts index e12aa85a44..c78e546442 100644 --- a/src/behaviours/preferences/navigation-using-application-menu.test.ts +++ b/src/behaviours/preferences/navigation-using-application-menu.test.ts @@ -28,8 +28,8 @@ describe("preferences - navigation using application menu", () => { }); describe("when navigating to preferences using application menu", () => { - beforeEach(async () => { - await applicationBuilder.applicationMenu.click("root.preferences"); + beforeEach(() => { + applicationBuilder.applicationMenu.click("root.preferences"); }); it("renders", () => { diff --git a/src/behaviours/quitting-and-restarting-the-app/opening-application-window-using-tray.test.ts b/src/behaviours/quitting-and-restarting-the-app/opening-application-window-using-tray.test.ts new file mode 100644 index 0000000000..4b5b6ff338 --- /dev/null +++ b/src/behaviours/quitting-and-restarting-the-app/opening-application-window-using-tray.test.ts @@ -0,0 +1,238 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { lensWindowInjectionToken } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token"; +import applicationWindowInjectable from "../../main/start-main-application/lens-window/application-window/application-window.injectable"; +import createElectronWindowForInjectable from "../../main/start-main-application/lens-window/application-window/create-electron-window.injectable"; +import type { AsyncFnMock } from "@async-fn/jest"; +import asyncFn from "@async-fn/jest"; +import type { ElectronWindow, LensWindowConfiguration } from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable"; +import type { DiContainer } from "@ogre-tools/injectable"; +import lensResourcesDirInjectable from "../../common/vars/lens-resources-dir.injectable"; + +describe("opening application window using tray", () => { + describe("given application has started", () => { + let applicationBuilder: ApplicationBuilder; + let createElectronWindowMock: jest.Mock; + let expectWindowsToBeOpen: (windowIds: string[]) => void; + let callForSplashWindowHtmlMock: AsyncFnMock<() => void>; + let callForApplicationWindowHtmlMock: AsyncFnMock<() => void>; + + beforeEach(async () => { + callForSplashWindowHtmlMock = asyncFn(); + callForApplicationWindowHtmlMock = asyncFn(); + + applicationBuilder = getApplicationBuilder().beforeApplicationStart( + ({ mainDi }) => { + mainDi.override(lensResourcesDirInjectable, () => "some-lens-resources-directory"); + + const loadFileMock = jest + .fn(callForSplashWindowHtmlMock) + .mockImplementationOnce(() => Promise.resolve()); + + const loadUrlMock = jest + .fn(callForApplicationWindowHtmlMock) + .mockImplementationOnce(() => Promise.resolve()); + + createElectronWindowMock = jest.fn((configuration: LensWindowConfiguration) => + ({ + splash: { + send: () => {}, + close: () => {}, + show: () => {}, + loadFile: loadFileMock, + loadUrl: () => { throw new Error("Should never come here"); }, + }, + + "only-application-window": { + send: () => {}, + close: () => {}, + show: () => {}, + loadFile: () => { throw new Error("Should never come here"); }, + loadUrl: loadUrlMock, + }, + }[configuration.id] as ElectronWindow)); + + mainDi.override( + createElectronWindowForInjectable, + + () => createElectronWindowMock, + ); + + expectWindowsToBeOpen = expectWindowsToBeOpenFor(mainDi); + }, + ); + + await applicationBuilder.render(); + }); + + it("only an application window is open", () => { + expectWindowsToBeOpen(["only-application-window"]); + }); + + describe("when an attempt to reopen the already started application is made using tray", () => { + beforeEach(() => { + applicationBuilder.tray.click("open-app"); + }); + + it("still shows only the application window", () => { + expectWindowsToBeOpen(["only-application-window"]); + }); + }); + + describe("when the application window is closed", () => { + beforeEach(() => { + const applicationWindow = applicationBuilder.dis.mainDi.inject( + applicationWindowInjectable, + ); + + applicationWindow.close(); + }); + + it("no windows are open", () => { + expectWindowsToBeOpen([]); + }); + + describe("when an application window is reopened using tray", () => { + beforeEach(() => { + callForSplashWindowHtmlMock.mockClear(); + callForApplicationWindowHtmlMock.mockClear(); + + applicationBuilder.tray.click("open-app"); + }); + + it("still no windows are open", () => { + expectWindowsToBeOpen([]); + }); + + it("starts loading static HTML of splash window", () => { + expect(callForSplashWindowHtmlMock).toHaveBeenCalledWith("/some-absolute-root-directory/some-lens-resources-directory/static/splash.html"); + }); + + describe("when loading of splash window HTML resolves", () => { + beforeEach(async () => { + await callForSplashWindowHtmlMock.resolve(); + }); + + it("shows just the splash window", () => { + expectWindowsToBeOpen(["splash"]); + }); + + it("starts loading of content for the application window", () => { + expect(callForApplicationWindowHtmlMock).toHaveBeenCalledWith("http://localhost:42"); + }); + + describe("given static HTML of application window has not resolved yet, when opening from tray again", () => { + beforeEach(() => { + callForApplicationWindowHtmlMock.mockClear(); + callForSplashWindowHtmlMock.mockClear(); + + applicationBuilder.tray.click("open-app"); + }); + + it("does not load contents of splash window again", () => { + expect(callForSplashWindowHtmlMock).not.toHaveBeenCalled(); + }); + + it("does not load contents of application window again", () => { + expect(callForApplicationWindowHtmlMock).not.toHaveBeenCalled(); + }); + + it("shows just the blank application window to permit developer tool access", () => { + expectWindowsToBeOpen(["only-application-window"]); + }); + }); + + describe("when static HTML of application window resolves", () => { + beforeEach(async () => { + await callForApplicationWindowHtmlMock.resolve(); + }); + + it("shows just the application window", () => { + expectWindowsToBeOpen(["only-application-window"]); + }); + + describe("when reopening the application using tray", () => { + beforeEach(() => { + callForSplashWindowHtmlMock.mockClear(); + callForApplicationWindowHtmlMock.mockClear(); + + applicationBuilder.tray.click("open-app"); + }); + + it("still shows just the application window", () => { + expectWindowsToBeOpen(["only-application-window"]); + }); + + it("does not load HTML for splash window again", () => { + expect(callForSplashWindowHtmlMock).not.toHaveBeenCalled(); + }); + + it("does not load HTML for application window again", () => { + expect(callForApplicationWindowHtmlMock).not.toHaveBeenCalled(); + }); + }); + }); + }); + + describe("given opening of splash window has not finished yet, but another attempt to open the application is made", () => { + beforeEach(() => { + createElectronWindowMock.mockClear(); + + applicationBuilder.tray.click("open-app"); + }); + + it("does not open any new windows", () => { + expect(createElectronWindowMock).not.toHaveBeenCalled(); + }); + }); + + describe("when opening of splash window resolves", () => { + beforeEach(async () => { + await callForSplashWindowHtmlMock.resolve(); + }); + + it("still only splash window is open", () => { + expectWindowsToBeOpen(["splash"]); + }); + + it("when opening of application window finishes, only an application window is open", async () => { + await callForApplicationWindowHtmlMock.resolve(); + + expectWindowsToBeOpen(["only-application-window"]); + }); + + describe("given opening of application window has not finished yet, but another attempt to open the application is made", () => { + beforeEach(() => { + createElectronWindowMock.mockClear(); + + applicationBuilder.tray.click("open-app"); + }); + + it("does not open any new windows", () => { + expect(createElectronWindowMock).not.toHaveBeenCalled(); + }); + + it("when opening finishes, only an application window is open", async () => { + await callForApplicationWindowHtmlMock.resolve(); + + expectWindowsToBeOpen(["only-application-window"]); + }); + }); + }); + }); + }); + }); +}); + +const expectWindowsToBeOpenFor = (di: DiContainer) => (windowIds: string[]) => { + const windows = di.injectMany(lensWindowInjectionToken); + + expect( + windows.filter((window) => window.isVisible).map((window) => window.id), + ).toEqual(windowIds); +}; diff --git a/src/behaviours/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts b/src/behaviours/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts new file mode 100644 index 0000000000..5f96bb06fb --- /dev/null +++ b/src/behaviours/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts @@ -0,0 +1,90 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import type { ClusterManager } from "../../main/cluster-manager"; +import { lensWindowInjectionToken } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token"; +import exitAppInjectable from "../../main/electron-app/features/exit-app.injectable"; +import clusterManagerInjectable from "../../main/cluster-manager.injectable"; +import stopServicesAndExitAppInjectable from "../../main/stop-services-and-exit-app.injectable"; + +describe("quitting the app using application menu", () => { + describe("given application has started", () => { + let applicationBuilder: ApplicationBuilder; + let clusterManagerStub: ClusterManager; + let exitAppMock: jest.Mock; + + beforeEach(async () => { + jest.useFakeTimers(); + + applicationBuilder = getApplicationBuilder().beforeApplicationStart( + ({ mainDi }) => { + mainDi.unoverride(stopServicesAndExitAppInjectable); + + clusterManagerStub = { stop: jest.fn() } as unknown as ClusterManager; + mainDi.override(clusterManagerInjectable, () => clusterManagerStub); + + exitAppMock = jest.fn(); + mainDi.override(exitAppInjectable, () => exitAppMock); + }, + ); + + await applicationBuilder.render(); + }); + + it("only an application window is open", () => { + const windows = applicationBuilder.dis.mainDi.injectMany( + lensWindowInjectionToken, + ); + + expect( + windows.map((window) => ({ id: window.id, visible: window.isVisible })), + ).toEqual([ + { id: "only-application-window", visible: true }, + { id: "splash", visible: false }, + ]); + }); + + describe("when application is quit", () => { + beforeEach(() => { + applicationBuilder.applicationMenu.click("root.quit"); + }); + + it("closes all windows", () => { + const windows = applicationBuilder.dis.mainDi.injectMany( + lensWindowInjectionToken, + ); + + expect( + windows.map((window) => ({ id: window.id, visible: window.isVisible })), + ).toEqual([ + { id: "only-application-window", visible: false }, + { id: "splash", visible: false }, + ]); + }); + + it("disconnects all clusters", () => { + expect(clusterManagerStub.stop).toHaveBeenCalled(); + }); + + it("after insufficient time passes, does not terminate application yet", () => { + jest.advanceTimersByTime(999); + + expect(exitAppMock).not.toHaveBeenCalled(); + }); + + describe("after sufficient time passes", () => { + beforeEach(() => { + jest.advanceTimersByTime(1000); + }); + + it("terminates application", () => { + expect(exitAppMock).toHaveBeenCalled(); + }); + }); + }); + }); +}); diff --git a/src/behaviours/tray/clicking-tray-menu-item-originating-from-extension.test.ts b/src/behaviours/tray/clicking-tray-menu-item-originating-from-extension.test.ts new file mode 100644 index 0000000000..249673ef83 --- /dev/null +++ b/src/behaviours/tray/clicking-tray-menu-item-originating-from-extension.test.ts @@ -0,0 +1,134 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { LensMainExtension } from "../../extensions/lens-main-extension"; +import type { TrayMenuRegistration } from "../../main/tray/tray-menu-registration"; +import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import loggerInjectable from "../../common/logger.injectable"; +import type { Logger } from "../../common/logger"; + +describe("clicking tray menu item originating from extension", () => { + let applicationBuilder: ApplicationBuilder; + let logErrorMock: jest.Mock; + + beforeEach(async () => { + applicationBuilder = getApplicationBuilder(); + + applicationBuilder.beforeApplicationStart(({ mainDi }) => { + logErrorMock = jest.fn(); + + mainDi.override(loggerInjectable, () => ({ error: logErrorMock }) as unknown as Logger); + }); + + await applicationBuilder.render(); + }); + + describe("when extension is enabled", () => { + let someExtension: SomeTestExtension; + let clickMock: jest.Mock; + + beforeEach(async () => { + clickMock = jest.fn(); + + someExtension = new SomeTestExtension({ + id: "some-extension-id", + trayMenus: [{ label: "some-label", click: clickMock }], + }); + + await applicationBuilder.extensions.main.enable(someExtension); + }); + + it("when item is clicked, triggers the click handler", () => { + applicationBuilder.tray.click( + "some-label-tray-menu-item-for-extension-some-extension-id-instance-1", + ); + + expect(clickMock).toHaveBeenCalled(); + }); + + describe("given click handler throws synchronously, when item is clicked", () => { + beforeEach(() => { + clickMock.mockImplementation(() => { + throw new Error("some-error"); + }); + + applicationBuilder.tray.click( + "some-label-tray-menu-item-for-extension-some-extension-id-instance-1", + ); + }); + + it("logs the error", () => { + expect(logErrorMock).toHaveBeenCalledWith( + '[TRAY]: Clicking of tray item "some-label" from extension "some-extension-id" failed.', + expect.any(Error), + ); + }); + }); + + describe("given click handler rejects asynchronously, when item is clicked", () => { + beforeEach(() => { + clickMock.mockImplementation(() => Promise.reject("some-rejection")); + + applicationBuilder.tray.click( + "some-label-tray-menu-item-for-extension-some-extension-id-instance-1", + ); + }); + + it("logs the error", () => { + expect(logErrorMock).toHaveBeenCalledWith( + '[TRAY]: Clicking of tray item "some-label" from extension "some-extension-id" failed.', + "some-rejection", + ); + }); + }); + + describe("when extension is disabled", () => { + beforeEach(() => { + applicationBuilder.extensions.main.disable(someExtension); + }); + + it("does not have the tray menu item from extension", () => { + applicationBuilder.extensions.main.disable(someExtension); + + expect( + applicationBuilder.tray.get( + "some-label-tray-menu-item-for-extension-some-extension-id-instance-1", + ), + ).toBeNull(); + }); + + // Note: Motivation here is to make sure that enabling same extension does not throw + it("when extension is re-enabled, has the tray menu item from extension", async () => { + await applicationBuilder.extensions.main.enable(someExtension); + + expect( + applicationBuilder.tray.get( + "some-label-tray-menu-item-for-extension-some-extension-id-instance-2", + ), + ).not.toBeNull(); + }); + }); + + }); +}); + +class SomeTestExtension extends LensMainExtension { + constructor({ id, trayMenus }: { + id: string; + trayMenus: TrayMenuRegistration[]; + }) { + super({ + id, + absolutePath: "irrelevant", + isBundled: false, + isCompatible: false, + isEnabled: false, + manifest: { name: id, version: "some-version", engines: { lens: "^5.5.0" }}, + manifestPath: "irrelevant", + }); + + this.trayMenus = trayMenus; + } +} diff --git a/src/behaviours/tray/multiple-separators-originating-from-extension.test.ts b/src/behaviours/tray/multiple-separators-originating-from-extension.test.ts new file mode 100644 index 0000000000..d2e44c24e2 --- /dev/null +++ b/src/behaviours/tray/multiple-separators-originating-from-extension.test.ts @@ -0,0 +1,54 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { LensMainExtension } from "../../extensions/lens-main-extension"; +import type { TrayMenuRegistration } from "../../main/tray/tray-menu-registration"; +import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import getRandomIdInjectable from "../../common/utils/get-random-id.injectable"; + +describe("multiple separators originating from extension", () => { + let applicationBuilder: ApplicationBuilder; + + beforeEach(async () => { + applicationBuilder = getApplicationBuilder(); + + applicationBuilder.beforeApplicationStart(({ mainDi }) => { + mainDi.unoverride(getRandomIdInjectable); + mainDi.permitSideEffects(getRandomIdInjectable); + }); + + await applicationBuilder.render(); + }); + + it("given extension with multiple separators, when extension is enabled, does not throw", () => { + const someExtension = new SomeTestExtension({ + id: "some-extension-id", + trayMenus: [{ type: "separator" }, { type: "separator" } ], + }); + + return expect( + applicationBuilder.extensions.main.enable(someExtension), + ).resolves.toBeUndefined(); + }); +}); + +class SomeTestExtension extends LensMainExtension { + constructor({ id, trayMenus }: { + id: string; + trayMenus: TrayMenuRegistration[]; + }) { + super({ + id, + absolutePath: "irrelevant", + isBundled: false, + isCompatible: false, + isEnabled: false, + manifest: { name: id, version: "some-version", engines: { lens: "^5.5.0" }}, + manifestPath: "irrelevant", + }); + + this.trayMenus = trayMenus; + } +} diff --git a/src/behaviours/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap b/src/behaviours/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap index 05eee498bf..1f1426e962 100644 --- a/src/behaviours/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap +++ b/src/behaviours/welcome/__snapshots__/navigation-using-application-menu.test.ts.snap @@ -2,6 +2,16 @@ exports[`welcome - navigation using application menu renders 1`] = `
        +
        +
        +
        +
        @@ -10,6 +20,16 @@ exports[`welcome - navigation using application menu renders 1`] = ` exports[`welcome - navigation using application menu when navigating to welcome using application menu renders 1`] = `
        +
        +
        +
        +
        { }); describe("when navigating to welcome using application menu", () => { - beforeEach(async () => { - await applicationBuilder.applicationMenu.click("help.welcome"); + beforeEach(() => { + applicationBuilder.applicationMenu.click("help.welcome"); }); it("renders", () => { diff --git a/src/common/app-event-bus/emit-event.injectable.ts b/src/common/app-event-bus/emit-event.injectable.ts new file mode 100644 index 0000000000..47bf2ca691 --- /dev/null +++ b/src/common/app-event-bus/emit-event.injectable.ts @@ -0,0 +1,13 @@ +/** + * 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 appEventBusInjectable from "./app-event-bus.injectable"; + +const emitEventInjectable = getInjectable({ + id: "emit-event", + instantiate: (di) => di.inject(appEventBusInjectable).emit, +}); + +export default emitEventInjectable; diff --git a/src/common/cluster-store/allowed-resources-injection-token.ts b/src/common/cluster-store/allowed-resources-injection-token.ts new file mode 100644 index 0000000000..ad387d26a2 --- /dev/null +++ b/src/common/cluster-store/allowed-resources-injection-token.ts @@ -0,0 +1,13 @@ +/** + * 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 { IComputedValue } from "mobx"; + +export const allowedResourcesInjectionToken = getInjectionToken< + IComputedValue> +>({ + id: "allowed-resources", +}); diff --git a/src/common/front-end-routing/route-injection-token.ts b/src/common/front-end-routing/front-end-route-injection-token.ts similarity index 82% rename from src/common/front-end-routing/route-injection-token.ts rename to src/common/front-end-routing/front-end-route-injection-token.ts index 7ecdbba635..cf1f9ed87e 100644 --- a/src/common/front-end-routing/route-injection-token.ts +++ b/src/common/front-end-routing/front-end-route-injection-token.ts @@ -6,8 +6,8 @@ import { getInjectionToken } from "@ogre-tools/injectable"; import type { IComputedValue } from "mobx"; import type { LensRendererExtension } from "../../extensions/lens-renderer-extension"; -export const routeInjectionToken = getInjectionToken>({ - id: "route-injection-token", +export const frontEndRouteInjectionToken = getInjectionToken>({ + id: "front-end-route-injection-token", }); export interface Route { diff --git a/src/common/front-end-routing/navigate-to-route-injection-token.ts b/src/common/front-end-routing/navigate-to-route-injection-token.ts index d6321f017e..29fb82867c 100644 --- a/src/common/front-end-routing/navigate-to-route-injection-token.ts +++ b/src/common/front-end-routing/navigate-to-route-injection-token.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectionToken } from "@ogre-tools/injectable"; -import type { Route } from "./route-injection-token"; +import type { Route } from "./front-end-route-injection-token"; type InferParametersFrom = TRoute extends Route ? TParameters diff --git a/src/common/front-end-routing/routes/add-cluster/add-cluster-route.injectable.ts b/src/common/front-end-routing/routes/add-cluster/add-cluster-route.injectable.ts index ce5bdcebd3..41e165dc59 100644 --- a/src/common/front-end-routing/routes/add-cluster/add-cluster-route.injectable.ts +++ b/src/common/front-end-routing/routes/add-cluster/add-cluster-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token"; const addClusterRouteInjectable = getInjectable({ id: "add-cluster-route", @@ -15,7 +15,7 @@ const addClusterRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default addClusterRouteInjectable; diff --git a/src/common/front-end-routing/routes/catalog/catalog-route.injectable.ts b/src/common/front-end-routing/routes/catalog/catalog-route.injectable.ts index 203c62e65a..bfe0904073 100644 --- a/src/common/front-end-routing/routes/catalog/catalog-route.injectable.ts +++ b/src/common/front-end-routing/routes/catalog/catalog-route.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import type { Route } from "../../route-injection-token"; -import { routeInjectionToken } from "../../route-injection-token"; +import type { Route } from "../../front-end-route-injection-token"; +import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token"; export interface CatalogPathParameters { group?: string; @@ -21,7 +21,7 @@ const catalogRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default catalogRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster-view/cluster-view-route.injectable.ts b/src/common/front-end-routing/routes/cluster-view/cluster-view-route.injectable.ts index 23fea9874b..e912ff63e0 100644 --- a/src/common/front-end-routing/routes/cluster-view/cluster-view-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster-view/cluster-view-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token"; const clusterViewRouteInjectable = getInjectable({ id: "cluster-view-route", @@ -15,7 +15,7 @@ const clusterViewRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default clusterViewRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/config/config-maps/config-maps-route.injectable.ts b/src/common/front-end-routing/routes/cluster/config/config-maps/config-maps-route.injectable.ts index b8c605fc64..3ab2bc515c 100644 --- a/src/common/front-end-routing/routes/cluster/config/config-maps/config-maps-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/config/config-maps/config-maps-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const configMapsRouteInjectable = getInjectable({ id: "config-maps-route", @@ -19,7 +19,7 @@ const configMapsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default configMapsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/config/horizontal-pod-autoscalers/horizontal-pod-autoscalers-route.injectable.ts b/src/common/front-end-routing/routes/cluster/config/horizontal-pod-autoscalers/horizontal-pod-autoscalers-route.injectable.ts index d9eff7a026..fe1814734f 100644 --- a/src/common/front-end-routing/routes/cluster/config/horizontal-pod-autoscalers/horizontal-pod-autoscalers-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/config/horizontal-pod-autoscalers/horizontal-pod-autoscalers-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const horizontalPodAutoscalersRouteInjectable = getInjectable({ id: "horizontal-pod-autoscalers-route", @@ -19,7 +19,7 @@ const horizontalPodAutoscalersRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default horizontalPodAutoscalersRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/config/limit-ranges/limit-ranges-route.injectable.ts b/src/common/front-end-routing/routes/cluster/config/limit-ranges/limit-ranges-route.injectable.ts index 70f40cb99d..bcf740113b 100644 --- a/src/common/front-end-routing/routes/cluster/config/limit-ranges/limit-ranges-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/config/limit-ranges/limit-ranges-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const limitRangesRouteInjectable = getInjectable({ id: "limit-ranges-route", @@ -22,7 +22,7 @@ const limitRangesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default limitRangesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/config/pod-disruption-budgets/pod-disruption-budgets-route.injectable.ts b/src/common/front-end-routing/routes/cluster/config/pod-disruption-budgets/pod-disruption-budgets-route.injectable.ts index 8d113e6727..df6d89fb06 100644 --- a/src/common/front-end-routing/routes/cluster/config/pod-disruption-budgets/pod-disruption-budgets-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/config/pod-disruption-budgets/pod-disruption-budgets-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const podDisruptionBudgetsRouteInjectable = getInjectable({ id: "pod-disruption-budgets-route", @@ -19,7 +19,7 @@ const podDisruptionBudgetsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default podDisruptionBudgetsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/config/resource-quotas/resource-quotas-route.injectable.ts b/src/common/front-end-routing/routes/cluster/config/resource-quotas/resource-quotas-route.injectable.ts index ee28deba5e..496a42ed0c 100644 --- a/src/common/front-end-routing/routes/cluster/config/resource-quotas/resource-quotas-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/config/resource-quotas/resource-quotas-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const resourceQuotasRouteInjectable = getInjectable({ id: "resource-quotas-route", @@ -19,7 +19,7 @@ const resourceQuotasRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default resourceQuotasRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/config/secrets/secrets-route.injectable.ts b/src/common/front-end-routing/routes/cluster/config/secrets/secrets-route.injectable.ts index 7806238e0c..f451f51d0c 100644 --- a/src/common/front-end-routing/routes/cluster/config/secrets/secrets-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/config/secrets/secrets-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const secretsRouteInjectable = getInjectable({ id: "secrets-route", @@ -19,7 +19,7 @@ const secretsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default secretsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/custom-resources/crd-list/crd-list-route.injectable.ts b/src/common/front-end-routing/routes/cluster/custom-resources/crd-list/crd-list-route.injectable.ts index 3a4865cc53..854b3a8c3a 100644 --- a/src/common/front-end-routing/routes/cluster/custom-resources/crd-list/crd-list-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/custom-resources/crd-list/crd-list-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const crdListRouteInjectable = getInjectable({ id: "crd-list-route", @@ -15,7 +15,7 @@ const crdListRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default crdListRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable.ts b/src/common/front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable.ts index 8e0709f33e..cc7d9b40be 100644 --- a/src/common/front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import type { Route } from "../../../../route-injection-token"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import type { Route } from "../../../../front-end-route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; export interface CustomResourcesPathParameters { group?: string; @@ -21,7 +21,7 @@ const customResourcesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default customResourcesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/events/events-route.injectable.ts b/src/common/front-end-routing/routes/cluster/events/events-route.injectable.ts index 6fb9ff51f9..a53cb5d1f8 100644 --- a/src/common/front-end-routing/routes/cluster/events/events-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/events/events-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const eventsRouteInjectable = getInjectable({ id: "events-route", @@ -19,7 +19,7 @@ const eventsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default eventsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/helm/charts/helm-charts-route.injectable.ts b/src/common/front-end-routing/routes/cluster/helm/charts/helm-charts-route.injectable.ts index 11509867e4..02161b082a 100644 --- a/src/common/front-end-routing/routes/cluster/helm/charts/helm-charts-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/helm/charts/helm-charts-route.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import type { Route } from "../../../../route-injection-token"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import type { Route } from "../../../../front-end-route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; export interface HelmChartsPathParameters { repo?: string; @@ -21,7 +21,7 @@ const helmChartsRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default helmChartsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/helm/releases/helm-releases-route.injectable.ts b/src/common/front-end-routing/routes/cluster/helm/releases/helm-releases-route.injectable.ts index bdc5a8a164..fb66416c63 100644 --- a/src/common/front-end-routing/routes/cluster/helm/releases/helm-releases-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/helm/releases/helm-releases-route.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import type { Route } from "../../../../route-injection-token"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import type { Route } from "../../../../front-end-route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; export interface HelmReleasesPathParameters { namespace?: string; @@ -21,7 +21,7 @@ const helmReleasesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default helmReleasesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/namespaces/namespaces-route.injectable.ts b/src/common/front-end-routing/routes/cluster/namespaces/namespaces-route.injectable.ts index 361771d575..395c128682 100644 --- a/src/common/front-end-routing/routes/cluster/namespaces/namespaces-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/namespaces/namespaces-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const namespacesRouteInjectable = getInjectable({ id: "namespaces-route", @@ -19,7 +19,7 @@ const namespacesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default namespacesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/network/endpoints/endpoints-route.injectable.ts b/src/common/front-end-routing/routes/cluster/network/endpoints/endpoints-route.injectable.ts index cc093f6cf3..e30df3123b 100644 --- a/src/common/front-end-routing/routes/cluster/network/endpoints/endpoints-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/network/endpoints/endpoints-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const endpointsRouteInjectable = getInjectable({ id: "endpoints-route", @@ -19,7 +19,7 @@ const endpointsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default endpointsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/network/ingresses/ingresses-route.injectable.ts b/src/common/front-end-routing/routes/cluster/network/ingresses/ingresses-route.injectable.ts index 8c30cefe74..12565deeaf 100644 --- a/src/common/front-end-routing/routes/cluster/network/ingresses/ingresses-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/network/ingresses/ingresses-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const ingressesRouteInjectable = getInjectable({ id: "ingresses-route", @@ -19,7 +19,7 @@ const ingressesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default ingressesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/network/network-policies/network-policies-route.injectable.ts b/src/common/front-end-routing/routes/cluster/network/network-policies/network-policies-route.injectable.ts index 99f94d68fe..ead62ee435 100644 --- a/src/common/front-end-routing/routes/cluster/network/network-policies/network-policies-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/network/network-policies/network-policies-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const networkPoliciesRouteInjectable = getInjectable({ id: "network-policies-route", @@ -19,7 +19,7 @@ const networkPoliciesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default networkPoliciesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/network/port-forwards/port-forwards-route.injectable.ts b/src/common/front-end-routing/routes/cluster/network/port-forwards/port-forwards-route.injectable.ts index 5b6814ec06..0c8cd5ef2d 100644 --- a/src/common/front-end-routing/routes/cluster/network/port-forwards/port-forwards-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/network/port-forwards/port-forwards-route.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import type { Route } from "../../../../route-injection-token"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import type { Route } from "../../../../front-end-route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; export interface PortForwardsPathParameters { forwardport?: string; @@ -20,7 +20,7 @@ const portForwardsRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default portForwardsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/network/services/services-route.injectable.ts b/src/common/front-end-routing/routes/cluster/network/services/services-route.injectable.ts index efd83a3ffa..033c95673b 100644 --- a/src/common/front-end-routing/routes/cluster/network/services/services-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/network/services/services-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const servicesRouteInjectable = getInjectable({ id: "services-route", @@ -19,7 +19,7 @@ const servicesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default servicesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/nodes/nodes-route.injectable.ts b/src/common/front-end-routing/routes/cluster/nodes/nodes-route.injectable.ts index 2713f1cc18..febd733343 100644 --- a/src/common/front-end-routing/routes/cluster/nodes/nodes-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/nodes/nodes-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const nodesRouteInjectable = getInjectable({ id: "nodes-route", @@ -19,7 +19,7 @@ const nodesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default nodesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/overview/cluster-overview-route.injectable.ts b/src/common/front-end-routing/routes/cluster/overview/cluster-overview-route.injectable.ts index 9598666209..209fc113d8 100644 --- a/src/common/front-end-routing/routes/cluster/overview/cluster-overview-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/overview/cluster-overview-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const clusterOverviewRouteInjectable = getInjectable({ id: "cluster-overview-route", @@ -19,7 +19,7 @@ const clusterOverviewRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default clusterOverviewRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/storage/persistent-volume-claims/persistent-volume-claims-route.injectable.ts b/src/common/front-end-routing/routes/cluster/storage/persistent-volume-claims/persistent-volume-claims-route.injectable.ts index a451c282e5..8879541355 100644 --- a/src/common/front-end-routing/routes/cluster/storage/persistent-volume-claims/persistent-volume-claims-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/storage/persistent-volume-claims/persistent-volume-claims-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const persistentVolumeClaimsRouteInjectable = getInjectable({ id: "persistent-volume-claims-route", @@ -19,7 +19,7 @@ const persistentVolumeClaimsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default persistentVolumeClaimsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/storage/persistent-volumes/persistent-volumes-route.injectable.ts b/src/common/front-end-routing/routes/cluster/storage/persistent-volumes/persistent-volumes-route.injectable.ts index 68c8fa08f5..e6549ea45b 100644 --- a/src/common/front-end-routing/routes/cluster/storage/persistent-volumes/persistent-volumes-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/storage/persistent-volumes/persistent-volumes-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const persistentVolumesRouteInjectable = getInjectable({ id: "persistent-volumes-route", @@ -19,7 +19,7 @@ const persistentVolumesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default persistentVolumesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/storage/storage-classes/storage-classes-route.injectable.ts b/src/common/front-end-routing/routes/cluster/storage/storage-classes/storage-classes-route.injectable.ts index 5499b5ba37..69f2b5d4ee 100644 --- a/src/common/front-end-routing/routes/cluster/storage/storage-classes/storage-classes-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/storage/storage-classes/storage-classes-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const storageClassesRouteInjectable = getInjectable({ id: "storage-classes-route", @@ -19,7 +19,7 @@ const storageClassesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default storageClassesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/user-management/cluster-role-bindings/cluster-role-bindings-route.injectable.ts b/src/common/front-end-routing/routes/cluster/user-management/cluster-role-bindings/cluster-role-bindings-route.injectable.ts index 483397e6e1..f19491ee72 100644 --- a/src/common/front-end-routing/routes/cluster/user-management/cluster-role-bindings/cluster-role-bindings-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/user-management/cluster-role-bindings/cluster-role-bindings-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const clusterRoleBindingsRouteInjectable = getInjectable({ id: "cluster-role-bindings-route", @@ -19,7 +19,7 @@ const clusterRoleBindingsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default clusterRoleBindingsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/user-management/cluster-roles/cluster-roles-route.injectable.ts b/src/common/front-end-routing/routes/cluster/user-management/cluster-roles/cluster-roles-route.injectable.ts index fced712dbf..d21c2c33a4 100644 --- a/src/common/front-end-routing/routes/cluster/user-management/cluster-roles/cluster-roles-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/user-management/cluster-roles/cluster-roles-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const clusterRolesRouteInjectable = getInjectable({ id: "cluster-roles-route", @@ -19,7 +19,7 @@ const clusterRolesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default clusterRolesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/user-management/pod-security-policies/pod-security-policies-route.injectable.ts b/src/common/front-end-routing/routes/cluster/user-management/pod-security-policies/pod-security-policies-route.injectable.ts index 89220511c1..14cfcbedc5 100644 --- a/src/common/front-end-routing/routes/cluster/user-management/pod-security-policies/pod-security-policies-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/user-management/pod-security-policies/pod-security-policies-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const podSecurityPoliciesRouteInjectable = getInjectable({ id: "pod-security-policies-route", @@ -19,7 +19,7 @@ const podSecurityPoliciesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default podSecurityPoliciesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/user-management/role-bindings/role-bindings-route.injectable.ts b/src/common/front-end-routing/routes/cluster/user-management/role-bindings/role-bindings-route.injectable.ts index 24e03d5cd9..0f908e5876 100644 --- a/src/common/front-end-routing/routes/cluster/user-management/role-bindings/role-bindings-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/user-management/role-bindings/role-bindings-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const roleBindingsRouteInjectable = getInjectable({ id: "role-bindings-route", @@ -19,7 +19,7 @@ const roleBindingsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default roleBindingsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/user-management/roles/roles-route.injectable.ts b/src/common/front-end-routing/routes/cluster/user-management/roles/roles-route.injectable.ts index 097cbb1cf5..94db156fa4 100644 --- a/src/common/front-end-routing/routes/cluster/user-management/roles/roles-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/user-management/roles/roles-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const rolesRouteInjectable = getInjectable({ id: "roles-route", @@ -19,7 +19,7 @@ const rolesRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default rolesRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/user-management/service-accounts/service-accounts-route.injectable.ts b/src/common/front-end-routing/routes/cluster/user-management/service-accounts/service-accounts-route.injectable.ts index f3424f1d8c..4d79258c54 100644 --- a/src/common/front-end-routing/routes/cluster/user-management/service-accounts/service-accounts-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/user-management/service-accounts/service-accounts-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const serviceAccountsRouteInjectable = getInjectable({ id: "service-accounts-route", @@ -19,7 +19,7 @@ const serviceAccountsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default serviceAccountsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/cron-jobs/cron-jobs-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/cron-jobs/cron-jobs-route.injectable.ts index a99e13ea1f..735ea94642 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/cron-jobs/cron-jobs-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/cron-jobs/cron-jobs-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const cronJobsRouteInjectable = getInjectable({ id: "cron-jobs-route", @@ -19,7 +19,7 @@ const cronJobsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default cronJobsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/daemonsets/daemonsets-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/daemonsets/daemonsets-route.injectable.ts index be54e18c91..55729813e8 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/daemonsets/daemonsets-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/daemonsets/daemonsets-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const daemonsetsRouteInjectable = getInjectable({ id: "daemonsets-route", @@ -19,7 +19,7 @@ const daemonsetsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default daemonsetsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/deployments/deployments-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/deployments/deployments-route.injectable.ts index 65eed20f7a..b9ff072e66 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/deployments/deployments-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/deployments/deployments-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const deploymentsRouteInjectable = getInjectable({ id: "deployments-route", @@ -19,7 +19,7 @@ const deploymentsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default deploymentsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/jobs/jobs-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/jobs/jobs-route.injectable.ts index 5b2f087dc9..d9190a7ea8 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/jobs/jobs-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/jobs/jobs-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const jobsRouteInjectable = getInjectable({ id: "jobs-route", @@ -19,7 +19,7 @@ const jobsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default jobsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/overview/workloads-overview-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/overview/workloads-overview-route.injectable.ts index 00441c2ce9..188bd9f1de 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/overview/workloads-overview-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/overview/workloads-overview-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const workloadsOverviewRouteInjectable = getInjectable({ id: "workloads-overview-route", @@ -15,7 +15,7 @@ const workloadsOverviewRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default workloadsOverviewRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/pods/pods-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/pods/pods-route.injectable.ts index b7c036cb65..e9fb2a2b16 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/pods/pods-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/pods/pods-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const podsRouteInjectable = getInjectable({ id: "pods-route", @@ -19,7 +19,7 @@ const podsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default podsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/replicasets/replicasets-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/replicasets/replicasets-route.injectable.ts index c1822339f7..0319d27550 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/replicasets/replicasets-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/replicasets/replicasets-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const replicasetsRouteInjectable = getInjectable({ id: "replicasets-route", @@ -19,7 +19,7 @@ const replicasetsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default replicasetsRouteInjectable; diff --git a/src/common/front-end-routing/routes/cluster/workloads/statefulsets/statefulsets-route.injectable.ts b/src/common/front-end-routing/routes/cluster/workloads/statefulsets/statefulsets-route.injectable.ts index ca271a22c5..a3089fa62f 100644 --- a/src/common/front-end-routing/routes/cluster/workloads/statefulsets/statefulsets-route.injectable.ts +++ b/src/common/front-end-routing/routes/cluster/workloads/statefulsets/statefulsets-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable"; -import { routeInjectionToken } from "../../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token"; const statefulsetsRouteInjectable = getInjectable({ id: "statefulsets-route", @@ -19,7 +19,7 @@ const statefulsetsRouteInjectable = getInjectable({ }; }, - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default statefulsetsRouteInjectable; diff --git a/src/common/front-end-routing/routes/entity-settings/entity-settings-route.injectable.ts b/src/common/front-end-routing/routes/entity-settings/entity-settings-route.injectable.ts index d4ff30603f..e7d3ac5f46 100644 --- a/src/common/front-end-routing/routes/entity-settings/entity-settings-route.injectable.ts +++ b/src/common/front-end-routing/routes/entity-settings/entity-settings-route.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import type { Route } from "../../route-injection-token"; -import { routeInjectionToken } from "../../route-injection-token"; +import type { Route } from "../../front-end-route-injection-token"; +import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token"; export interface EntitySettingsPathParameters { entityId: string; @@ -20,7 +20,7 @@ const entitySettingsRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default entitySettingsRouteInjectable; diff --git a/src/common/front-end-routing/routes/extensions/extensions-route.injectable.ts b/src/common/front-end-routing/routes/extensions/extensions-route.injectable.ts index 9459260412..5992355022 100644 --- a/src/common/front-end-routing/routes/extensions/extensions-route.injectable.ts +++ b/src/common/front-end-routing/routes/extensions/extensions-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token"; const extensionsRouteInjectable = getInjectable({ id: "extensions-route", @@ -15,7 +15,7 @@ const extensionsRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default extensionsRouteInjectable; diff --git a/src/common/front-end-routing/routes/preferences/app/app-preferences-route.injectable.ts b/src/common/front-end-routing/routes/preferences/app/app-preferences-route.injectable.ts index f19321f800..b4dfe5c05b 100644 --- a/src/common/front-end-routing/routes/preferences/app/app-preferences-route.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/app/app-preferences-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const appPreferencesRouteInjectable = getInjectable({ id: "app-preferences-route", @@ -15,7 +15,7 @@ const appPreferencesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default appPreferencesRouteInjectable; diff --git a/src/common/front-end-routing/routes/preferences/editor/editor-preferences-route.injectable.ts b/src/common/front-end-routing/routes/preferences/editor/editor-preferences-route.injectable.ts index 485a5a1e18..ca6cbf8a70 100644 --- a/src/common/front-end-routing/routes/preferences/editor/editor-preferences-route.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/editor/editor-preferences-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const editorPreferencesRouteInjectable = getInjectable({ id: "editor-preferences-route", @@ -15,7 +15,7 @@ const editorPreferencesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default editorPreferencesRouteInjectable; diff --git a/src/common/front-end-routing/routes/preferences/extension/extension-preferences-route.injectable.ts b/src/common/front-end-routing/routes/preferences/extension/extension-preferences-route.injectable.ts index 92a97675b0..01a87fa3c2 100644 --- a/src/common/front-end-routing/routes/preferences/extension/extension-preferences-route.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/extension/extension-preferences-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const extensionPreferencesRouteInjectable = getInjectable({ id: "extension-preferences-route", @@ -15,7 +15,7 @@ const extensionPreferencesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default extensionPreferencesRouteInjectable; diff --git a/src/common/front-end-routing/routes/preferences/kubernetes/kubernetes-preferences-route.injectable.ts b/src/common/front-end-routing/routes/preferences/kubernetes/kubernetes-preferences-route.injectable.ts index 7a84a965b6..7b3479c7fa 100644 --- a/src/common/front-end-routing/routes/preferences/kubernetes/kubernetes-preferences-route.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/kubernetes/kubernetes-preferences-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const kubernetesPreferencesRouteInjectable = getInjectable({ id: "kubernetes-preferences-route", @@ -15,7 +15,7 @@ const kubernetesPreferencesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default kubernetesPreferencesRouteInjectable; diff --git a/src/common/front-end-routing/routes/preferences/proxy/proxy-preferences-route.injectable.ts b/src/common/front-end-routing/routes/preferences/proxy/proxy-preferences-route.injectable.ts index b07925bab5..322e711225 100644 --- a/src/common/front-end-routing/routes/preferences/proxy/proxy-preferences-route.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/proxy/proxy-preferences-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const proxyPreferencesRouteInjectable = getInjectable({ id: "proxy-preferences-route", @@ -15,7 +15,7 @@ const proxyPreferencesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default proxyPreferencesRouteInjectable; diff --git a/src/common/front-end-routing/routes/preferences/telemetry/telemetry-preferences-route.injectable.ts b/src/common/front-end-routing/routes/preferences/telemetry/telemetry-preferences-route.injectable.ts index f42cb83717..2ae9f14acd 100644 --- a/src/common/front-end-routing/routes/preferences/telemetry/telemetry-preferences-route.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/telemetry/telemetry-preferences-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const telemetryPreferencesRouteInjectable = getInjectable({ id: "telemetry-preferences-route", @@ -15,7 +15,7 @@ const telemetryPreferencesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default telemetryPreferencesRouteInjectable; diff --git a/src/common/front-end-routing/routes/preferences/terminal/terminal-preferences-route.injectable.ts b/src/common/front-end-routing/routes/preferences/terminal/terminal-preferences-route.injectable.ts index 8f530b2b9d..c077c45bab 100644 --- a/src/common/front-end-routing/routes/preferences/terminal/terminal-preferences-route.injectable.ts +++ b/src/common/front-end-routing/routes/preferences/terminal/terminal-preferences-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../front-end-route-injection-token"; const terminalPreferencesRouteInjectable = getInjectable({ id: "terminal-preferences-route", @@ -15,7 +15,7 @@ const terminalPreferencesRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default terminalPreferencesRouteInjectable; diff --git a/src/common/front-end-routing/routes/welcome/welcome-route.injectable.ts b/src/common/front-end-routing/routes/welcome/welcome-route.injectable.ts index 516ee6cca4..75d722ab46 100644 --- a/src/common/front-end-routing/routes/welcome/welcome-route.injectable.ts +++ b/src/common/front-end-routing/routes/welcome/welcome-route.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import { routeInjectionToken } from "../../route-injection-token"; +import { frontEndRouteInjectionToken } from "../../front-end-route-injection-token"; const welcomeRouteInjectable = getInjectable({ id: "welcome-route", @@ -15,7 +15,7 @@ const welcomeRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); export default welcomeRouteInjectable; diff --git a/src/common/front-end-routing/verify-that-all-routes-have-route-component.test.ts b/src/common/front-end-routing/verify-that-all-routes-have-route-component.test.ts index 369fb6eb8c..4b6776bdaa 100644 --- a/src/common/front-end-routing/verify-that-all-routes-have-route-component.test.ts +++ b/src/common/front-end-routing/verify-that-all-routes-have-route-component.test.ts @@ -4,7 +4,7 @@ */ import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting"; import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token"; -import { routeInjectionToken } from "./route-injection-token"; +import { frontEndRouteInjectionToken } from "./front-end-route-injection-token"; import { filter, map, matches } from "lodash/fp"; import clusterStoreInjectable from "../cluster-store/cluster-store.injectable"; import type { ClusterStore } from "../cluster-store/cluster-store"; @@ -18,7 +18,7 @@ describe("verify-that-all-routes-have-component", () => { getById: () => null, } as unknown as ClusterStore)); - const routes = rendererDi.injectMany(routeInjectionToken); + const routes = rendererDi.injectMany(frontEndRouteInjectionToken); const routeComponents = rendererDi.injectMany( routeSpecificComponentInjectionToken, ); diff --git a/src/common/k8s-api/kube-object.store.ts b/src/common/k8s-api/kube-object.store.ts index ca4e1d9000..855e1a1315 100644 --- a/src/common/k8s-api/kube-object.store.ts +++ b/src/common/k8s-api/kube-object.store.ts @@ -7,7 +7,7 @@ import type { ClusterContext } from "./cluster-context"; import { action, computed, makeObservable, observable, reaction, when } from "mobx"; import type { Disposer } from "../utils"; -import { autoBind, includes, isRequestError, noop, rejectPromiseBy } from "../utils"; +import { waitUntilDefined, autoBind, includes, isRequestError, noop, rejectPromiseBy } from "../utils"; import type { KubeJsonApiDataFor, KubeObject } from "./kube-object"; import { KubeStatus } from "./kube-object"; import type { IKubeWatchEvent } from "./kube-watch-event"; @@ -114,7 +114,7 @@ export abstract class KubeObjectStore< this.bindWatchEventsUpdater(); } - get context(): ClusterContext { + get context(): ClusterContext | undefined { return KubeObjectStore.defaultContext.get(); } @@ -259,8 +259,9 @@ export abstract class KubeObjectStore< @action async loadAll({ namespaces, merge = true, reqInit, onLoadFailure }: KubeObjectStoreLoadAllParams = {}): Promise { - await this.contextReady; - namespaces ??= this.context.contextNamespaces; + const context = await waitUntilDefined(() => this.context); + + namespaces ??= context.contextNamespaces; this.isLoading = true; try { @@ -427,11 +428,17 @@ export abstract class KubeObjectStore< subscribe({ onLoadFailure, abortController = new AbortController() }: KubeObjectStoreSubscribeParams = {}): Disposer { if (this.api.isNamespaced) { - Promise.race([rejectPromiseBy(abortController.signal), Promise.all([this.contextReady, this.namespacesReady])]) - .then(() => { + Promise.race([ + rejectPromiseBy(abortController.signal), + Promise.all([ + waitUntilDefined(() => this.context), + this.namespacesReady, + ] as const), + ]) + .then(([context]) => { assert(this.loadedNamespaces); - if (this.context.cluster?.isGlobalWatchEnabled && this.loadedNamespaces.length === 0) { + if (context.cluster?.isGlobalWatchEnabled && this.loadedNamespaces.length === 0) { return this.watchNamespace("", abortController, { onLoadFailure }); } diff --git a/src/common/test-utils/flush-promises.ts b/src/common/test-utils/flush-promises.ts index e9f0ebea69..c2fdeff99e 100644 --- a/src/common/test-utils/flush-promises.ts +++ b/src/common/test-utils/flush-promises.ts @@ -2,4 +2,6 @@ * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ -export const flushPromises = () => new Promise(resolve => setTimeout(resolve, 0)); +import { setImmediate } from "timers"; + +export const flushPromises = () => new Promise(setImmediate); diff --git a/src/common/utils/channel/channel.test.ts b/src/common/utils/channel/channel.test.ts index f2748104d7..84c1366f35 100644 --- a/src/common/utils/channel/channel.test.ts +++ b/src/common/utils/channel/channel.test.ts @@ -70,13 +70,13 @@ describe("channel", () => { closeAllWindows(); }); - describe("given window is shown", () => { + describe("given window is started", () => { let someWindowFake: LensWindow; beforeEach(async () => { someWindowFake = createTestWindow(mainDi, "some-window"); - await someWindowFake.show(); + await someWindowFake.start(); }); it("when sending message, triggers listener in window", () => { @@ -94,12 +94,12 @@ describe("channel", () => { }); }); - it("given multiple shown windows, when sending message, triggers listeners in all windows", async () => { + it("given multiple started windows, when sending message, triggers listeners in all windows", async () => { const someWindowFake = createTestWindow(mainDi, "some-window"); const someOtherWindowFake = createTestWindow(mainDi, "some-other-window"); - await someWindowFake.show(); - await someOtherWindowFake.show(); + await someWindowFake.start(); + await someOtherWindowFake.start(); messageToChannel(testMessageChannel, "some-message"); diff --git a/src/common/utils/date/get-current-date-time.ts b/src/common/utils/date/get-current-date-time.ts new file mode 100644 index 0000000000..bf3df2bd78 --- /dev/null +++ b/src/common/utils/date/get-current-date-time.ts @@ -0,0 +1,7 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import moment from "moment"; + +export const getCurrentDateTime = () => moment().utc().format(); diff --git a/src/common/utils/is-allowed-resource.injectable.ts b/src/common/utils/is-allowed-resource.injectable.ts index 67050a7f02..8841a8f0cc 100644 --- a/src/common/utils/is-allowed-resource.injectable.ts +++ b/src/common/utils/is-allowed-resource.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable"; import { computed } from "mobx"; -import allowedResourcesInjectable from "../cluster-store/allowed-resources.injectable"; import type { KubeResource } from "../rbac"; +import { allowedResourcesInjectionToken } from "../cluster-store/allowed-resources-injection-token"; export type IsAllowedResource = (resource: KubeResource) => boolean; @@ -13,7 +13,7 @@ const isAllowedResourceInjectable = getInjectable({ id: "is-allowed-resource", instantiate: (di, resourceName: string) => { - const allowedResources = di.inject(allowedResourcesInjectable); + const allowedResources = di.inject(allowedResourcesInjectionToken); return computed(() => allowedResources.get().has(resourceName)); }, diff --git a/src/common/utils/reject-promise.ts b/src/common/utils/reject-promise.ts index 2f6c31ca2a..8212bacd3f 100644 --- a/src/common/utils/reject-promise.ts +++ b/src/common/utils/reject-promise.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ -import "abort-controller/polyfill"; +import type { AbortSignal } from "abort-controller"; /** * Creates a new promise that will be rejected when the signal rejects. @@ -11,7 +11,7 @@ import "abort-controller/polyfill"; * Useful for `Promise.race()` applications. * @param signal The AbortController's signal to reject with */ -export function rejectPromiseBy(signal: AbortSignal): Promise { +export function rejectPromiseBy(signal: AbortSignal): Promise { return new Promise((_, reject) => { signal.addEventListener("abort", reject); }); diff --git a/src/common/utils/sync-box/create-sync-box.injectable.ts b/src/common/utils/sync-box/create-sync-box.injectable.ts index 2cf3de6a69..1328106e24 100644 --- a/src/common/utils/sync-box/create-sync-box.injectable.ts +++ b/src/common/utils/sync-box/create-sync-box.injectable.ts @@ -3,6 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; +import type { IObservableValue } from "mobx"; import { computed } from "mobx"; import syncBoxChannelInjectable from "./sync-box-channel.injectable"; import { messageToChannelInjectionToken } from "../channel/message-to-channel-injection-token"; @@ -17,8 +18,8 @@ const createSyncBoxInjectable = getInjectable({ const messageToChannel = di.inject(messageToChannelInjectionToken); const getSyncBoxState = (id: string) => di.inject(syncBoxStateInjectable, id); - return (id: string, initialValue: TData): SyncBox => { - const state = getSyncBoxState(id); + return (id: string, initialValue: Value): SyncBox => { + const state = getSyncBoxState(id) as IObservableValue; state.set(initialValue); diff --git a/src/common/utils/sync-box/sync-box-injection-token.ts b/src/common/utils/sync-box/sync-box-injection-token.ts index 76ba0679f3..8db80243d3 100644 --- a/src/common/utils/sync-box/sync-box-injection-token.ts +++ b/src/common/utils/sync-box/sync-box-injection-token.ts @@ -4,21 +4,10 @@ */ import { getInjectionToken } from "@ogre-tools/injectable"; import type { IComputedValue } from "mobx"; - -type AsJson = T extends string | number | boolean | null - ? T - : T extends Function - ? never - : T extends Array - ? AsJson[] - : T extends object - ? { [K in keyof T]: AsJson } - : never; - -export interface SyncBox { +export interface SyncBox { id: string; - value: IComputedValue>; - set: (value: AsJson) => void; + value: IComputedValue; + set: (value: Value) => void; } export const syncBoxInjectionToken = getInjectionToken>({ diff --git a/src/extensions/lens-extension-set-dependencies.ts b/src/extensions/lens-extension-set-dependencies.ts index 42848f7859..0f06103af2 100644 --- a/src/extensions/lens-extension-set-dependencies.ts +++ b/src/extensions/lens-extension-set-dependencies.ts @@ -6,7 +6,7 @@ import type { IComputedValue } from "mobx"; import type { CatalogCategoryRegistry } from "../common/catalog"; import type { NavigateToRoute } from "../common/front-end-routing/navigate-to-route-injection-token"; -import type { Route } from "../common/front-end-routing/route-injection-token"; +import type { Route } from "../common/front-end-routing/front-end-route-injection-token"; import type { CatalogEntityRegistry as MainCatalogEntityRegistry } from "../main/catalog"; import type { CatalogEntityRegistry as RendererCatalogEntityRegistry } from "../renderer/api/catalog/entity/registry"; import type { GetExtensionPageParameters } from "../renderer/routes/get-extension-page-parameters.injectable"; diff --git a/src/extensions/npm/extensions/package.json b/src/extensions/npm/extensions/package.json index 0086825b22..9f145fed97 100644 --- a/src/extensions/npm/extensions/package.json +++ b/src/extensions/npm/extensions/package.json @@ -3,7 +3,7 @@ "productName": "OpenLens extensions", "description": "OpenLens - Open Source Kubernetes IDE: extensions", "version": "0.0.1", - "copyright": "© 2021 OpenLens Authors", + "copyright": "© 2022 OpenLens Authors", "license": "MIT", "main": "dist/src/extensions/extension-api.js", "types": "dist/src/extensions/extension-api.d.ts", diff --git a/src/jest.setup.ts b/src/jest.setup.ts index d22c62b4be..2ab9b1b52d 100644 --- a/src/jest.setup.ts +++ b/src/jest.setup.ts @@ -6,6 +6,7 @@ import fetchMock from "jest-fetch-mock"; import configurePackages from "./common/configure-packages"; import { configure } from "mobx"; +import { setImmediate } from "timers"; // setup default configuration for external npm-packages configurePackages(); @@ -22,8 +23,12 @@ fetchMock.enableMocks(); // Mock __non_webpack_require__ for tests globalThis.__non_webpack_require__ = jest.fn(); -global.setImmediate = global.setImmediate ?? ((callback: (...args: TArgs) => void, ...args: TArgs) => setTimeout(() => callback(...args), 0)); +global.setImmediate = setImmediate; + +global.fail = ((error = "Test failed without explicit error") => { + console.error(error); +}) as any; process.on("unhandledRejection", (err: any) => { - fail(err); + global.fail(err); }); diff --git a/src/main/application-update/check-for-updates-tray-item.injectable.ts b/src/main/application-update/check-for-updates-tray-item.injectable.ts index 5ff4be731a..29f39fa9d5 100644 --- a/src/main/application-update/check-for-updates-tray-item.injectable.ts +++ b/src/main/application-update/check-for-updates-tray-item.injectable.ts @@ -59,7 +59,7 @@ const checkForUpdatesTrayItemInjectable = getInjectable({ click: pipeline( async () => { - await processCheckingForUpdates(); + await processCheckingForUpdates("tray"); await showApplicationWindow(); }, diff --git a/src/main/application-update/check-for-updates/process-checking-for-updates.injectable.ts b/src/main/application-update/check-for-updates/process-checking-for-updates.injectable.ts index 2688d00d4a..a7066468da 100644 --- a/src/main/application-update/check-for-updates/process-checking-for-updates.injectable.ts +++ b/src/main/application-update/check-for-updates/process-checking-for-updates.injectable.ts @@ -8,11 +8,13 @@ import updatesAreBeingDiscoveredInjectable from "../../../common/application-upd import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable"; import { runInAction } from "mobx"; import askBooleanInjectable from "../../ask-boolean/ask-boolean.injectable"; -import quitAndInstallUpdateInjectable from "../../electron-app/features/quit-and-install-update.injectable"; import downloadUpdateInjectable from "../download-update/download-update.injectable"; import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable"; import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable"; import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable"; +import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable"; +import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time"; +import quitAndInstallUpdateInjectable from "../quit-and-install-update.injectable"; const processCheckingForUpdatesInjectable = getInjectable({ id: "process-checking-for-updates", @@ -27,8 +29,15 @@ const processCheckingForUpdatesInjectable = getInjectable({ const discoveredVersionState = di.inject(discoveredUpdateVersionInjectable); const checkForUpdatesStartingFromChannel = di.inject(checkForUpdatesStartingFromChannelInjectable); const withOrphanPromise = di.inject(withOrphanPromiseInjectable); + const emitEvent = di.inject(emitEventInjectable); + + return async (source: string) => { + emitEvent({ + name: "app", + action: "checking-for-updates", + params: { currentDateTime: getCurrentDateTime(), source }, + }); - return async () => { broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" }); runInAction(() => { @@ -50,6 +59,12 @@ const processCheckingForUpdatesInjectable = getInjectable({ const { version, actualUpdateChannel } = result; + emitEvent({ + name: "app", + action: "update-was-discovered", + params: { version, currentDateTime: getCurrentDateTime() }, + }); + broadcastChangeInUpdatingStatus({ eventId: "download-for-update-started", version, diff --git a/src/main/application-update/emit-current-version-to-analytics.injectable.ts b/src/main/application-update/emit-current-version-to-analytics.injectable.ts new file mode 100644 index 0000000000..fd190ebf72 --- /dev/null +++ b/src/main/application-update/emit-current-version-to-analytics.injectable.ts @@ -0,0 +1,36 @@ +/** + * 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 { afterApplicationIsLoadedInjectionToken } from "../start-main-application/runnable-tokens/after-application-is-loaded-injection-token"; +import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable"; +import { getCurrentDateTime } from "../../common/utils/date/get-current-date-time"; +import appVersionInjectable from "../../common/get-configuration-file-model/app-version/app-version.injectable"; + +const emitCurrentVersionToAnalyticsInjectable = getInjectable({ + id: "emit-current-version-to-analytics", + + instantiate: (di) => { + const emitEvent = di.inject(emitEventInjectable); + const appVersion = di.inject(appVersionInjectable); + + return { + run: () => { + emitEvent({ + name: "app", + action: "current-version", + + params: { + version: appVersion, + currentDateTime: getCurrentDateTime(), + }, + }); + }, + }; + }, + + injectionToken: afterApplicationIsLoadedInjectionToken, +}); + +export default emitCurrentVersionToAnalyticsInjectable; diff --git a/src/main/application-update/install-application-update-tray-item.injectable.ts b/src/main/application-update/install-application-update-tray-item.injectable.ts index 2f938964f8..a7a63d1a1b 100644 --- a/src/main/application-update/install-application-update-tray-item.injectable.ts +++ b/src/main/application-update/install-application-update-tray-item.injectable.ts @@ -5,12 +5,12 @@ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; import { trayMenuItemInjectionToken } from "../tray/tray-menu-item/tray-menu-item-injection-token"; -import quitAndInstallUpdateInjectable from "../electron-app/features/quit-and-install-update.injectable"; import discoveredUpdateVersionInjectable from "../../common/application-update/discovered-update-version/discovered-update-version.injectable"; import updateIsBeingDownloadedInjectable from "../../common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable"; import { withErrorSuppression } from "../../common/utils/with-error-suppression/with-error-suppression"; import { pipeline } from "@ogre-tools/fp"; import withErrorLoggingInjectable from "../../common/utils/with-error-logging/with-error-logging.injectable"; +import quitAndInstallUpdateInjectable from "./quit-and-install-update.injectable"; const installApplicationUpdateTrayItemInjectable = getInjectable({ id: "install-update-tray-item", diff --git a/src/main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable.ts b/src/main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable.ts index 394383ee65..b6b5f7b852 100644 --- a/src/main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable.ts +++ b/src/main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable.ts @@ -5,22 +5,23 @@ import { getInjectable } from "@ogre-tools/injectable"; import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable"; import processCheckingForUpdatesInjectable from "../check-for-updates/process-checking-for-updates.injectable"; +import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable"; const periodicalCheckForUpdatesInjectable = getInjectable({ id: "periodical-check-for-updates", instantiate: (di) => { - const processCheckingForUpdates = di.inject(processCheckingForUpdatesInjectable); + const withOrphanPromise = di.inject(withOrphanPromiseInjectable); + const processCheckingForUpdates = withOrphanPromise(di.inject(processCheckingForUpdatesInjectable)); return getStartableStoppable("periodical-check-for-updates", () => { const TWO_HOURS = 1000 * 60 * 60 * 2; - // Note: intentional orphan promise to make checking for updates happen in the background - processCheckingForUpdates(); + processCheckingForUpdates("periodic"); const intervalId = setInterval(() => { - // Note: intentional orphan promise to make checking for updates happen in the background - processCheckingForUpdates(); + + processCheckingForUpdates("periodic"); }, TWO_HOURS); return () => { diff --git a/src/main/application-update/quit-and-install-update.injectable.ts b/src/main/application-update/quit-and-install-update.injectable.ts new file mode 100644 index 0000000000..0ba82feac2 --- /dev/null +++ b/src/main/application-update/quit-and-install-update.injectable.ts @@ -0,0 +1,45 @@ +/** + * 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 electronQuitAndInstallUpdateInjectable from "../electron-app/features/electron-quit-and-install-update.injectable"; +import { getCurrentDateTime } from "../../common/utils/date/get-current-date-time"; +import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable"; +import discoveredUpdateVersionInjectable from "../../common/application-update/discovered-update-version/discovered-update-version.injectable"; + +const quitAndInstallUpdateInjectable = getInjectable({ + id: "quit-and-install-update", + + instantiate: (di) => { + const electronQuitAndInstallUpdate = di.inject( + electronQuitAndInstallUpdateInjectable, + ); + + const emitEvent = di.inject(emitEventInjectable); + const discoveredUpdateVersion = di.inject(discoveredUpdateVersionInjectable); + + return () => { + const discoveredVersion = discoveredUpdateVersion.value.get(); + + if (!discoveredVersion) { + throw new Error("Tried to install update but no update was discovered."); + } + + emitEvent({ + name: "app", + action: "start-installing-update", + + params: { + version: discoveredVersion.version, + updateChannel: discoveredVersion.updateChannel.id, + currentDateTime: getCurrentDateTime(), + }, + }); + + electronQuitAndInstallUpdate(); + }; + }, +}); + +export default quitAndInstallUpdateInjectable; diff --git a/src/main/ask-boolean/__snapshots__/ask-boolean.test.ts.snap b/src/main/ask-boolean/__snapshots__/ask-boolean.test.ts.snap index 8176698168..fca2c12cb9 100644 --- a/src/main/ask-boolean/__snapshots__/ask-boolean.test.ts.snap +++ b/src/main/ask-boolean/__snapshots__/ask-boolean.test.ts.snap @@ -3,6 +3,16 @@ exports[`ask-boolean given started when asking multiple questions renders 1`] = `
        +
        +
        +
        +
        @@ -150,6 +160,16 @@ exports[`ask-boolean given started when asking multiple questions renders 1`] = exports[`ask-boolean given started when asking multiple questions when answering to first question renders 1`] = `
        +
        +
        +
        +
        @@ -229,6 +249,16 @@ exports[`ask-boolean given started when asking multiple questions when answering exports[`ask-boolean given started when asking question renders 1`] = `
        +
        +
        +
        +
        @@ -308,6 +338,16 @@ exports[`ask-boolean given started when asking question renders 1`] = ` exports[`ask-boolean given started when asking question when user answers "no" renders 1`] = `
        +
        +
        +
        +
        @@ -318,6 +358,16 @@ exports[`ask-boolean given started when asking question when user answers "no" r exports[`ask-boolean given started when asking question when user answers "yes" renders 1`] = `
        +
        +
        +
        +
        @@ -328,6 +378,16 @@ exports[`ask-boolean given started when asking question when user answers "yes" exports[`ask-boolean given started when asking question when user closes notification without answering the question renders 1`] = `
        +
        +
        +
        +
        diff --git a/src/main/create-cluster/allowed-resources.injectable.ts b/src/main/create-cluster/allowed-resources.injectable.ts new file mode 100644 index 0000000000..d614ca3d17 --- /dev/null +++ b/src/main/create-cluster/allowed-resources.injectable.ts @@ -0,0 +1,16 @@ +/** + * 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 { computed } from "mobx"; +import { allowedResourcesInjectionToken } from "../../common/cluster-store/allowed-resources-injection-token"; + +// TODO: Figure out implementation for this later. +const allowedResourcesInjectable = getInjectable({ + id: "allowed-resources", + instantiate: () => computed(() => new Set()), + injectionToken: allowedResourcesInjectionToken, +}); + +export default allowedResourcesInjectable; diff --git a/src/main/electron-app/features/quit-and-install-update.injectable.ts b/src/main/electron-app/features/electron-quit-and-install-update.injectable.ts similarity index 73% rename from src/main/electron-app/features/quit-and-install-update.injectable.ts rename to src/main/electron-app/features/electron-quit-and-install-update.injectable.ts index 6b313e21b0..fb7f2fb994 100644 --- a/src/main/electron-app/features/quit-and-install-update.injectable.ts +++ b/src/main/electron-app/features/electron-quit-and-install-update.injectable.ts @@ -5,8 +5,8 @@ import { getInjectable } from "@ogre-tools/injectable"; import electronUpdaterInjectable from "./electron-updater.injectable"; -const quitAndInstallUpdateInjectable = getInjectable({ - id: "quit-and-install-update", +const electronQuitAndInstallUpdateInjectable = getInjectable({ + id: "electron-quit-and-install-update", instantiate: (di) => { const electronUpdater = di.inject(electronUpdaterInjectable); @@ -17,4 +17,4 @@ const quitAndInstallUpdateInjectable = getInjectable({ }, }); -export default quitAndInstallUpdateInjectable; +export default electronQuitAndInstallUpdateInjectable; diff --git a/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts b/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts index de4b2b357d..315b2a5689 100644 --- a/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts +++ b/src/main/electron-app/runnables/dock-visibility/hide-dock-for-last-closed-window.injectable.ts @@ -5,23 +5,19 @@ import { getInjectable } from "@ogre-tools/injectable"; import { beforeQuitOfFrontEndInjectionToken } from "../../../start-main-application/runnable-tokens/before-quit-of-front-end-injection-token"; import electronAppInjectable from "../../electron-app.injectable"; -import { lensWindowInjectionToken } from "../../../start-main-application/lens-window/application-window/lens-window-injection-token"; -import { pipeline } from "@ogre-tools/fp"; -import { filter, isEmpty } from "lodash/fp"; +import { isEmpty } from "lodash/fp"; +import getVisibleWindowsInjectable from "../../../start-main-application/lens-window/get-visible-windows.injectable"; const hideDockForLastClosedWindowInjectable = getInjectable({ id: "hide-dock-when-there-are-no-windows", instantiate: (di) => { const app = di.inject(electronAppInjectable); - const getLensWindows = () => di.injectMany(lensWindowInjectionToken); + const getVisibleWindows = di.inject(getVisibleWindowsInjectable); return { run: () => { - const visibleWindows = pipeline( - getLensWindows(), - filter(window => !!window.visible), - ); + const visibleWindows = getVisibleWindows(); if (isEmpty(visibleWindows)) { app.dock?.hide(); diff --git a/src/main/getDiForUnitTesting.ts b/src/main/getDiForUnitTesting.ts index 43f61c22cc..a022bf15ba 100644 --- a/src/main/getDiForUnitTesting.ts +++ b/src/main/getDiForUnitTesting.ts @@ -64,7 +64,7 @@ import { observable } from "mobx"; import waitForElectronToBeReadyInjectable from "./electron-app/features/wait-for-electron-to-be-ready.injectable"; import setupListenerForCurrentClusterFrameInjectable from "./start-main-application/lens-window/current-cluster-frame/setup-listener-for-current-cluster-frame.injectable"; import ipcMainInjectable from "./utils/channel/ipc-main/ipc-main.injectable"; -import createElectronWindowForInjectable from "./start-main-application/lens-window/application-window/create-electron-window-for.injectable"; +import createElectronWindowForInjectable from "./start-main-application/lens-window/application-window/create-electron-window.injectable"; import setupRunnablesAfterWindowIsOpenedInjectable from "./electron-app/runnables/setup-runnables-after-window-is-opened.injectable"; import sendToChannelInElectronBrowserWindowInjectable from "./start-main-application/lens-window/application-window/send-to-channel-in-electron-browser-window.injectable"; import broadcastMessageInjectable from "../common/ipc/broadcast-message.injectable"; @@ -72,7 +72,7 @@ import getElectronThemeInjectable from "./electron-app/features/get-electron-the import syncThemeFromOperatingSystemInjectable from "./electron-app/features/sync-theme-from-operating-system.injectable"; import platformInjectable from "../common/vars/platform.injectable"; import productNameInjectable from "./app-paths/app-name/product-name.injectable"; -import quitAndInstallUpdateInjectable from "./electron-app/features/quit-and-install-update.injectable"; +import electronQuitAndInstallUpdateInjectable from "./electron-app/features/electron-quit-and-install-update.injectable"; import electronUpdaterIsActiveInjectable from "./electron-app/features/electron-updater-is-active.injectable"; import publishIsConfiguredInjectable from "./application-update/publish-is-configured.injectable"; import checkForPlatformUpdatesInjectable from "./application-update/check-for-platform-updates/check-for-platform-updates.injectable"; @@ -97,6 +97,7 @@ import installHelmChartInjectable from "./helm/helm-service/install-helm-chart.i import listHelmReleasesInjectable from "./helm/helm-service/list-helm-releases.injectable"; import rollbackHelmReleaseInjectable from "./helm/helm-service/rollback-helm-release.injectable"; import updateHelmReleaseInjectable from "./helm/helm-service/update-helm-release.injectable"; +import waitUntilBundledExtensionsAreLoadedInjectable from "./start-main-application/lens-window/application-window/wait-until-bundled-extensions-are-loaded.injectable"; export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) { const { @@ -120,6 +121,7 @@ export function getDiForUnitTesting(opts: { doGeneralOverrides?: boolean } = {}) di.preventSideEffects(); if (doGeneralOverrides) { + di.override(waitUntilBundledExtensionsAreLoadedInjectable, () => async () => {}); di.override(getRandomIdInjectable, () => () => "some-irrelevant-random-id"); di.override(hotbarStoreInjectable, () => ({ load: () => {} })); di.override(userStoreInjectable, () => ({ startMainReactions: () => {}, extensionRegistryUrl: { customUrl: "some-custom-url" }}) as UserStore); @@ -242,13 +244,13 @@ const overrideElectronFeatures = (di: DiContainer) => { di.override(getCommandLineSwitchInjectable, () => () => "irrelevant"); di.override(requestSingleInstanceLockInjectable, () => () => true); di.override(disableHardwareAccelerationInjectable, () => () => {}); - di.override(shouldStartHiddenInjectable, () => true); + di.override(shouldStartHiddenInjectable, () => false); di.override(showMessagePopupInjectable, () => () => {}); di.override(waitForElectronToBeReadyInjectable, () => () => Promise.resolve()); di.override(ipcMainInjectable, () => ({})); di.override(getElectronThemeInjectable, () => () => "dark"); di.override(syncThemeFromOperatingSystemInjectable, () => ({ start: () => {}, stop: () => {} })); - di.override(quitAndInstallUpdateInjectable, () => () => {}); + di.override(electronQuitAndInstallUpdateInjectable, () => () => {}); di.override(setUpdateOnQuitInjectable, () => () => {}); di.override(downloadPlatformUpdateInjectable, () => async () => ({ downloadWasSuccessful: true })); @@ -256,7 +258,7 @@ const overrideElectronFeatures = (di: DiContainer) => { throw new Error("Tried to check for platform updates without explicit override."); }); - di.override(createElectronWindowForInjectable, () => () => async () => ({ + di.override(createElectronWindowForInjectable, () => () => ({ show: () => {}, close: () => {}, @@ -266,6 +268,9 @@ const overrideElectronFeatures = (di: DiContainer) => { sendFake(null, arg); }, + + loadFile: async () => {}, + loadUrl: async () => {}, })); di.override( diff --git a/src/main/index.ts b/src/main/index.ts index 3752c5a8c2..dcb8c60f8b 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -15,9 +15,7 @@ const di = getDi(); const startApplication = di.inject(startMainApplicationInjectable); -(async () => { - await startApplication(); -})(); +void startApplication(); /** * Exports for virtual package "@k8slens/extensions" for main-process. diff --git a/src/main/menu/application-menu-items.injectable.ts b/src/main/menu/application-menu-items.injectable.ts index 4ea447f675..f223c539c6 100644 --- a/src/main/menu/application-menu-items.injectable.ts +++ b/src/main/menu/application-menu-items.injectable.ts @@ -71,9 +71,10 @@ const applicationMenuItemsInjectable = getInjectable({ }, ...ignoreIf(!updatingIsEnabled, [ { + id: "check-for-updates", label: "Check for updates", click() { - processCheckingForUpdates().then(() => showApplicationWindow()); + processCheckingForUpdates("application-menu").then(() => showApplicationWindow()); }, }, ]), @@ -285,7 +286,7 @@ const applicationMenuItemsInjectable = getInjectable({ { label: "Check for updates", click() { - processCheckingForUpdates().then(() => + processCheckingForUpdates("periodic").then(() => showApplicationWindow(), ); }, diff --git a/src/main/start-main-application/lens-window/application-window/application-window.injectable.ts b/src/main/start-main-application/lens-window/application-window/application-window.injectable.ts index c63191c71c..45d7631415 100644 --- a/src/main/start-main-application/lens-window/application-window/application-window.injectable.ts +++ b/src/main/start-main-application/lens-window/application-window/application-window.injectable.ts @@ -9,9 +9,7 @@ import lensProxyPortInjectable from "../../../lens-proxy/lens-proxy-port.injecta import isMacInjectable from "../../../../common/vars/is-mac.injectable"; import appNameInjectable from "../../../app-paths/app-name/app-name.injectable"; import appEventBusInjectable from "../../../../common/app-event-bus/app-event-bus.injectable"; -import { delay } from "../../../../common/utils"; -import { bundledExtensionsLoaded } from "../../../../common/ipc/extension-handling"; -import ipcMainInjectable from "../../../utils/channel/ipc-main/ipc-main.injectable"; +import waitUntilBundledExtensionsAreLoadedInjectable from "./wait-until-bundled-extensions-are-loaded.injectable"; const applicationWindowInjectable = getInjectable({ id: "application-window", @@ -21,7 +19,7 @@ const applicationWindowInjectable = getInjectable({ const isMac = di.inject(isMacInjectable); const applicationName = di.inject(appNameInjectable); const appEventBus = di.inject(appEventBusInjectable); - const ipcMain = di.inject(ipcMainInjectable); + const waitUntilBundledExtensionsAreLoaded = di.inject(waitUntilBundledExtensionsAreLoadedInjectable); const lensProxyPort = di.inject(lensProxyPortInjectable); return createLensWindow({ @@ -45,14 +43,7 @@ const applicationWindowInjectable = getInjectable({ onDomReady: () => { appEventBus.emit({ name: "app", action: "dom-ready" }); }, - beforeOpen: async () => { - const viewHasLoaded = new Promise((resolve) => { - ipcMain.once(bundledExtensionsLoaded, () => resolve()); - }); - - await viewHasLoaded; - await delay(50); // wait just a bit longer to let the first round of rendering happen - }, + beforeOpen: waitUntilBundledExtensionsAreLoaded, }); }, diff --git a/src/main/start-main-application/lens-window/application-window/create-electron-window-for.injectable.ts b/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts similarity index 83% rename from src/main/start-main-application/lens-window/application-window/create-electron-window-for.injectable.ts rename to src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts index 5279bff30f..00fcdb6231 100644 --- a/src/main/start-main-application/lens-window/application-window/create-electron-window-for.injectable.ts +++ b/src/main/start-main-application/lens-window/application-window/create-electron-window.injectable.ts @@ -8,7 +8,7 @@ import applicationWindowStateInjectable from "./application-window-state.injecta import { BrowserWindow } from "electron"; import { openBrowser } from "../../../../common/utils"; import sendToChannelInElectronBrowserWindowInjectable from "./send-to-channel-in-electron-browser-window.injectable"; -import type { LensWindow } from "./create-lens-window.injectable"; +import type { ElectronWindow } from "./create-lens-window.injectable"; import type { RequireExactlyOne } from "type-fest"; export type ElectronWindowTitleBarStyle = "hiddenInset" | "hidden" | "default" | "customButtonsOnHover"; @@ -38,21 +38,16 @@ export interface ElectronWindowConfiguration { onDomReady?: () => void; } -export type CreateElectronWindow = () => Promise; -export type CreateElectronWindowFor = (config: ElectronWindowConfiguration) => CreateElectronWindow; +export type CreateElectronWindow = (config: ElectronWindowConfiguration) => ElectronWindow; -function isFileSource(src: ContentSource): src is FileSource { - return typeof (src as FileSource).file === "string"; -} +const createElectronWindowInjectable = getInjectable({ + id: "create-electron-window", -const createElectronWindowFor = getInjectable({ - id: "create-electron-window-for", - - instantiate: (di): CreateElectronWindowFor => { + instantiate: (di): CreateElectronWindow => { const logger = di.inject(loggerInjectable); const sendToChannelInLensWindow = di.inject(sendToChannelInElectronBrowserWindowInjectable); - return (configuration) => async () => { + return (configuration) => { const applicationWindowState = di.inject( applicationWindowStateInjectable, { @@ -172,19 +167,23 @@ const createElectronWindowFor = getInjectable({ return { action: "deny" }; }); - const contentSource = configuration.getContentSource(); - - if (isFileSource(contentSource)) { - logger.info(`[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from file: ${contentSource.file}...`); - await browserWindow.loadFile(contentSource.file); - } else { - logger.info(`[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from url: ${contentSource.url}...`); - await browserWindow.loadURL(contentSource.url); - } - - await configuration.beforeOpen?.(); - return { + loadFile: async (filePath) => { + logger.info( + `[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from file: ${filePath}...`, + ); + + await browserWindow.loadFile(filePath); + }, + + loadUrl: async (url) => { + logger.info( + `[CREATE-ELECTRON-WINDOW]: Loading content for window "${configuration.id}" from url: ${url}...`, + ); + + await browserWindow.loadURL(url); + }, + show: () => browserWindow.show(), close: () => browserWindow.close(), send: (args) => sendToChannelInLensWindow(browserWindow, args), @@ -195,4 +194,4 @@ const createElectronWindowFor = getInjectable({ causesSideEffects: true, }); -export default createElectronWindowFor; +export default createElectronWindowInjectable; diff --git a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts index a44b0ebd4c..fe43f2e41e 100644 --- a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts +++ b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts @@ -3,14 +3,17 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import type { SendToViewArgs } from "./lens-window-injection-token"; -import type { ContentSource, ElectronWindowTitleBarStyle } from "./create-electron-window-for.injectable"; -import createElectronWindowForInjectable from "./create-electron-window-for.injectable"; +import type { LensWindow, SendToViewArgs } from "./lens-window-injection-token"; +import type { ContentSource, ElectronWindowTitleBarStyle } from "./create-electron-window.injectable"; +import createElectronWindowForInjectable from "./create-electron-window.injectable"; +import assert from "assert"; -export interface LensWindow { +export interface ElectronWindow { show: () => void; close: () => void; send: (args: SendToViewArgs) => void; + loadFile: (filePath: string) => Promise; + loadUrl: (url: string) => Promise; } export interface LensWindowConfiguration { @@ -33,31 +36,69 @@ const createLensWindowInjectable = getInjectable({ id: "create-lens-window", instantiate: (di) => { - const createElectronWindowFor = di.inject(createElectronWindowForInjectable); + const createElectronWindow = di.inject(createElectronWindowForInjectable); - return (configuration: LensWindowConfiguration) => { - let browserWindow: LensWindow | undefined; + return (configuration: LensWindowConfiguration): LensWindow => { + let browserWindow: ElectronWindow | undefined; - const createElectronWindow = createElectronWindowFor({ - ...configuration, - onClose: () => browserWindow = undefined, - }); + let windowIsShown = false; + let windowIsStarting = false; + + const showWindow = () => { + assert(browserWindow); + + browserWindow.show(); + windowIsShown = true; + }; return { - get visible() { - return !!browserWindow; + id: configuration.id, + + get isVisible() { + return windowIsShown; }, - show: async () => { + + get isStarting() { + return windowIsStarting; + }, + + start: async () => { if (!browserWindow) { - browserWindow = await createElectronWindow(); + windowIsStarting = true; + + browserWindow = createElectronWindow({ + ...configuration, + onClose: () => { + browserWindow = undefined; + windowIsShown = false; + }, + }); + + const { file: filePathForContent, url: urlForContent } = + configuration.getContentSource(); + + if (filePathForContent) { + await browserWindow.loadFile(filePathForContent); + } else if (urlForContent) { + await browserWindow.loadUrl(urlForContent); + } + + await configuration.beforeOpen?.(); } - browserWindow.show(); + showWindow(); + + windowIsStarting = false; }, + + show: showWindow, + close: () => { browserWindow?.close(); browserWindow = undefined; + windowIsShown = false; }, + send: (args: SendToViewArgs) => { if (!browserWindow) { throw new Error(`Tried to send message to window "${configuration.id}" but the window was closed`); diff --git a/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts b/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts index 3e62b0894b..04c0939a6a 100644 --- a/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts +++ b/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts @@ -12,10 +12,13 @@ export interface SendToViewArgs { } export interface LensWindow { - show: () => Promise; + id: string; + start: () => Promise; close: () => void; + show: () => void; send: (args: SendToViewArgs) => void; - visible: boolean; + isVisible: boolean; + isStarting: boolean; } export const lensWindowInjectionToken = getInjectionToken({ diff --git a/src/main/start-main-application/lens-window/application-window/wait-until-bundled-extensions-are-loaded.injectable.ts b/src/main/start-main-application/lens-window/application-window/wait-until-bundled-extensions-are-loaded.injectable.ts new file mode 100644 index 0000000000..2c0f30b83b --- /dev/null +++ b/src/main/start-main-application/lens-window/application-window/wait-until-bundled-extensions-are-loaded.injectable.ts @@ -0,0 +1,29 @@ +/** + * 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 { bundledExtensionsLoaded } from "../../../../common/ipc/extension-handling"; +import { delay } from "../../../../common/utils"; +import ipcMainInjectable from "../../../utils/channel/ipc-main/ipc-main.injectable"; + +const waitUntilBundledExtensionsAreLoadedInjectable = getInjectable({ + id: "wait-until-bundled-extensions-are-loaded", + + instantiate: (di) => { + const ipcMain = di.inject(ipcMainInjectable); + + return async () => { + const viewHasLoaded = new Promise((resolve) => { + ipcMain.once(bundledExtensionsLoaded, () => resolve()); + }); + + await viewHasLoaded; + await delay(50); // wait just a bit longer to let the first round of rendering happen + }; + }, + + causesSideEffects: true, +}); + +export default waitUntilBundledExtensionsAreLoadedInjectable; diff --git a/src/main/start-main-application/lens-window/current-cluster-frame/current-cluster-frame.injectable.ts b/src/main/start-main-application/lens-window/current-cluster-frame/current-cluster-frame.injectable.ts index 2749b23253..e364b8cb0e 100644 --- a/src/main/start-main-application/lens-window/current-cluster-frame/current-cluster-frame.injectable.ts +++ b/src/main/start-main-application/lens-window/current-cluster-frame/current-cluster-frame.injectable.ts @@ -17,6 +17,10 @@ const currentClusterFrameInjectable = getInjectable({ return computed(() => { const clusterId = currentClusterFrameState.get(); + if (!clusterId) { + return undefined; + } + return clusterFrames.get(clusterId); }); }, diff --git a/src/main/start-main-application/lens-window/get-visible-windows.injectable.ts b/src/main/start-main-application/lens-window/get-visible-windows.injectable.ts new file mode 100644 index 0000000000..0179bdb377 --- /dev/null +++ b/src/main/start-main-application/lens-window/get-visible-windows.injectable.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 { pipeline } from "@ogre-tools/fp"; +import { getInjectable } from "@ogre-tools/injectable"; +import { filter } from "lodash/fp"; +import { lensWindowInjectionToken } from "./application-window/lens-window-injection-token"; + +const getVisibleWindowsInjectable = getInjectable({ + id: "get-visible-windows", + + instantiate: (di) => { + const getAllLensWindows = () => di.injectMany(lensWindowInjectionToken); + + return () => + pipeline( + getAllLensWindows(), + filter((lensWindow) => !!lensWindow.isVisible), + ); + }, +}); + +export default getVisibleWindowsInjectable; diff --git a/src/main/start-main-application/lens-window/show-application-window.injectable.ts b/src/main/start-main-application/lens-window/show-application-window.injectable.ts index b514c41891..6fa6fca62c 100644 --- a/src/main/start-main-application/lens-window/show-application-window.injectable.ts +++ b/src/main/start-main-application/lens-window/show-application-window.injectable.ts @@ -5,25 +5,36 @@ import { getInjectable } from "@ogre-tools/injectable"; import splashWindowInjectable from "./splash-window/splash-window.injectable"; import applicationWindowInjectable from "./application-window/application-window.injectable"; +import { identity, some } from "lodash/fp"; +const someIsTruthy = some(identity); const showApplicationWindowInjectable = getInjectable({ id: "show-application-window", instantiate: (di) => { const applicationWindow = di.inject(applicationWindowInjectable); - - const splashWindow = di.inject( - splashWindowInjectable, - ); + const splashWindow = di.inject(splashWindowInjectable); return async () => { - if (applicationWindow.visible) { + if (applicationWindow.isStarting) { + applicationWindow.show(); + splashWindow.close(); + return; } - await splashWindow.show(); + const windowIsAlreadyBeingShown = someIsTruthy([ + applicationWindow.isVisible, + splashWindow.isStarting, + ]); - await applicationWindow.show(); + if (windowIsAlreadyBeingShown) { + return; + } + + await splashWindow.start(); + + await applicationWindow.start(); splashWindow.close(); }; diff --git a/src/main/start-main-application/runnables/setup-sentry.injectable.ts b/src/main/start-main-application/runnables/setup-sentry.injectable.ts index d100b93cc6..4ba3763a16 100644 --- a/src/main/start-main-application/runnables/setup-sentry.injectable.ts +++ b/src/main/start-main-application/runnables/setup-sentry.injectable.ts @@ -5,7 +5,7 @@ import { getInjectable } from "@ogre-tools/injectable"; import { initializeSentryReporting } from "../../../common/sentry"; import { init } from "@sentry/electron/main"; -import { beforeApplicationIsLoadingInjectionToken } from "../runnable-tokens/before-application-is-loading-injection-token"; +import { beforeElectronIsReadyInjectionToken } from "../runnable-tokens/before-electron-is-ready-injection-token"; const setupSentryInjectable = getInjectable({ id: "setup-sentry", @@ -18,7 +18,7 @@ const setupSentryInjectable = getInjectable({ causesSideEffects: true, - injectionToken: beforeApplicationIsLoadingInjectionToken, + injectionToken: beforeElectronIsReadyInjectionToken, }); export default setupSentryInjectable; diff --git a/src/main/start-main-application/start-main-application.injectable.ts b/src/main/start-main-application/start-main-application.injectable.ts index c818d0308b..fa85d9f029 100644 --- a/src/main/start-main-application/start-main-application.injectable.ts +++ b/src/main/start-main-application/start-main-application.injectable.ts @@ -38,34 +38,36 @@ const startMainApplicationInjectable = getInjectable({ const onLoadOfApplication = runMany(onLoadOfApplicationInjectionToken); const afterApplicationIsLoaded = runMany(afterApplicationIsLoadedInjectionToken); - return async () => { + return () => { // Stuff happening before application is ready needs to be synchronous because of // https://github.com/electron/electron/issues/21370 beforeElectronIsReady(); - await waitForElectronToBeReady(); + return (async () => { + await waitForElectronToBeReady(); - await beforeApplicationIsLoading(); + await beforeApplicationIsLoading(); - if (!shouldStartHidden) { - await splashWindow.show(); - } - - await onLoadOfApplication(); - - if (!shouldStartHidden) { - const deepLinkUrl = getDeepLinkUrl(commandLineArguments); - - if (deepLinkUrl) { - await openDeepLink(deepLinkUrl); - } else { - await applicationWindow.show(); + if (!shouldStartHidden) { + await splashWindow.start(); } - splashWindow.close(); - } + await onLoadOfApplication(); - await afterApplicationIsLoaded(); + if (!shouldStartHidden) { + const deepLinkUrl = getDeepLinkUrl(commandLineArguments); + + if (deepLinkUrl) { + await openDeepLink(deepLinkUrl); + } else { + await applicationWindow.start(); + } + + splashWindow.close(); + } + + await afterApplicationIsLoaded(); + })(); }; }, }); diff --git a/src/main/tray/tray-menu-item/tray-menu-item-registrator.injectable.ts b/src/main/tray/tray-menu-item/tray-menu-item-registrator.injectable.ts index 6cbd9e5d33..fa9914b4b6 100644 --- a/src/main/tray/tray-menu-item/tray-menu-item-registrator.injectable.ts +++ b/src/main/tray/tray-menu-item/tray-menu-item-registrator.injectable.ts @@ -15,6 +15,7 @@ import type { TrayMenuRegistration } from "../tray-menu-registration"; import { withErrorSuppression } from "../../../common/utils/with-error-suppression/with-error-suppression"; import type { WithErrorLoggingFor } from "../../../common/utils/with-error-logging/with-error-logging.injectable"; import withErrorLoggingInjectable from "../../../common/utils/with-error-logging/with-error-logging.injectable"; +import getRandomIdInjectable from "../../../common/utils/get-random-id.injectable"; const trayMenuItemRegistratorInjectable = getInjectable({ id: "tray-menu-item-registrator", @@ -22,11 +23,12 @@ const trayMenuItemRegistratorInjectable = getInjectable({ instantiate: (di) => (extension, installationCounter) => { const mainExtension = extension as LensMainExtension; const withErrorLoggingFor = di.inject(withErrorLoggingInjectable); + const getRandomId = di.inject(getRandomIdInjectable); pipeline( mainExtension.trayMenus, - flatMap(toItemInjectablesFor(mainExtension, installationCounter, withErrorLoggingFor)), + flatMap(toItemInjectablesFor(mainExtension, installationCounter, withErrorLoggingFor, getRandomId)), (injectables) => di.register(...injectables), ); @@ -37,9 +39,9 @@ const trayMenuItemRegistratorInjectable = getInjectable({ export default trayMenuItemRegistratorInjectable; -const toItemInjectablesFor = (extension: LensMainExtension, installationCounter: number, withErrorLoggingFor: WithErrorLoggingFor) => { +const toItemInjectablesFor = (extension: LensMainExtension, installationCounter: number, withErrorLoggingFor: WithErrorLoggingFor, getRandomId: () => string) => { const _toItemInjectables = (parentId: string | null) => (registration: TrayMenuRegistration): Injectable[] => { - const trayItemId = registration.id || kebabCase(registration.label || ""); + const trayItemId = registration.id || kebabCase(registration.label || getRandomId()); const id = `${trayItemId}-tray-menu-item-for-extension-${extension.sanitizedExtensionId}-instance-${installationCounter}`; const parentInjectable = getInjectable({ @@ -55,20 +57,27 @@ const toItemInjectablesFor = (extension: LensMainExtension, installationCounter: label: computed(() => registration.label || ""), tooltip: registration.toolTip, - click: pipeline( - () => { - registration.click?.(registration); - }, + click: () => { + const decorated = pipeline( + registration.click || (() => {}), - withErrorLoggingFor(() => `[TRAY]: Clicking of tray item "${trayItemId}" from extension "${extension.sanitizedExtensionId}" failed.`), + withErrorLoggingFor( + () => + `[TRAY]: Clicking of tray item "${trayItemId}" from extension "${extension.sanitizedExtensionId}" failed.`, + ), - // TODO: Find out how to improve typing so that instead of - // x => withErrorSuppression(x) there could only be withErrorSuppression - (x) => withErrorSuppression(x), - ), + // TODO: Find out how to improve typing so that instead of + // x => withErrorSuppression(x) there could only be withErrorSuppression + x => withErrorSuppression(x), + ); - enabled: computed(() => !!registration.enabled), + return decorated(registration); + }, + + enabled: computed(() => registration.enabled ?? true), visible: computed(() => true), + + extension, }), injectionToken: trayMenuItemInjectionToken, diff --git a/src/main/tray/tray-menu-items.injectable.ts b/src/main/tray/tray-menu-items.injectable.ts deleted file mode 100644 index c008c123e0..0000000000 --- a/src/main/tray/tray-menu-items.injectable.ts +++ /dev/null @@ -1,19 +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 { computed } from "mobx"; -import mainExtensionsInjectable from "../../extensions/main-extensions.injectable"; - -const trayItemsInjectable = getInjectable({ - id: "tray-items", - - instantiate: (di) => { - const extensions = di.inject(mainExtensionsInjectable); - - return computed(() => extensions.get().flatMap(extension => extension.trayMenus)); - }, -}); - -export default trayItemsInjectable; diff --git a/src/main/tray/tray-menu-items.test.ts b/src/main/tray/tray-menu-items.test.ts deleted file mode 100644 index fb4f29f763..0000000000 --- a/src/main/tray/tray-menu-items.test.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import type { DiContainer } from "@ogre-tools/injectable"; -import { LensMainExtension } from "../../extensions/lens-main-extension"; -import trayItemsInjectable from "./tray-menu-items.injectable"; -import type { IComputedValue } from "mobx"; -import { computed, ObservableMap, runInAction } from "mobx"; -import { getDiForUnitTesting } from "../getDiForUnitTesting"; -import mainExtensionsInjectable from "../../extensions/main-extensions.injectable"; -import type { TrayMenuRegistration } from "./tray-menu-registration"; - -describe("tray-menu-items", () => { - let di: DiContainer; - let trayMenuItems: IComputedValue; - let extensionsStub: ObservableMap; - - beforeEach(async () => { - di = getDiForUnitTesting({ doGeneralOverrides: true }); - - extensionsStub = new ObservableMap(); - - di.override( - mainExtensionsInjectable, - () => computed(() => [...extensionsStub.values()]), - ); - - trayMenuItems = di.inject(trayItemsInjectable); - }); - - it("does not have any items yet", () => { - expect(trayMenuItems.get()).toHaveLength(0); - }); - - describe("when extension is enabled", () => { - beforeEach(() => { - const someExtension = new SomeTestExtension({ - id: "some-extension-id", - trayMenus: [{ label: "tray-menu-from-some-extension" }], - }); - - runInAction(() => { - extensionsStub.set("some-extension-id", someExtension); - }); - }); - - it("has tray menu items", () => { - expect(trayMenuItems.get()).toEqual([ - { - label: "tray-menu-from-some-extension", - }, - ]); - }); - - it("when disabling extension, does not have tray menu items", () => { - runInAction(() => { - extensionsStub.delete("some-extension-id"); - }); - - expect(trayMenuItems.get()).toHaveLength(0); - }); - - describe("when other extension is enabled", () => { - beforeEach(() => { - const someOtherExtension = new SomeTestExtension({ - id: "some-extension-id", - trayMenus: [{ label: "some-label-from-second-extension" }], - }); - - runInAction(() => { - extensionsStub.set("some-other-extension-id", someOtherExtension); - }); - }); - - it("has tray menu items for both extensions", () => { - expect(trayMenuItems.get()).toEqual([ - { - label: "tray-menu-from-some-extension", - }, - - { - label: "some-label-from-second-extension", - }, - ]); - }); - - it("when extension is disabled, still returns tray menu items for extensions that are enabled", () => { - runInAction(() => { - extensionsStub.delete("some-other-extension-id"); - }); - - expect(trayMenuItems.get()).toEqual([ - { - label: "tray-menu-from-some-extension", - }, - ]); - }); - }); - }); -}); - -class SomeTestExtension extends LensMainExtension { - constructor({ id, trayMenus }: { - id: string; - trayMenus: TrayMenuRegistration[]; - }) { - super({ - id, - absolutePath: "irrelevant", - isBundled: false, - isCompatible: false, - isEnabled: false, - manifest: { name: id, version: "some-version", engines: { lens: "^5.5.0" }}, - manifestPath: "irrelevant", - }); - - this.trayMenus = trayMenus; - } -} diff --git a/src/main/utils/channel/message-to-channel.injectable.ts b/src/main/utils/channel/message-to-channel.injectable.ts index 00e588a16a..cbcdc2badd 100644 --- a/src/main/utils/channel/message-to-channel.injectable.ts +++ b/src/main/utils/channel/message-to-channel.injectable.ts @@ -2,32 +2,24 @@ * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ -import { lensWindowInjectionToken } from "../../start-main-application/lens-window/application-window/lens-window-injection-token"; -import { pipeline } from "@ogre-tools/fp"; import { getInjectable } from "@ogre-tools/injectable"; -import { filter } from "lodash/fp"; import { messageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token"; import type { MessageChannel } from "../../../common/utils/channel/message-channel-injection-token"; import { tentativeStringifyJson } from "../../../common/utils/tentative-stringify-json"; +import getVisibleWindowsInjectable from "../../start-main-application/lens-window/get-visible-windows.injectable"; const messageToChannelInjectable = getInjectable({ id: "message-to-channel", instantiate: (di) => { - const getAllLensWindows = () => di.injectMany(lensWindowInjectionToken); + const getVisibleWindows = di.inject(getVisibleWindowsInjectable); // TODO: Figure out way to improve typing in internals // Notice that this should be injected using "messageToChannelInjectionToken" which is typed correctly. return (channel: MessageChannel, message?: unknown) => { const stringifiedMessage = tentativeStringifyJson(message); - - const visibleWindows = pipeline( - getAllLensWindows(), - filter((lensWindow) => !!lensWindow.visible), - ); - - visibleWindows.forEach((lensWindow) => + getVisibleWindows().forEach((lensWindow) => lensWindow.send({ channel: channel.id, data: stringifiedMessage ? [stringifiedMessage] : [] }), ); }; diff --git a/src/main/utils/channel/message-to-channel.test.ts b/src/main/utils/channel/message-to-channel.test.ts index cf2fc46549..67a407de55 100644 --- a/src/main/utils/channel/message-to-channel.test.ts +++ b/src/main/utils/channel/message-to-channel.test.ts @@ -43,9 +43,9 @@ describe("message to channel from main", () => { expect(sendToChannelInBrowserMock).not.toHaveBeenCalled(); }); - describe("given visible window", () => { + describe("given started window", () => { beforeEach(async () => { - await someTestWindow.show(); + await someTestWindow.start(); }); it("when messaging to channel, messages to window", () => { @@ -109,9 +109,9 @@ describe("message to channel from main", () => { }); }); - it("given multiple visible windows, when messaging to channel, messages to window", async () => { - await someTestWindow.show(); - await someOtherTestWindow.show(); + it("given multiple started windows, when messaging to channel, messages to window", async () => { + await someTestWindow.start(); + await someOtherTestWindow.start(); messageToChannel(someChannel, "some-message"); diff --git a/src/renderer/api/create-terminal-api.injectable.ts b/src/renderer/api/create-terminal-api.injectable.ts index f9f151dace..255fa396f3 100644 --- a/src/renderer/api/create-terminal-api.injectable.ts +++ b/src/renderer/api/create-terminal-api.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import assert from "assert"; -import hostedClusterIdInjectable from "../../common/cluster-store/hosted-cluster-id.injectable"; +import hostedClusterIdInjectable from "../cluster-frame-context/hosted-cluster-id.injectable"; import type { TerminalApiQuery } from "./terminal-api"; import { TerminalApi } from "./terminal-api"; diff --git a/src/common/cluster-store/allowed-resources.injectable.ts b/src/renderer/cluster-frame-context/allowed-resources.injectable.ts similarity index 82% rename from src/common/cluster-store/allowed-resources.injectable.ts rename to src/renderer/cluster-frame-context/allowed-resources.injectable.ts index 27ce2d510f..646d931367 100644 --- a/src/common/cluster-store/allowed-resources.injectable.ts +++ b/src/renderer/cluster-frame-context/allowed-resources.injectable.ts @@ -5,6 +5,7 @@ import { getInjectable } from "@ogre-tools/injectable"; import { comparer, computed } from "mobx"; import hostedClusterInjectable from "./hosted-cluster.injectable"; +import { allowedResourcesInjectionToken } from "../../common/cluster-store/allowed-resources-injection-token"; const allowedResourcesInjectable = getInjectable({ id: "allowed-resources", @@ -17,6 +18,8 @@ const allowedResourcesInjectable = getInjectable({ equals: (cur, prev) => comparer.structural(cur, prev), }); }, + + injectionToken: allowedResourcesInjectionToken, }); export default allowedResourcesInjectable; diff --git a/src/renderer/cluster-frame-context/cluster-frame-context.injectable.ts b/src/renderer/cluster-frame-context/cluster-frame-context.injectable.ts index 08a921a87e..a353a30b40 100644 --- a/src/renderer/cluster-frame-context/cluster-frame-context.injectable.ts +++ b/src/renderer/cluster-frame-context/cluster-frame-context.injectable.ts @@ -5,7 +5,7 @@ import { getInjectable } from "@ogre-tools/injectable"; import { ClusterFrameContext } from "./cluster-frame-context"; import namespaceStoreInjectable from "../components/+namespaces/store.injectable"; -import hostedClusterInjectable from "../../common/cluster-store/hosted-cluster.injectable"; +import hostedClusterInjectable from "./hosted-cluster.injectable"; import assert from "assert"; const clusterFrameContextInjectable = getInjectable({ diff --git a/src/common/cluster-store/hosted-cluster-id.injectable.ts b/src/renderer/cluster-frame-context/hosted-cluster-id.injectable.ts similarity index 87% rename from src/common/cluster-store/hosted-cluster-id.injectable.ts rename to src/renderer/cluster-frame-context/hosted-cluster-id.injectable.ts index 5a5c99c580..854e004796 100644 --- a/src/common/cluster-store/hosted-cluster-id.injectable.ts +++ b/src/renderer/cluster-frame-context/hosted-cluster-id.injectable.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { getClusterIdFromHost } from "../utils"; +import { getClusterIdFromHost } from "../../common/utils"; const hostedClusterIdInjectable = getInjectable({ id: "hosted-cluster-id", diff --git a/src/common/cluster-store/hosted-cluster.injectable.ts b/src/renderer/cluster-frame-context/hosted-cluster.injectable.ts similarity index 86% rename from src/common/cluster-store/hosted-cluster.injectable.ts rename to src/renderer/cluster-frame-context/hosted-cluster.injectable.ts index fa49cbca48..a466984952 100644 --- a/src/common/cluster-store/hosted-cluster.injectable.ts +++ b/src/renderer/cluster-frame-context/hosted-cluster.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import hostedClusterIdInjectable from "./hosted-cluster-id.injectable"; -import clusterStoreInjectable from "./cluster-store.injectable"; +import clusterStoreInjectable from "../../common/cluster-store/cluster-store.injectable"; const hostedClusterInjectable = getInjectable({ id: "hosted-cluster", diff --git a/src/renderer/components/+catalog/catalog-menu.module.scss b/src/renderer/components/+catalog/catalog-menu.module.scss index de79bb22d2..cafed28964 100644 --- a/src/renderer/components/+catalog/catalog-menu.module.scss +++ b/src/renderer/components/+catalog/catalog-menu.module.scss @@ -8,12 +8,15 @@ } .parent { - @apply uppercase font-bold; color: var(--textColorAccent); font-size: small; + text-transform: uppercase; + font-weight: bold; } .catalog { - @apply p-5 font-bold text-2xl; + font-size: medium; + padding: var(--padding) calc(var(--padding) * 1.5); + font-weight: bold; color: var(--textColorAccent); } diff --git a/src/renderer/components/+catalog/catalog.module.scss b/src/renderer/components/+catalog/catalog.module.scss index e285fb3ced..74e4bcc80f 100644 --- a/src/renderer/components/+catalog/catalog.module.scss +++ b/src/renderer/components/+catalog/catalog.module.scss @@ -48,6 +48,7 @@ transition: none; opacity: 0; margin-left: var(--padding); + width: calc(var(--unit) * 2); &:hover { /* Drop styles defined for */ diff --git a/src/renderer/components/+cluster/cluster-no-metrics.tsx b/src/renderer/components/+cluster/cluster-no-metrics.tsx index 5c981008be..ec039835fc 100644 --- a/src/renderer/components/+cluster/cluster-no-metrics.tsx +++ b/src/renderer/components/+cluster/cluster-no-metrics.tsx @@ -11,7 +11,7 @@ import { cssNames } from "../../utils"; import type { NavigateToEntitySettings } from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable"; import { withInjectables } from "@ogre-tools/injectable-react"; import navigateToEntitySettingsInjectable from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable"; -import hostedClusterInjectable from "../../../common/cluster-store/hosted-cluster.injectable"; +import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable"; export interface ClusterNoMetricsProps { className: string; diff --git a/src/renderer/components/+cluster/cluster-overview.tsx b/src/renderer/components/+cluster/cluster-overview.tsx index f17579e843..1ba8df8401 100644 --- a/src/renderer/components/+cluster/cluster-overview.tsx +++ b/src/renderer/components/+cluster/cluster-overview.tsx @@ -24,7 +24,7 @@ import { withInjectables } from "@ogre-tools/injectable-react"; import clusterOverviewStoreInjectable from "./cluster-overview-store/cluster-overview-store.injectable"; import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api"; import type { Cluster } from "../../../common/cluster/cluster"; -import hostedClusterInjectable from "../../../common/cluster-store/hosted-cluster.injectable"; +import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable"; import assert from "assert"; import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable"; import podStoreInjectable from "../+workloads-pods/store.injectable"; diff --git a/src/renderer/components/+extensions/notice.module.scss b/src/renderer/components/+extensions/notice.module.scss index ec92333704..2f1963b663 100644 --- a/src/renderer/components/+extensions/notice.module.scss +++ b/src/renderer/components/+extensions/notice.module.scss @@ -4,8 +4,12 @@ */ .notice { - @apply p-8 flex flex-col gap-2 rounded-lg; + display: flex; + flex-direction: column; + gap: calc(var(--unit) * 2); background-color: var(--inputControlBackground); border: 1px solid var(--boxShadow); color: var(--textColorTertiary); + border-radius: 4px; + padding: calc(var(--padding) * 2); } diff --git a/src/renderer/components/+helm-charts/helm-chart-details.tsx b/src/renderer/components/+helm-charts/helm-chart-details.tsx index 04e000bd1f..4e0076e068 100644 --- a/src/renderer/components/+helm-charts/helm-chart-details.tsx +++ b/src/renderer/components/+helm-charts/helm-chart-details.tsx @@ -23,6 +23,7 @@ import createInstallChartTabInjectable from "../dock/install-chart/create-instal import { Notifications } from "../notifications"; import HelmLogoPlaceholder from "./helm-placeholder.svg"; import type { SingleValue } from "react-select"; +import { AbortController } from "abort-controller"; export interface HelmChartDetailsProps { chart: HelmChart; diff --git a/src/renderer/components/+helm-releases/release-secrets.injectable.ts b/src/renderer/components/+helm-releases/release-secrets.injectable.ts new file mode 100644 index 0000000000..87fda2f181 --- /dev/null +++ b/src/renderer/components/+helm-releases/release-secrets.injectable.ts @@ -0,0 +1,37 @@ +/** + * 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 { computed, onBecomeObserved, onBecomeUnobserved } from "mobx"; +import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable"; +import secretStoreInjectable from "../+config-secrets/store.injectable"; + +const releaseSecretsInjectable = getInjectable({ + id: "release-secrets", + + instantiate: (di) => { + const subscribeStores = di.inject(subscribeStoresInjectable); + const secretStore = di.inject(secretStoreInjectable); + + const releaseSecrets = computed(() => + secretStore.contextItems.filter((secret) => + secret.type.startsWith("helm.sh/release"), + ), + ); + + let unsubscribe: () => void; + + onBecomeObserved(releaseSecrets, () => { + unsubscribe = subscribeStores([secretStore]); + }); + + onBecomeUnobserved(releaseSecrets, () => { + unsubscribe?.(); + }); + + return releaseSecrets; + }, +}); + +export default releaseSecretsInjectable; diff --git a/src/renderer/components/+helm-releases/releases.injectable.ts b/src/renderer/components/+helm-releases/releases.injectable.ts index accedf3a30..e23640de6d 100644 --- a/src/renderer/components/+helm-releases/releases.injectable.ts +++ b/src/renderer/components/+helm-releases/releases.injectable.ts @@ -7,6 +7,7 @@ import { asyncComputed } from "@ogre-tools/injectable-react"; import namespaceStoreInjectable from "../+namespaces/store.injectable"; import { listReleases } from "../../../common/k8s-api/endpoints/helm-releases.api"; import clusterFrameContextInjectable from "../../cluster-frame-context/cluster-frame-context.injectable"; +import releaseSecretsInjectable from "./release-secrets.injectable"; const releasesInjectable = getInjectable({ id: "releases", @@ -14,10 +15,13 @@ const releasesInjectable = getInjectable({ instantiate: (di) => { const clusterContext = di.inject(clusterFrameContextInjectable); const namespaceStore = di.inject(namespaceStoreInjectable); + const releaseSecrets = di.inject(releaseSecretsInjectable); return asyncComputed(async () => { const contextNamespaces = namespaceStore.contextNamespaces || []; + void releaseSecrets.get(); + const isLoadingAll = clusterContext.allNamespaces?.length > 1 && clusterContext.cluster?.accessibleNamespaces.length === 0 && diff --git a/src/renderer/components/+namespaces/namespace-select-filter.scss b/src/renderer/components/+namespaces/namespace-select-filter.scss index 00e067ddf5..5230fd7a84 100644 --- a/src/renderer/components/+namespaces/namespace-select-filter.scss +++ b/src/renderer/components/+namespaces/namespace-select-filter.scss @@ -59,6 +59,8 @@ &__option { white-space: normal; word-break: break-all; + padding: 4px 8px; + border-radius: 3px; } } diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index bcb855d585..6c50f3f921 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -82,5 +82,5 @@ const InjectedNamespaceSelect = withInjectables(props: NamespaceSelectProps): JSX.Element { - return ; + return )} />; } diff --git a/src/renderer/components/+namespaces/store.ts b/src/renderer/components/+namespaces/store.ts index 1a242839fa..1b2342facf 100644 --- a/src/renderer/components/+namespaces/store.ts +++ b/src/renderer/components/+namespaces/store.ts @@ -114,7 +114,7 @@ export class NamespaceStore extends KubeObjectStore { * if user has given static list of namespaces let's not start watches * because watch adds stuff that's not wanted or will just fail */ - if (this.context.cluster.accessibleNamespaces.length > 0) { + if ((this.context?.cluster.accessibleNamespaces.length ?? 0) > 0) { return noop; } diff --git a/src/renderer/components/+preferences/kubernetes/helm-charts/helm-charts.module.scss b/src/renderer/components/+preferences/kubernetes/helm-charts/helm-charts.module.scss index eb60ab744b..0329e7f8f7 100644 --- a/src/renderer/components/+preferences/kubernetes/helm-charts/helm-charts.module.scss +++ b/src/renderer/components/+preferences/kubernetes/helm-charts/helm-charts.module.scss @@ -4,12 +4,22 @@ */ .repos { - @apply mt-6 flex flex-col; + display: flex; + flex-direction: column; + margin-top: calc(var(--margin) * 2); +} + +.repos .repo + .repo { + margin-top: calc(var(--margin) * 1.5); +} + +.contents { + display: flex; + gap: var(--padding); } .repoName { font-weight: 500; - margin-bottom: 8px; } .repoUrl { diff --git a/src/renderer/components/+preferences/kubernetes/helm-charts/helm-repositories.tsx b/src/renderer/components/+preferences/kubernetes/helm-charts/helm-repositories.tsx index 4eeee10182..d48f648e89 100644 --- a/src/renderer/components/+preferences/kubernetes/helm-charts/helm-repositories.tsx +++ b/src/renderer/components/+preferences/kubernetes/helm-charts/helm-repositories.tsx @@ -40,14 +40,16 @@ const NonInjectedActiveHelmRepositories = observer(({ activeHelmRepositories, re removeRepository(repository)} - className="mt-3" + className={styles.repo} data-testid={`remove-helm-repository-${repository.name}`} > -
        - {repository.name} -
        +
        +
        + {repository.name} +
        -
        {repository.url}
        +
        {repository.url}
        +
        ))}
        diff --git a/src/renderer/components/+preferences/preferences-navigation/navigate-to-preference-tab.injectable.ts b/src/renderer/components/+preferences/preferences-navigation/navigate-to-preference-tab.injectable.ts index 05a20dab29..70b5da347c 100644 --- a/src/renderer/components/+preferences/preferences-navigation/navigate-to-preference-tab.injectable.ts +++ b/src/renderer/components/+preferences/preferences-navigation/navigate-to-preference-tab.injectable.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import type { Route } from "../../../../common/front-end-routing/route-injection-token"; +import type { Route } from "../../../../common/front-end-routing/front-end-route-injection-token"; import { navigateToRouteInjectionToken } from "../../../../common/front-end-routing/navigate-to-route-injection-token"; const navigateToPreferenceTabInjectable = getInjectable({ diff --git a/src/renderer/components/+preferences/removable-item.module.scss b/src/renderer/components/+preferences/removable-item.module.scss index e170da9532..6734dda5b9 100644 --- a/src/renderer/components/+preferences/removable-item.module.scss +++ b/src/renderer/components/+preferences/removable-item.module.scss @@ -1,7 +1,8 @@ .item { - --flex-gap: 1.2rem; + --flex-gap: 0.5rem; - @apply rounded-md px-7 py-5 shadow-sm; background: var(--inputControlBackground); min-height: 65px; + border-radius: 3px; + padding: calc(var(--padding) * 1.5); } \ No newline at end of file diff --git a/src/renderer/components/app.scss b/src/renderer/components/app.scss index 80317acb59..68cc6db3d9 100755 --- a/src/renderer/components/app.scss +++ b/src/renderer/components/app.scss @@ -68,6 +68,9 @@ html, body { height: 100%; overflow: hidden; +} + +body { color: var(--textColorPrimary); background-color: var(--mainBackground); font-size: var(--font-size); diff --git a/src/renderer/components/badge/badge.module.scss b/src/renderer/components/badge/badge.module.scss index e5d0f7b0a1..f3c6bcf13a 100644 --- a/src/renderer/components/badge/badge.module.scss +++ b/src/renderer/components/badge/badge.module.scss @@ -15,7 +15,6 @@ &:not(.isExpanded) { white-space: unset; - overflow: unset; text-overflow: unset; } } diff --git a/src/renderer/components/command-palette/command-container.tsx b/src/renderer/components/command-palette/command-container.tsx index 3154917842..759e41e312 100644 --- a/src/renderer/components/command-palette/command-container.tsx +++ b/src/renderer/components/command-palette/command-container.tsx @@ -21,7 +21,7 @@ import windowAddEventListenerInjectable from "../../window/event-listener.inject import type { IComputedValue } from "mobx"; import matchedClusterIdInjectable from "../../navigation/matched-cluster-id.injectable"; import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable"; -import hostedClusterIdInjectable from "../../../common/cluster-store/hosted-cluster-id.injectable"; +import hostedClusterIdInjectable from "../../cluster-frame-context/hosted-cluster-id.injectable"; interface Dependencies { addWindowEventListener: (type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions) => Disposer; diff --git a/src/renderer/components/delete-cluster-dialog/__tests__/delete-cluster-dialog.test.tsx b/src/renderer/components/delete-cluster-dialog/__tests__/delete-cluster-dialog.test.tsx index ded5cf8098..02d1c7e96c 100644 --- a/src/renderer/components/delete-cluster-dialog/__tests__/delete-cluster-dialog.test.tsx +++ b/src/renderer/components/delete-cluster-dialog/__tests__/delete-cluster-dialog.test.tsx @@ -20,7 +20,7 @@ import storesAndApisCanBeCreatedInjectable from "../../../stores-apis-can-be-cre import createKubeconfigManagerInjectable from "../../../../main/kubeconfig-manager/create-kubeconfig-manager.injectable"; import type { ApplicationBuilder } from "../../test-utils/get-application-builder"; import { getApplicationBuilder } from "../../test-utils/get-application-builder"; -import { routeInjectionToken } from "../../../../common/front-end-routing/route-injection-token"; +import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token"; import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; import { routeSpecificComponentInjectionToken } from "../../../routes/route-specific-component-injection-token"; @@ -319,7 +319,7 @@ const testRouteInjectable = getInjectable({ isEnabled: computed(() => true), }), - injectionToken: routeInjectionToken, + injectionToken: frontEndRouteInjectionToken, }); const testRouteComponentInjectable = getInjectable({ diff --git a/src/renderer/components/delete-cluster-dialog/view.module.scss b/src/renderer/components/delete-cluster-dialog/view.module.scss index 0c95c3d2a6..e8f513a991 100644 --- a/src/renderer/components/delete-cluster-dialog/view.module.scss +++ b/src/renderer/components/delete-cluster-dialog/view.module.scss @@ -1,17 +1,22 @@ .warning { - @apply mt-4 flex py-4 px-6 rounded-md items-center; + display: flex; + margin-top: var(--margin); + padding: calc(var(--padding) * 2) calc(var(--padding) * 3); + border-radius: 4px; + align-items: center; background: #fad8d7; color: #797979; } .warningIcon { - @apply mr-5; + margin-right: calc(var(--margin) * 2.4); font-size: 26px; } .dialog { > div { - @apply rounded-md bg-white; + border-radius: 4px; + background-color: white; max-width: 600px; min-width: calc(45 * var(--unit)); } @@ -22,11 +27,14 @@ } .dialogContent { - @apply p-9 leading-9; + padding: calc(var(--padding) * 2) calc(var(--padding) * 3); } .dialogButtons { - @apply flex justify-end p-7 rounded-md; + display: flex; + border-radius: 4px; + justify-content: flex-end; + padding: calc(var(--padding) * 2); background: #f4f4f4; > * { @@ -35,7 +43,7 @@ } .hr { - @apply mt-7; + margin-top: calc(var(--margin) * 3); height: 1px; background: #dfdfdf80; } \ No newline at end of file diff --git a/src/renderer/components/delete-cluster-dialog/view.tsx b/src/renderer/components/delete-cluster-dialog/view.tsx index 79e0ea88ee..3d86bae4a9 100644 --- a/src/renderer/components/delete-cluster-dialog/view.tsx +++ b/src/renderer/components/delete-cluster-dialog/view.tsx @@ -204,9 +204,9 @@ class NonInjectedDeleteClusterDialog extends React.Component {
        {this.renderDeleteMessage(state)} {this.renderWarning(state)} -
        {contexts.length > 0 && ( <> +
        ({ app: { diff --git a/src/renderer/components/dock/dock-tab.module.scss b/src/renderer/components/dock/dock-tab.module.scss index 3b803f32c7..64bd4768ff 100644 --- a/src/renderer/components/dock/dock-tab.module.scss +++ b/src/renderer/components/dock/dock-tab.module.scss @@ -94,5 +94,5 @@ .title { overflow: hidden; text-overflow: ellipsis; - margin-right: 2.5rem; + margin-right: calc(var(--margin) * 3); } diff --git a/src/renderer/components/dock/logs/to-bottom.tsx b/src/renderer/components/dock/logs/to-bottom.tsx index 99df41a85c..f9b5cbb03e 100644 --- a/src/renderer/components/dock/logs/to-bottom.tsx +++ b/src/renderer/components/dock/logs/to-bottom.tsx @@ -8,7 +8,7 @@ import { Icon } from "../../icon"; export function ToBottom({ onClick }: { onClick: () => void }) { return (