1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Merge branch 'master' into show-extension-preferences-in-separate-page

This commit is contained in:
Alex Andreev 2022-06-09 14:11:44 +03:00
commit 88cce075ec
48 changed files with 506 additions and 305 deletions

View File

@ -16,8 +16,8 @@ jobs:
vmImage: windows-2019 vmImage: windows-2019
strategy: strategy:
matrix: matrix:
node_14.x: node:
node_version: 14.x node_version: 16.x
steps: steps:
- powershell: | - powershell: |
$CI_BUILD_TAG = git describe --tags $CI_BUILD_TAG = git describe --tags
@ -64,8 +64,8 @@ jobs:
vmImage: macOS-11 vmImage: macOS-11
strategy: strategy:
matrix: matrix:
node_14.x: node:
node_version: 14.x node_version: 16.x
steps: steps:
- script: CI_BUILD_TAG=`git describe --tags` && echo "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG" - script: CI_BUILD_TAG=`git describe --tags` && echo "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG"
condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))"
@ -128,8 +128,8 @@ jobs:
vmImage: ubuntu-18.04 vmImage: ubuntu-18.04
strategy: strategy:
matrix: matrix:
node_14.x: node:
node_version: 14.x node_version: 16.x
steps: steps:
- script: CI_BUILD_TAG=`git describe --tags` && echo "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG" - script: CI_BUILD_TAG=`git describe --tags` && echo "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG"
condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))"

View File

@ -9,7 +9,7 @@ jobs:
if: ${{ contains(github.event.pull_request.labels.*.name, 'area/documentation') }} if: ${{ contains(github.event.pull_request.labels.*.name, 'area/documentation') }}
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
steps: steps:
- name: Checkout Release from lens - name: Checkout Release from lens
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -14,12 +14,12 @@ jobs:
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: "14" node-version: "16"
- uses: doyensec/electronegativity-action@v1.1 - uses: doyensec/electronegativity-action@v1.1
with: with:
input: src/ input: src/
electron-version: "14.2.4" electron-version: "15.5.7"
severity: medium severity: medium
- name: Upload sarif - name: Upload sarif

View File

@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
steps: steps:
- name: Checkout Release from lens - name: Checkout Release from lens
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
steps: steps:
- name: Set up Python 3.7 - name: Set up Python 3.7
uses: actions/setup-python@v2 uses: actions/setup-python@v2
@ -46,7 +46,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
needs: verify-docs needs: verify-docs
steps: steps:
- name: Set up Python 3.7 - name: Set up Python 3.7

View File

@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
steps: steps:
- name: Set up Python 3.7 - name: Set up Python 3.7
uses: actions/setup-python@v2 uses: actions/setup-python@v2

View File

@ -14,7 +14,7 @@ jobs:
${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'area/extension') }} ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'area/extension') }}
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
steps: steps:
- name: Checkout Release - name: Checkout Release
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [14.x] node-version: [16.x]
steps: steps:
- name: Checkout Release - name: Checkout Release
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -13,7 +13,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-18.04, macos-11, windows-2019] os: [ubuntu-18.04, macos-11, windows-2019]
node-version: [14.x] node-version: [16.x]
steps: steps:
- name: Checkout Release from lens - name: Checkout Release from lens
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -1,3 +1,3 @@
disturl "https://atom.io/download/electron" disturl "https://atom.io/download/electron"
target "14.2.4" target "15.5.0"
runtime "electron" runtime "electron"

View File

@ -56,6 +56,7 @@ integration: build
build: node_modules binaries/client build: node_modules binaries/client
yarn run npm:fix-build-version yarn run npm:fix-build-version
$(MAKE) build-extensions -B $(MAKE) build-extensions -B
yarn run build:tray-icons
yarn run compile yarn run compile
ifeq "$(DETECTED_OS)" "Windows" ifeq "$(DETECTED_OS)" "Windows"
# https://github.com/ukoloff/win-ca#clear-pem-folder-on-publish # https://github.com/ukoloff/win-ca#clear-pem-folder-on-publish

View File

@ -3,8 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { readFileSync } from "fs"; import { ensureDir, readFile } from "fs-extra";
import { ensureDirSync } from "fs-extra";
import { JSDOM } from "jsdom"; import { JSDOM } from "jsdom";
import path from "path"; import path from "path";
import sharp from "sharp"; import sharp from "sharp";
@ -12,39 +11,120 @@ import sharp from "sharp";
const size = Number(process.env.OUTPUT_SIZE || "16"); const size = Number(process.env.OUTPUT_SIZE || "16");
const outputFolder = process.env.OUTPUT_DIR || "./build/tray"; const outputFolder = process.env.OUTPUT_DIR || "./build/tray";
const inputFile = process.env.INPUT_SVG_PATH || "./src/renderer/components/icon/logo-lens.svg"; const inputFile = process.env.INPUT_SVG_PATH || "./src/renderer/components/icon/logo-lens.svg";
const noticeFile = process.env.NOTICE_SVG_PATH || "./src/renderer/components/icon/notice.svg";
const svgData = readFileSync(inputFile, { encoding: "utf-8" }); async function ensureOutputFoler() {
const svgDom = new JSDOM(`<body>${svgData}</body>`); await ensureDir(outputFolder);
const svgRoot = svgDom.window.document.body.getElementsByTagName("svg")[0]; }
svgRoot.innerHTML += `<style>* {fill: white !important;}</style>`; function getSvgStyling(colouring: "dark" | "light"): string {
const lightTemplate = svgRoot.outerHTML; return `
<style>
ellipse {
stroke: ${colouring === "dark" ? "white" : "black"} !important;
}
path, rect {
fill: ${colouring === "dark" ? "white" : "black"} !important;
}
</style>
`;
}
svgRoot.innerHTML += `<style>* {fill: black !important;}</style>`; type TargetSystems = "macos" | "windows-or-linux";
const darkTemplate = svgRoot.outerHTML; async function getBaseIconImage(system: TargetSystems) {
const svgData = await readFile(inputFile, { encoding: "utf-8" });
const dom = new JSDOM(`<body>${svgData}</body>`);
const root = dom.window.document.body.getElementsByTagName("svg")[0];
console.log("Generating tray icon pngs"); root.innerHTML += getSvgStyling(system === "macos" ? "light" : "dark");
ensureDirSync(outputFolder); return Buffer.from(root.outerHTML);
}
Promise.all([ async function generateImage(image: Buffer, size: number, namePrefix: string) {
sharp(Buffer.from(lightTemplate)) sharp(image)
.resize({ width: size, height: size }) .resize({ width: size, height: size })
.png() .png()
.toFile(path.join(outputFolder, "trayIconDarkTemplate.png")), .toFile(path.join(outputFolder, `${namePrefix}.png`));
sharp(Buffer.from(lightTemplate)) }
.resize({ width: size*2, height: size*2 })
.png() async function generateImages(image: Buffer, size: number, name: string) {
.toFile(path.join(outputFolder, "trayIconDarkTemplate@2x.png")), await Promise.all([
sharp(Buffer.from(darkTemplate)) generateImage(image, size, name),
.resize({ width: size, height: size }) generateImage(image, size*2, `${name}@2x`),
.png() generateImage(image, size*3, `${name}@3x`),
.toFile(path.join(outputFolder, "trayIconTemplate.png")), generateImage(image, size*4, `${name}@4x`),
sharp(Buffer.from(darkTemplate)) ]);
.resize({ width: size*2, height: size*2 }) }
.png()
.toFile(path.join(outputFolder, "trayIconTemplate@2x.png")), async function generateUpdateAvailableImages(baseImage: Buffer, system: TargetSystems) {
]) const noticeIconImage = await getNoticeIconImage(system);
.then((resolutions) => console.log(`Generated ${resolutions.length} images`)) const circleBuffer = await sharp(Buffer.from(`
.catch(console.error); <svg viewBox="0 0 64 64">
<circle cx="32" cy="32" r="32" fill="black" />
</svg>
`))
.toBuffer();
return sharp(baseImage)
.resize({ width: 128, height: 128 })
.composite([
{
input: circleBuffer,
top: 64,
left: 64,
blend: "dest-out",
},
{
input: (
await sharp(noticeIconImage)
.resize({
width: 60,
height: 60,
})
.toBuffer()
),
top: 66,
left: 66,
},
])
.toBuffer();
}
async function getNoticeIconImage(system: TargetSystems) {
const svgData = await readFile(noticeFile, { encoding: "utf-8" });
const root = new JSDOM(svgData).window.document.getElementsByTagName("svg")[0];
root.innerHTML += getSvgStyling(system === "macos" ? "light" : "dark");
return Buffer.from(root.outerHTML);
}
async function generateTrayIcons() {
try {
console.log("Generating tray icon pngs");
await ensureOutputFoler();
const baseIconTemplateImage = await getBaseIconImage("macos");
const updateAvailableTemplateImage = await generateUpdateAvailableImages(baseIconTemplateImage, "macos");
const baseIconImage = await getBaseIconImage("windows-or-linux");
const updateAvailableImage = await generateUpdateAvailableImages(baseIconImage, "windows-or-linux");
await Promise.all([
// Templates are for macOS only
generateImages(baseIconTemplateImage, size, "trayIconTemplate"),
generateImages(updateAvailableTemplateImage, size, "trayIconUpdateAvailableTemplate"),
// Non-templates are for windows and linux
generateImages(baseIconImage, size, "trayIcon"),
generateImages(updateAvailableImage, size, "trayIconUpdateAvailable"),
]);
console.log("Generated all images");
} catch (error) {
console.error(error);
}
}
generateTrayIcons();

View File

Before

Width:  |  Height:  |  Size: 392 B

After

Width:  |  Height:  |  Size: 392 B

View File

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

BIN
build/tray/trayIcon@3x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
build/tray/trayIcon@4x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -52,7 +52,7 @@
"sentryDsn": "" "sentryDsn": ""
}, },
"engines": { "engines": {
"node": ">=14 <15" "node": ">=16 <17"
}, },
"jest": { "jest": {
"collectCoverage": false, "collectCoverage": false,
@ -250,7 +250,7 @@
"monaco-editor": "^0.29.1", "monaco-editor": "^0.29.1",
"monaco-editor-webpack-plugin": "^5.0.0", "monaco-editor-webpack-plugin": "^5.0.0",
"node-fetch": "lensapp/node-fetch#2.x", "node-fetch": "lensapp/node-fetch#2.x",
"node-pty": "^0.10.1", "node-pty": "^0.11.0-beta19",
"npm": "^6.14.17", "npm": "^6.14.17",
"p-limit": "^3.1.0", "p-limit": "^3.1.0",
"path-to-regexp": "^6.2.0", "path-to-regexp": "^6.2.0",
@ -313,7 +313,7 @@
"@types/md5-file": "^4.0.2", "@types/md5-file": "^4.0.2",
"@types/mini-css-extract-plugin": "^2.4.0", "@types/mini-css-extract-plugin": "^2.4.0",
"@types/mock-fs": "^4.13.1", "@types/mock-fs": "^4.13.1",
"@types/node": "14.18.18", "@types/node": "^16.11.39",
"@types/node-fetch": "^2.6.1", "@types/node-fetch": "^2.6.1",
"@types/npm": "^2.0.32", "@types/npm": "^2.0.32",
"@types/proper-lockfile": "^4.1.2", "@types/proper-lockfile": "^4.1.2",
@ -343,7 +343,7 @@
"@types/webpack-dev-server": "^4.7.2", "@types/webpack-dev-server": "^4.7.2",
"@types/webpack-env": "^1.17.0", "@types/webpack-env": "^1.17.0",
"@types/webpack-node-externals": "^2.5.3", "@types/webpack-node-externals": "^2.5.3",
"@typescript-eslint/eslint-plugin": "^5.27.0", "@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.0", "@typescript-eslint/parser": "^5.27.0",
"ansi_up": "^5.1.0", "ansi_up": "^5.1.0",
"chart.js": "^2.9.4", "chart.js": "^2.9.4",
@ -355,7 +355,7 @@
"css-loader": "^6.7.1", "css-loader": "^6.7.1",
"deepdash": "^5.3.9", "deepdash": "^5.3.9",
"dompurify": "^2.3.8", "dompurify": "^2.3.8",
"electron": "^14.2.9", "electron": "^15.5.7",
"electron-builder": "^23.0.3", "electron-builder": "^23.0.3",
"electron-notarize": "^0.3.0", "electron-notarize": "^0.3.0",
"esbuild": "^0.14.38", "esbuild": "^0.14.38",

View File

@ -44,7 +44,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_13" data-testid="close-notification-for-notification_16"
tabindex="0" tabindex="0"
> >
<span <span
@ -95,7 +95,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_96" data-testid="close-notification-for-notification_115"
tabindex="0" tabindex="0"
> >
<span <span
@ -135,7 +135,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_99" data-testid="close-notification-for-notification_118"
tabindex="0" tabindex="0"
> >
<span <span
@ -186,7 +186,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_149" data-testid="close-notification-for-notification_183"
tabindex="0" tabindex="0"
> >
<span <span
@ -226,7 +226,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_152" data-testid="close-notification-for-notification_186"
tabindex="0" tabindex="0"
> >
<span <span
@ -266,7 +266,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_157" data-testid="close-notification-for-notification_191"
tabindex="0" tabindex="0"
> >
<span <span
@ -317,7 +317,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_215" data-testid="close-notification-for-notification_266"
tabindex="0" tabindex="0"
> >
<span <span
@ -357,7 +357,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_218" data-testid="close-notification-for-notification_269"
tabindex="0" tabindex="0"
> >
<span <span
@ -478,7 +478,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_48" data-testid="close-notification-for-notification_59"
tabindex="0" tabindex="0"
> >
<span <span
@ -518,7 +518,7 @@ exports[`installing update using tray when started when user checks for updates
> >
<i <i
class="Icon close material interactive focusable" class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_51" data-testid="close-notification-for-notification_62"
tabindex="0" tabindex="0"
> >
<span <span

View File

@ -15,12 +15,15 @@ import type { DownloadPlatformUpdate } from "../../main/application-update/downl
import downloadPlatformUpdateInjectable 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 showApplicationWindowInjectable from "../../main/start-main-application/lens-window/show-application-window.injectable"; import showApplicationWindowInjectable from "../../main/start-main-application/lens-window/show-application-window.injectable";
import progressOfUpdateDownloadInjectable from "../../common/application-update/progress-of-update-download/progress-of-update-download.injectable"; import progressOfUpdateDownloadInjectable from "../../common/application-update/progress-of-update-download/progress-of-update-download.injectable";
import type { TrayIconPaths } from "../../main/tray/tray-icon-path.injectable";
import trayIconPathsInjectable from "../../main/tray/tray-icon-path.injectable";
describe("installing update using tray", () => { describe("installing update using tray", () => {
let applicationBuilder: ApplicationBuilder; let applicationBuilder: ApplicationBuilder;
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>; let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>; let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
let showApplicationWindowMock: jest.Mock; let showApplicationWindowMock: jest.Mock;
let trayIconPaths: TrayIconPaths;
beforeEach(() => { beforeEach(() => {
applicationBuilder = getApplicationBuilder(); applicationBuilder = getApplicationBuilder();
@ -44,6 +47,7 @@ describe("installing update using tray", () => {
mainDi.override(electronUpdaterIsActiveInjectable, () => true); mainDi.override(electronUpdaterIsActiveInjectable, () => true);
mainDi.override(publishIsConfiguredInjectable, () => true); mainDi.override(publishIsConfiguredInjectable, () => true);
trayIconPaths = mainDi.inject(trayIconPathsInjectable);
}); });
}); });
@ -58,22 +62,29 @@ describe("installing update using tray", () => {
expect(rendered.baseElement).toMatchSnapshot(); expect(rendered.baseElement).toMatchSnapshot();
}); });
it("should use the normal tray icon", () => {
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
});
it("user cannot install update yet", () => { it("user cannot install update yet", () => {
expect(applicationBuilder.tray.get("install-update")).toBeUndefined(); expect(applicationBuilder.tray.get("install-update")).toBeNull();
}); });
describe("when user checks for updates using tray", () => { describe("when user checks for updates using tray", () => {
let processCheckingForUpdatesPromise: Promise<void>; let processCheckingForUpdatesPromise: Promise<void>;
beforeEach(async () => { beforeEach(async () => {
processCheckingForUpdatesPromise = processCheckingForUpdatesPromise = applicationBuilder.tray.click("check-for-updates");
applicationBuilder.tray.click("check-for-updates");
}); });
it("does not show application window yet", () => { it("does not show application window yet", () => {
expect(showApplicationWindowMock).not.toHaveBeenCalled(); expect(showApplicationWindowMock).not.toHaveBeenCalled();
}); });
it("should still use the normal tray icon", () => {
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
});
it("user cannot check for updates again", () => { it("user cannot check for updates again", () => {
expect( expect(
applicationBuilder.tray.get("check-for-updates")?.enabled.get(), applicationBuilder.tray.get("check-for-updates")?.enabled.get(),
@ -87,7 +98,7 @@ describe("installing update using tray", () => {
}); });
it("user cannot install update yet", () => { it("user cannot install update yet", () => {
expect(applicationBuilder.tray.get("install-update")).toBeUndefined(); expect(applicationBuilder.tray.get("install-update")).toBeNull();
}); });
it("renders", () => { it("renders", () => {
@ -107,8 +118,12 @@ describe("installing update using tray", () => {
expect(showApplicationWindowMock).toHaveBeenCalled(); expect(showApplicationWindowMock).toHaveBeenCalled();
}); });
it("should still use the normal tray icon", () => {
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
});
it("user cannot install update", () => { it("user cannot install update", () => {
expect(applicationBuilder.tray.get("install-update")).toBeUndefined(); expect(applicationBuilder.tray.get("install-update")).toBeNull();
}); });
it("user can check for updates again", () => { it("user can check for updates again", () => {
@ -142,6 +157,10 @@ describe("installing update using tray", () => {
expect(showApplicationWindowMock).toHaveBeenCalled(); expect(showApplicationWindowMock).toHaveBeenCalled();
}); });
it("should use the update available icon", () => {
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.updateAvailable);
});
it("user cannot check for updates again yet", () => { it("user cannot check for updates again yet", () => {
expect( expect(
applicationBuilder.tray.get("check-for-updates")?.enabled.get(), applicationBuilder.tray.get("check-for-updates")?.enabled.get(),
@ -167,7 +186,7 @@ describe("installing update using tray", () => {
}); });
it("user still cannot install update", () => { it("user still cannot install update", () => {
expect(applicationBuilder.tray.get("install-update")).toBeUndefined(); expect(applicationBuilder.tray.get("install-update")).toBeNull();
}); });
it("renders", () => { it("renders", () => {
@ -182,7 +201,11 @@ describe("installing update using tray", () => {
it("user cannot install update", () => { it("user cannot install update", () => {
expect( expect(
applicationBuilder.tray.get("install-update"), applicationBuilder.tray.get("install-update"),
).toBeUndefined(); ).toBeNull();
});
it("should revert to use the normal tray icon", () => {
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
}); });
it("user can check for updates again", () => { it("user can check for updates again", () => {
@ -213,6 +236,10 @@ describe("installing update using tray", () => {
).toBe("Install update some-version"); ).toBe("Install update some-version");
}); });
it("should use the update available icon", () => {
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.updateAvailable);
});
it("user can check for updates again", () => { it("user can check for updates again", () => {
expect( expect(
applicationBuilder.tray.get("check-for-updates")?.enabled.get(), applicationBuilder.tray.get("check-for-updates")?.enabled.get(),

View File

@ -3,6 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
export type UpdateChannelId = "alpha" | "beta" | "latest"; export type UpdateChannelId = "alpha" | "beta" | "latest";
const latestChannel: UpdateChannel = { const latestChannel: UpdateChannel = {

View File

@ -4,12 +4,21 @@
*/ */
import { getInjectionToken } from "@ogre-tools/injectable"; import { getInjectionToken } from "@ogre-tools/injectable";
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import type { JsonValue } from "type-fest";
export interface SyncBox<TValue extends JsonValue> { type AsJson<T> = T extends string | number | boolean | null
? T
: T extends Function
? never
: T extends Array<infer V>
? AsJson<V>[]
: T extends object
? { [K in keyof T]: AsJson<T[K]> }
: never;
export interface SyncBox<TValue> {
id: string; id: string;
value: IComputedValue<TValue>; value: IComputedValue<AsJson<TValue>>;
set: (value: TValue) => void; set: (value: AsJson<TValue>) => void;
} }
export const syncBoxInjectionToken = getInjectionToken<SyncBox<any>>({ export const syncBoxInjectionToken = getInjectionToken<SyncBox<any>>({

View File

@ -152,9 +152,6 @@ export class ContextHandler implements ClusterContextHandler {
protected async newApiTarget(timeout: number): Promise<httpProxy.ServerOptions> { protected async newApiTarget(timeout: number): Promise<httpProxy.ServerOptions> {
const kubeAuthProxy = await this.ensureServerHelper(); const kubeAuthProxy = await this.ensureServerHelper();
const ca = this.resolveAuthProxyCa();
const clusterPath = this.clusterUrl.path !== "/" ? this.clusterUrl.path : "";
const apiPrefix = `${kubeAuthProxy.apiPrefix}${clusterPath}`;
const headers: Record<string, string> = {}; const headers: Record<string, string> = {};
if (this.clusterUrl.hostname) { if (this.clusterUrl.hostname) {
@ -166,8 +163,8 @@ export class ContextHandler implements ClusterContextHandler {
protocol: "https:", protocol: "https:",
host: "127.0.0.1", host: "127.0.0.1",
port: kubeAuthProxy.port, port: kubeAuthProxy.port,
path: apiPrefix, path: kubeAuthProxy.apiPrefix,
ca, ca: this.resolveAuthProxyCa(),
}, },
changeOrigin: true, changeOrigin: true,
timeout, timeout,

View File

@ -4,7 +4,7 @@
*/ */
import { promiseExecFile } from "../../common/utils/promise-exec"; import { promiseExecFile } from "../../common/utils/promise-exec";
import type { BaseEncodingOptions } from "fs"; import type { ObjectEncodingOptions } from "fs";
import type { ExecFileOptions, ExecFileOptionsWithStringEncoding } from "child_process"; import type { ExecFileOptions, ExecFileOptionsWithStringEncoding } from "child_process";
import { helmBinaryPath } from "../../common/vars"; import { helmBinaryPath } from "../../common/vars";
import { UserStore } from "../../common/user-store"; import { UserStore } from "../../common/user-store";
@ -14,7 +14,7 @@ import { isChildProcessError } from "../../common/utils";
* ExecFile the bundled helm CLI * ExecFile the bundled helm CLI
* @returns STDOUT * @returns STDOUT
*/ */
export async function execHelm(args: string[], { encoding, ...rest }: BaseEncodingOptions & ExecFileOptions = {}): Promise<string> { export async function execHelm(args: string[], { encoding, ...rest }: ObjectEncodingOptions & ExecFileOptions = {}): Promise<string> {
const options: ExecFileOptionsWithStringEncoding = { const options: ExecFileOptionsWithStringEncoding = {
encoding: encoding ?? "utf-8", encoding: encoding ?? "utf-8",
...rest, ...rest,

View File

@ -159,6 +159,7 @@ const createElectronWindowFor = getInjectable({
// Always disable Node.js integration for all webviews // Always disable Node.js integration for all webviews
webPreferences.nodeIntegration = false; webPreferences.nodeIntegration = false;
webPreferences.nativeWindowOpen = false;
}) })
.setWindowOpenHandler((details) => { .setWindowOpenHandler((details) => {

View File

@ -5,31 +5,37 @@
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { Menu, Tray } from "electron"; import { Menu, Tray } from "electron";
import packageJsonInjectable from "../../../common/vars/package-json.injectable"; import packageJsonInjectable from "../../../common/vars/package-json.injectable";
import logger from "../../logger";
import { TRAY_LOG_PREFIX } from "../tray";
import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable"; import showApplicationWindowInjectable from "../../start-main-application/lens-window/show-application-window.injectable";
import type { TrayMenuItem } from "../tray-menu-item/tray-menu-item-injection-token";
import { pipeline } from "@ogre-tools/fp";
import { isEmpty, map, filter } from "lodash/fp";
import isWindowsInjectable from "../../../common/vars/is-windows.injectable"; import isWindowsInjectable from "../../../common/vars/is-windows.injectable";
import loggerInjectable from "../../../common/logger.injectable"; import loggerInjectable from "../../../common/logger.injectable";
import trayIconPathInjectable from "../tray-icon-path.injectable"; import trayIconPathsInjectable from "../tray-icon-path.injectable";
import type { TrayMenuItem } from "../tray-menu-item/tray-menu-item-injection-token";
import { convertToElectronMenuTemplate } from "../reactive-tray-menu-items/converters";
const TRAY_LOG_PREFIX = "[TRAY]";
export interface ElectronTray {
start(): void;
stop(): void;
setMenuItems(menuItems: TrayMenuItem[]): void;
setIconPath(iconPath: string): void;
}
const electronTrayInjectable = getInjectable({ const electronTrayInjectable = getInjectable({
id: "electron-tray", id: "electron-tray",
instantiate: (di) => { instantiate: (di): ElectronTray => {
const packageJson = di.inject(packageJsonInjectable); const packageJson = di.inject(packageJsonInjectable);
const showApplicationWindow = di.inject(showApplicationWindowInjectable); const showApplicationWindow = di.inject(showApplicationWindowInjectable);
const isWindows = di.inject(isWindowsInjectable); const isWindows = di.inject(isWindowsInjectable);
const logger = di.inject(loggerInjectable); const logger = di.inject(loggerInjectable);
const trayIconPath = di.inject(trayIconPathInjectable); const trayIconPaths = di.inject(trayIconPathsInjectable);
let tray: Tray; let tray: Tray;
return { return {
start: () => { start: () => {
tray = new Tray(trayIconPath); tray = new Tray(trayIconPaths.normal);
tray.setToolTip(packageJson.description); tray.setToolTip(packageJson.description);
tray.setIgnoreDoubleClickEvents(true); tray.setIgnoreDoubleClickEvents(true);
@ -41,21 +47,17 @@ const electronTrayInjectable = getInjectable({
}); });
} }
}, },
stop: () => { stop: () => {
tray.destroy(); tray.destroy();
}, },
setMenuItems: (menuItems) => {
const template = convertToElectronMenuTemplate(menuItems);
const menu = Menu.buildFromTemplate(template);
setMenuItems: (items: TrayMenuItem[]) => { tray.setContextMenu(menu);
pipeline( },
items, setIconPath: (iconPath) => {
convertToElectronMenuTemplate, tray.setImage(iconPath);
Menu.buildFromTemplate,
(template) => {
tray.setContextMenu(template);
},
);
}, },
}; };
}, },
@ -64,53 +66,3 @@ const electronTrayInjectable = getInjectable({
}); });
export default electronTrayInjectable; export default electronTrayInjectable;
const convertToElectronMenuTemplate = (trayMenuItems: TrayMenuItem[]) => {
const _toTrayMenuOptions = (parentId: string | null) =>
pipeline(
trayMenuItems,
filter((item) => item.parentId === parentId),
map(
(trayMenuItem: TrayMenuItem): Electron.MenuItemConstructorOptions => {
if (trayMenuItem.separator) {
return { id: trayMenuItem.id, type: "separator" };
}
const childItems = _toTrayMenuOptions(trayMenuItem.id);
return {
id: trayMenuItem.id,
label: trayMenuItem.label?.get(),
enabled: trayMenuItem.enabled.get(),
toolTip: trayMenuItem.tooltip,
...(isEmpty(childItems)
? {
type: "normal",
submenu: _toTrayMenuOptions(trayMenuItem.id),
click: () => {
try {
trayMenuItem.click?.();
} catch (error) {
logger.error(
`${TRAY_LOG_PREFIX}: clicking item "${trayMenuItem.id} failed."`,
{ error },
);
}
},
}
: {
type: "submenu",
submenu: _toTrayMenuOptions(trayMenuItem.id),
}),
};
},
),
);
return _toTrayMenuOptions(null);
};

View File

@ -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 { reaction } from "mobx";
import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
import electronTrayInjectable from "../electron-tray/electron-tray.injectable";
import trayIconPathsInjectable from "../tray-icon-path.injectable";
const reactiveTrayMenuIconInjectable = getInjectable({
id: "reactive-tray-menu-icon",
instantiate: (di) => {
const discoveredUpdateVersion = di.inject(discoveredUpdateVersionInjectable);
const electronTray = di.inject(electronTrayInjectable);
const trayIconPaths = di.inject(trayIconPathsInjectable);
return getStartableStoppable("reactive-tray-menu-icon", () => (
reaction(
() => discoveredUpdateVersion.value.get(),
updateVersion => {
if (updateVersion) {
electronTray.setIconPath(trayIconPaths.updateAvailable);
} else {
electronTray.setIconPath(trayIconPaths.normal);
}
},
{
fireImmediately: true,
},
)
));
},
});
export default reactiveTrayMenuIconInjectable;

View File

@ -0,0 +1,28 @@
/**
* 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 { onLoadOfApplicationInjectionToken } from "../../start-main-application/runnable-tokens/on-load-of-application-injection-token";
import startTrayInjectable from "../electron-tray/start-tray.injectable";
import reactiveTrayMenuIconInjectable from "./reactive.injectable";
const startReactiveTrayMenuIconInjectable = getInjectable({
id: "start-reactive-tray-menu-icon",
instantiate: (di) => {
const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable);
return {
run: async () => {
await reactiveTrayMenuIcon.start();
},
runAfter: di.inject(startTrayInjectable),
};
},
injectionToken: onLoadOfApplicationInjectionToken,
});
export default startReactiveTrayMenuIconInjectable;

View File

@ -0,0 +1,25 @@
/**
* 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 { beforeQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token";
import reactiveTrayMenuIconInjectable from "./reactive.injectable";
const stopReactiveTrayMenuIconInjectable = getInjectable({
id: "stop-reactive-tray-menu-icon",
instantiate: (di) => {
const reactiveTrayMenuIcon = di.inject(reactiveTrayMenuIconInjectable);
return {
run: async () => {
await reactiveTrayMenuIcon.stop();
},
};
},
injectionToken: beforeQuitOfBackEndInjectionToken,
});
export default stopReactiveTrayMenuIconInjectable;

View File

@ -0,0 +1,40 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { TrayMenuItem } from "../tray-menu-item/tray-menu-item-injection-token";
export function convertToElectronMenuTemplate(trayMenuItems: TrayMenuItem[]): Electron.MenuItemConstructorOptions[] {
const toTrayMenuOptions = (parentId: string | null) => (
trayMenuItems
.filter((item) => item.parentId === parentId)
.map((trayMenuItem: TrayMenuItem): Electron.MenuItemConstructorOptions => {
if (trayMenuItem.separator) {
return { id: trayMenuItem.id, type: "separator" };
}
const childItems = toTrayMenuOptions(trayMenuItem.id);
return {
id: trayMenuItem.id,
label: trayMenuItem.label?.get(),
enabled: trayMenuItem.enabled.get(),
toolTip: trayMenuItem.tooltip,
...(childItems.length === 0
? {
type: "normal",
submenu: toTrayMenuOptions(trayMenuItem.id),
click: trayMenuItem.click,
}
: {
type: "submenu",
submenu: toTrayMenuOptions(trayMenuItem.id),
}),
};
})
);
return toTrayMenuOptions(null);
}

View File

@ -4,9 +4,9 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable"; import { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
import { autorun } from "mobx"; import { reaction } from "mobx";
import trayMenuItemsInjectable from "../tray-menu-item/tray-menu-items.injectable";
import electronTrayInjectable from "../electron-tray/electron-tray.injectable"; import electronTrayInjectable from "../electron-tray/electron-tray.injectable";
import trayMenuItemsInjectable from "../tray-menu-item/tray-menu-items.injectable";
const reactiveTrayMenuItemsInjectable = getInjectable({ const reactiveTrayMenuItemsInjectable = getInjectable({
id: "reactive-tray-menu-items", id: "reactive-tray-menu-items",
@ -15,9 +15,15 @@ const reactiveTrayMenuItemsInjectable = getInjectable({
const electronTray = di.inject(electronTrayInjectable); const electronTray = di.inject(electronTrayInjectable);
const trayMenuItems = di.inject(trayMenuItemsInjectable); const trayMenuItems = di.inject(trayMenuItemsInjectable);
return getStartableStoppable("reactive-tray-menu-items", () => autorun(() => { return getStartableStoppable("reactive-tray-menu-items", () => (
electronTray.setMenuItems(trayMenuItems.get()); reaction(
})); () => trayMenuItems.get(),
electronTray.setMenuItems,
{
fireImmediately: true,
},
)
));
}, },
}); });

View File

@ -6,21 +6,32 @@ import { getInjectable } from "@ogre-tools/injectable";
import getAbsolutePathInjectable from "../../common/path/get-absolute-path.injectable"; import getAbsolutePathInjectable from "../../common/path/get-absolute-path.injectable";
import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable"; import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable";
import isDevelopmentInjectable from "../../common/vars/is-development.injectable"; import isDevelopmentInjectable from "../../common/vars/is-development.injectable";
import isMacInjectable from "../../common/vars/is-mac.injectable";
const trayIconPathInjectable = getInjectable({ export interface TrayIconPaths {
id: "tray-icon-path", normal: string;
updateAvailable: string;
}
instantiate: (di) => { const trayIconPathsInjectable = getInjectable({
id: "tray-icon-paths",
instantiate: (di): TrayIconPaths => {
const getAbsolutePath = di.inject(getAbsolutePathInjectable); const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const staticFilesDirectory = di.inject(staticFilesDirectoryInjectable); const staticFilesDirectory = di.inject(staticFilesDirectoryInjectable);
const isDevelopment = di.inject(isDevelopmentInjectable); const isDevelopment = di.inject(isDevelopmentInjectable);
const isMac = di.inject(isMacInjectable);
return getAbsolutePath( const baseIconDirectory = getAbsolutePath(
staticFilesDirectory, staticFilesDirectory,
isDevelopment ? "../build/tray" : "icons", // copied within electron-builder extras isDevelopment ? "../build/tray" : "icons", // copied within electron-builder extras
"trayIconTemplate.png",
); );
const fileSuffix = isMac ? "Template.png" : ".png";
return {
normal: getAbsolutePath(baseIconDirectory, `trayIcon${fileSuffix}`),
updateAvailable: getAbsolutePath(baseIconDirectory, `trayIconUpdateAvailable${fileSuffix}`),
};
}, },
}); });
export default trayIconPathInjectable; export default trayIconPathsInjectable;

View File

@ -12,8 +12,7 @@ const trayItemsInjectable = getInjectable({
instantiate: (di) => { instantiate: (di) => {
const extensions = di.inject(mainExtensionsInjectable); const extensions = di.inject(mainExtensionsInjectable);
return computed(() => return computed(() => extensions.get().flatMap(extension => extension.trayMenus));
extensions.get().flatMap(extension => extension.trayMenus));
}, },
}); });

View File

@ -1,99 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import packageInfo from "../../../package.json";
import { Menu, Tray } from "electron";
import type { IComputedValue } from "mobx";
import { autorun } from "mobx";
import logger from "../logger";
import { isWindows } from "../../common/vars";
import type { Disposer } from "../../common/utils";
import { disposer } from "../../common/utils";
import type { TrayMenuItem } from "./tray-menu-item/tray-menu-item-injection-token";
import { pipeline } from "@ogre-tools/fp";
import { filter, isEmpty, map } from "lodash/fp";
export const TRAY_LOG_PREFIX = "[TRAY]";
// note: instance of Tray should be saved somewhere, otherwise it disappears
export let tray: Tray | null = null;
export function initTray(
trayMenuItems: IComputedValue<TrayMenuItem[]>,
showApplicationWindow: () => Promise<void>,
trayIconPath: string,
): Disposer {
tray = new Tray(trayIconPath);
tray.setToolTip(packageInfo.description);
tray.setIgnoreDoubleClickEvents(true);
if (isWindows) {
tray.on("click", () => {
showApplicationWindow()
.catch(error => logger.error(`${TRAY_LOG_PREFIX}: Failed to open lens`, { error }));
});
}
return disposer(
autorun(() => {
try {
const options = toTrayMenuOptions(trayMenuItems.get());
const menu = Menu.buildFromTemplate(options);
tray?.setContextMenu(menu);
} catch (error) {
logger.error(`${TRAY_LOG_PREFIX}: building failed`, { error });
}
}),
() => {
tray?.destroy();
tray = null;
},
);
}
const toTrayMenuOptions = (trayMenuItems: TrayMenuItem[]) => {
const _toTrayMenuOptions = (parentId: string | null) =>
pipeline(
trayMenuItems,
filter((item) => item.parentId === parentId),
map(
(trayMenuItem: TrayMenuItem): Electron.MenuItemConstructorOptions => {
if (trayMenuItem.separator) {
return { id: trayMenuItem.id, type: "separator" };
}
const childItems = _toTrayMenuOptions(trayMenuItem.id);
return {
id: trayMenuItem.id,
label: trayMenuItem.label?.get(),
enabled: trayMenuItem.enabled.get(),
toolTip: trayMenuItem.tooltip,
...(isEmpty(childItems)
? {
type: "normal",
submenu: _toTrayMenuOptions(trayMenuItem.id),
click: () => {
trayMenuItem.click?.();
},
}
: {
type: "submenu",
submenu: _toTrayMenuOptions(trayMenuItem.id),
}),
};
},
),
);
return _toTrayMenuOptions(null);
};

View File

@ -9,7 +9,12 @@ import { cssNames } from "../../utils";
export interface DrawerTitleProps { export interface DrawerTitleProps {
className?: string; className?: string;
children: React.ReactNode; children?: React.ReactNode;
/**
* @deprecated Prefer passing the value as `children`
*/
title?: React.ReactNode;
/** /**
* Specifies how large this title is * Specifies how large this title is

View File

@ -29,6 +29,7 @@ import Spinner from "./spinner.svg";
import Ssh from "./ssh.svg"; import Ssh from "./ssh.svg";
import Storage from "./storage.svg"; import Storage from "./storage.svg";
import Terminal from "./terminal.svg"; import Terminal from "./terminal.svg";
import Notice from "./notice.svg";
import User from "./user.svg"; import User from "./user.svg";
import Users from "./users.svg"; import Users from "./users.svg";
import Wheel from "./wheel.svg"; import Wheel from "./wheel.svg";
@ -58,6 +59,7 @@ const localSvgIcons = new Map([
["ssh", Ssh], ["ssh", Ssh],
["storage", Storage], ["storage", Storage],
["terminal", Terminal], ["terminal", Terminal],
["notice", Notice],
["user", User], ["user", User],
["users", Users], ["users", Users],
["wheel", Wheel], ["wheel", Wheel],

View File

@ -0,0 +1,30 @@
<svg xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" sodipodi:docname="notice.svg" inkscape:version="1.0 (4035a4f, 2020-05-01)" id="notice" version="1.1" viewBox="0 0 135.46666 135.46666" height="512" width="512">
<defs id="defs2">
<rect id="rect2785" height="134.1693" width="135.23837" y="0.26726951" x="-0.53453903" />
<linearGradient osb:paint="solid" id="linearGradient837">
<stop id="stop835" offset="0" style="stop-color:#000000;stop-opacity:1;" />
</linearGradient>
</defs>
<sodipodi:namedview inkscape:window-maximized="0" inkscape:window-y="0" inkscape:window-x="0" inkscape:window-height="1080" inkscape:window-width="1920" inkscape:pagecheckerboard="true" units="px" showgrid="false" inkscape:document-rotation="0" inkscape:current-layer="layer1" inkscape:document-units="px" inkscape:cy="263.00246" inkscape:cx="240.74335" inkscape:zoom="2.0359339" inkscape:pageshadow="2" inkscape:pageopacity="0.0" borderopacity="1.0" bordercolor="#666666" pagecolor="#ffffff" id="base" />
<metadata id="metadata5">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g id="layer1" inkscape:groupmode="layer" inkscape:label="Layer 1">
<ellipse ry="59.764721" rx="59.764713" cy="67.73333" cx="67.733345" id="path10" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:15.9372;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path id="path2807" d="M 58.707956,29.522524 H 76.674473 L 76.739452,43.330427 73.23062,71.076192 62.054343,71.043701 58.740444,43.427894 Z" style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<rect y="83.204803" x="59.292759" height="14.815064" width="16.861885" id="rect2809" style="fill:#000000;fill-opacity:1;stroke:none;" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -24,12 +24,12 @@ import type { ClusterStore } from "../../../common/cluster-store/cluster-store";
import mainExtensionsInjectable from "../../../extensions/main-extensions.injectable"; import mainExtensionsInjectable from "../../../extensions/main-extensions.injectable";
import currentRouteComponentInjectable from "../../routes/current-route-component.injectable"; import currentRouteComponentInjectable from "../../routes/current-route-component.injectable";
import { pipeline } from "@ogre-tools/fp"; import { pipeline } from "@ogre-tools/fp";
import { flatMap, compact, join, get, filter, find, map, matches } from "lodash/fp"; import { flatMap, compact, join, get, filter, map, matches, find } from "lodash/fp";
import preferenceNavigationItemsInjectable from "../+preferences/preferences-navigation/preference-navigation-items.injectable"; import preferenceNavigationItemsInjectable from "../+preferences/preferences-navigation/preference-navigation-items.injectable";
import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable"; import navigateToPreferencesInjectable from "../../../common/front-end-routing/routes/preferences/navigate-to-preferences.injectable";
import type { MenuItemOpts } from "../../../main/menu/application-menu-items.injectable"; import type { MenuItemOpts } from "../../../main/menu/application-menu-items.injectable";
import applicationMenuItemsInjectable from "../../../main/menu/application-menu-items.injectable"; import applicationMenuItemsInjectable from "../../../main/menu/application-menu-items.injectable";
import type { MenuItem, MenuItemConstructorOptions } from "electron"; import type { MenuItemConstructorOptions, MenuItem } from "electron";
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable"; import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
import navigateToHelmChartsInjectable from "../../../common/front-end-routing/routes/cluster/helm/charts/navigate-to-helm-charts.injectable"; import navigateToHelmChartsInjectable from "../../../common/front-end-routing/routes/cluster/helm/charts/navigate-to-helm-charts.injectable";
import hostedClusterInjectable from "../../../common/cluster-store/hosted-cluster.injectable"; import hostedClusterInjectable from "../../../common/cluster-store/hosted-cluster.injectable";
@ -43,7 +43,6 @@ import { flushPromises } from "../../../common/test-utils/flush-promises";
import type { NamespaceStore } from "../+namespaces/store"; import type { NamespaceStore } from "../+namespaces/store";
import namespaceStoreInjectable from "../+namespaces/store.injectable"; import namespaceStoreInjectable from "../+namespaces/store.injectable";
import historyInjectable from "../../navigation/history.injectable"; import historyInjectable from "../../navigation/history.injectable";
import type { TrayMenuItem } from "../../../main/tray/tray-menu-item/tray-menu-item-injection-token";
import electronTrayInjectable from "../../../main/tray/electron-tray/electron-tray.injectable"; import electronTrayInjectable from "../../../main/tray/electron-tray/electron-tray.injectable";
import applicationWindowInjectable from "../../../main/start-main-application/lens-window/application-window/application-window.injectable"; import applicationWindowInjectable from "../../../main/start-main-application/lens-window/application-window/application-window.injectable";
import { Notifications } from "../notifications/notifications"; import { Notifications } from "../notifications/notifications";
@ -51,6 +50,8 @@ import broadcastThatRootFrameIsRenderedInjectable from "../../frames/root-frame/
import { getDiForUnitTesting as getRendererDi } from "../../getDiForUnitTesting"; import { getDiForUnitTesting as getRendererDi } from "../../getDiForUnitTesting";
import { getDiForUnitTesting as getMainDi } from "../../../main/getDiForUnitTesting"; import { getDiForUnitTesting as getMainDi } from "../../../main/getDiForUnitTesting";
import { overrideChannels } from "../../../test-utils/channel-fakes/override-channels"; import { overrideChannels } from "../../../test-utils/channel-fakes/override-channels";
import type { TrayMenuItem } from "../../../main/tray/tray-menu-item/tray-menu-item-injection-token";
import trayIconPathsInjectable from "../../../main/tray/tray-icon-path.injectable";
type Callback = (dis: DiContainers) => void | Promise<void>; type Callback = (dis: DiContainers) => void | Promise<void>;
@ -65,7 +66,8 @@ export interface ApplicationBuilder {
tray: { tray: {
click: (id: string) => Promise<void>; click: (id: string) => Promise<void>;
get: (id: string) => TrayMenuItem | undefined; get: (id: string) => TrayMenuItem | null;
getIconPath: () => string;
}; };
applicationMenu: { applicationMenu: {
@ -166,15 +168,22 @@ export const getApplicationBuilder = () => {
computed(() => []), computed(() => []),
); );
const iconPaths = mainDi.inject(trayIconPathsInjectable);
let trayMenuItemsStateFake: TrayMenuItem[]; let trayMenuItemsStateFake: TrayMenuItem[];
let trayMenuIconPath: string;
mainDi.override(electronTrayInjectable, () => ({ mainDi.override(electronTrayInjectable, () => ({
start: () => {}, start: () => {
trayMenuIconPath = iconPaths.normal;
},
stop: () => {}, stop: () => {},
setMenuItems: (items) => { setMenuItems: (items) => {
trayMenuItemsStateFake = items; trayMenuItemsStateFake = items;
}, },
setIconPath: (path) => {
trayMenuIconPath = path;
},
})); }));
let allowedResourcesState: IObservableArray<KubeResource>; let allowedResourcesState: IObservableArray<KubeResource>;
@ -209,6 +218,7 @@ export const getApplicationBuilder = () => {
{ {
menu: null as never, menu: null as never,
commandId: 0, commandId: 0,
userAccelerator: null,
...menuItem, ...menuItem,
} as MenuItem, } as MenuItem,
undefined, undefined,
@ -221,9 +231,9 @@ export const getApplicationBuilder = () => {
tray: { tray: {
get: (id: string) => { get: (id: string) => {
return trayMenuItemsStateFake.find(matches({ id })); return trayMenuItemsStateFake.find(matches({ id })) ?? null;
}, },
getIconPath: () => trayMenuIconPath,
click: async (id: string) => { click: async (id: string) => {
const menuItem = pipeline( const menuItem = pipeline(
trayMenuItemsStateFake, trayMenuItemsStateFake,

107
yarn.lock
View File

@ -473,7 +473,7 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==
"@electron/get@^1.0.1": "@electron/get@^1.13.0":
version "1.14.1" version "1.14.1"
resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.14.1.tgz#16ba75f02dffb74c23965e72d617adc721d27f40" resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.14.1.tgz#16ba75f02dffb74c23965e72d617adc721d27f40"
integrity sha512-BrZYyL/6m0ZXz/lDxy/nlVhQz+WF+iPS6qXolEU8atw7h6v1aYkjwJZ63m+bJMBTxDE66X+r2tPS4a/8C82sZw== integrity sha512-BrZYyL/6m0ZXz/lDxy/nlVhQz+WF+iPS6qXolEU8atw7h6v1aYkjwJZ63m+bJMBTxDE66X+r2tPS4a/8C82sZw==
@ -1847,16 +1847,21 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.31.tgz#a5bb84ecfa27eec5e1c802c6bbf8139bdb163a5d" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.31.tgz#a5bb84ecfa27eec5e1c802c6bbf8139bdb163a5d"
integrity sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q== integrity sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q==
"@types/node@14.18.18", "@types/node@^14.6.2":
version "14.18.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.18.tgz#5c9503030df484ccffcbb935ea9a9e1d6fad1a20"
integrity sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==
"@types/node@^10.12.0": "@types/node@^10.12.0":
version "10.17.60" version "10.17.60"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b"
integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==
"@types/node@^14.6.2":
version "14.18.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.18.tgz#5c9503030df484ccffcbb935ea9a9e1d6fad1a20"
integrity sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==
"@types/node@^16.11.39":
version "16.11.39"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.39.tgz#07223cd2bc332ad9d92135e3a522eebdee3b060e"
integrity sha512-K0MsdV42vPwm9L6UwhIxMAOmcvH/1OoVkZyCgEtVu4Wx7sElGloy/W7kMBNe/oJ7V/jW9BVt1F6RahH6e7tPXw==
"@types/normalize-package-data@^2.4.0": "@types/normalize-package-data@^2.4.0":
version "2.4.1" version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
@ -2288,14 +2293,14 @@
dependencies: dependencies:
"@types/yargs-parser" "*" "@types/yargs-parser" "*"
"@typescript-eslint/eslint-plugin@^5.27.0": "@typescript-eslint/eslint-plugin@^5.27.1":
version "5.27.0" version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.27.0.tgz#23d82a4f21aaafd8f69dbab7e716323bb6695cc8" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.27.1.tgz#fdf59c905354139046b41b3ed95d1609913d0758"
integrity sha512-DDrIA7GXtmHXr1VCcx9HivA39eprYBIFxbQEHI6NyraRDxCGpxAFiYQAT/1Y0vh1C+o2vfBiy4IuPoXxtTZCAQ== integrity sha512-6dM5NKT57ZduNnJfpY81Phe9nc9wolnMCnknb1im6brWi1RYv84nbMS3olJa27B6+irUVV1X/Wb+Am0FjJdGFw==
dependencies: dependencies:
"@typescript-eslint/scope-manager" "5.27.0" "@typescript-eslint/scope-manager" "5.27.1"
"@typescript-eslint/type-utils" "5.27.0" "@typescript-eslint/type-utils" "5.27.1"
"@typescript-eslint/utils" "5.27.0" "@typescript-eslint/utils" "5.27.1"
debug "^4.3.4" debug "^4.3.4"
functional-red-black-tree "^1.0.1" functional-red-black-tree "^1.0.1"
ignore "^5.2.0" ignore "^5.2.0"
@ -2321,12 +2326,20 @@
"@typescript-eslint/types" "5.27.0" "@typescript-eslint/types" "5.27.0"
"@typescript-eslint/visitor-keys" "5.27.0" "@typescript-eslint/visitor-keys" "5.27.0"
"@typescript-eslint/type-utils@5.27.0": "@typescript-eslint/scope-manager@5.27.1":
version "5.27.0" version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.27.0.tgz#36fd95f6747412251d79c795b586ba766cf0974b" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.27.1.tgz#4d1504392d01fe5f76f4a5825991ec78b7b7894d"
integrity sha512-vpTvRRchaf628Hb/Xzfek+85o//zEUotr1SmexKvTfs7czXfYjXVT/a5yDbpzLBX1rhbqxjDdr1Gyo0x1Fc64g== integrity sha512-fQEOSa/QroWE6fAEg+bJxtRZJTH8NTskggybogHt4H9Da8zd4cJji76gA5SBlR0MgtwF7rebxTbDKB49YUCpAg==
dependencies: dependencies:
"@typescript-eslint/utils" "5.27.0" "@typescript-eslint/types" "5.27.1"
"@typescript-eslint/visitor-keys" "5.27.1"
"@typescript-eslint/type-utils@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.27.1.tgz#369f695199f74c1876e395ebea202582eb1d4166"
integrity sha512-+UC1vVUWaDHRnC2cQrCJ4QtVjpjjCgjNFpg8b03nERmkHv9JV9X5M19D7UFMd+/G7T/sgFwX2pGmWK38rqyvXw==
dependencies:
"@typescript-eslint/utils" "5.27.1"
debug "^4.3.4" debug "^4.3.4"
tsutils "^3.21.0" tsutils "^3.21.0"
@ -2335,6 +2348,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.27.0.tgz#c3f44b9dda6177a9554f94a74745ca495ba9c001" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.27.0.tgz#c3f44b9dda6177a9554f94a74745ca495ba9c001"
integrity sha512-lY6C7oGm9a/GWhmUDOs3xAVRz4ty/XKlQ2fOLr8GAIryGn0+UBOoJDWyHer3UgrHkenorwvBnphhP+zPmzmw0A== integrity sha512-lY6C7oGm9a/GWhmUDOs3xAVRz4ty/XKlQ2fOLr8GAIryGn0+UBOoJDWyHer3UgrHkenorwvBnphhP+zPmzmw0A==
"@typescript-eslint/types@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.27.1.tgz#34e3e629501349d38be6ae97841298c03a6ffbf1"
integrity sha512-LgogNVkBhCTZU/m8XgEYIWICD6m4dmEDbKXESCbqOXfKZxRKeqpiJXQIErv66sdopRKZPo5l32ymNqibYEH/xg==
"@typescript-eslint/typescript-estree@5.27.0": "@typescript-eslint/typescript-estree@5.27.0":
version "5.27.0" version "5.27.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.27.0.tgz#7965f5b553c634c5354a47dcce0b40b94611e995" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.27.0.tgz#7965f5b553c634c5354a47dcce0b40b94611e995"
@ -2348,15 +2366,28 @@
semver "^7.3.7" semver "^7.3.7"
tsutils "^3.21.0" tsutils "^3.21.0"
"@typescript-eslint/utils@5.27.0": "@typescript-eslint/typescript-estree@5.27.1":
version "5.27.0" version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.27.0.tgz#d0021cbf686467a6a9499bd0589e19665f9f7e71" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.27.1.tgz#7621ee78607331821c16fffc21fc7a452d7bc808"
integrity sha512-nZvCrkIJppym7cIbP3pOwIkAefXOmfGPnCM0LQfzNaKxJHI6VjI8NC662uoiPlaf5f6ymkTy9C3NQXev2mdXmA== integrity sha512-DnZvvq3TAJ5ke+hk0LklvxwYsnXpRdqUY5gaVS0D4raKtbznPz71UJGnPTHEFo0GDxqLOLdMkkmVZjSpET1hFw==
dependencies:
"@typescript-eslint/types" "5.27.1"
"@typescript-eslint/visitor-keys" "5.27.1"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/utils@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.27.1.tgz#b4678b68a94bc3b85bf08f243812a6868ac5128f"
integrity sha512-mZ9WEn1ZLDaVrhRaYgzbkXBkTPghPFsup8zDbbsYTxC5OmqrFE7skkKS/sraVsLP3TcT3Ki5CSyEFBRkLH/H/w==
dependencies: dependencies:
"@types/json-schema" "^7.0.9" "@types/json-schema" "^7.0.9"
"@typescript-eslint/scope-manager" "5.27.0" "@typescript-eslint/scope-manager" "5.27.1"
"@typescript-eslint/types" "5.27.0" "@typescript-eslint/types" "5.27.1"
"@typescript-eslint/typescript-estree" "5.27.0" "@typescript-eslint/typescript-estree" "5.27.1"
eslint-scope "^5.1.1" eslint-scope "^5.1.1"
eslint-utils "^3.0.0" eslint-utils "^3.0.0"
@ -2368,6 +2399,14 @@
"@typescript-eslint/types" "5.27.0" "@typescript-eslint/types" "5.27.0"
eslint-visitor-keys "^3.3.0" eslint-visitor-keys "^3.3.0"
"@typescript-eslint/visitor-keys@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.27.1.tgz#05a62666f2a89769dac2e6baa48f74e8472983af"
integrity sha512-xYs6ffo01nhdJgPieyk7HAOpjhTsx7r/oB9LWEhwAXgwn33tkr+W8DI2ChboqhZlC4q3TC6geDYPoiX8ROqyOQ==
dependencies:
"@typescript-eslint/types" "5.27.1"
eslint-visitor-keys "^3.3.0"
"@webassemblyjs/ast@1.11.1": "@webassemblyjs/ast@1.11.1":
version "1.11.1" version "1.11.1"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7"
@ -4989,12 +5028,12 @@ electron-window-state@^5.0.3:
jsonfile "^4.0.0" jsonfile "^4.0.0"
mkdirp "^0.5.1" mkdirp "^0.5.1"
electron@^14.2.9: electron@^15.5.7:
version "14.2.9" version "15.5.7"
resolved "https://registry.yarnpkg.com/electron/-/electron-14.2.9.tgz#9e1e95643ec3847592a186e8115d1ddb2e4921ee" resolved "https://registry.yarnpkg.com/electron/-/electron-15.5.7.tgz#aadb0081c504f2c2d8f81ea5fd23e38881afe86a"
integrity sha512-7LdJFmqVzO9NLKO0hwOwPA6Kv4GSybGMcej8f2q7fVT4O8mIfL9oo/v4axVjVWm0+58ROQtHv8hYnnAs3ygG0Q== integrity sha512-n4mVlxoMc4eYx07wWFWGficL+iOMz5xZEf5dBtE/wwLm0fQpYVyW4AlknMFG9F8Css0MM0JSwNMOyRg5e1vDtg==
dependencies: dependencies:
"@electron/get" "^1.0.1" "@electron/get" "^1.13.0"
"@types/node" "^14.6.2" "@types/node" "^14.6.2"
extract-zip "^1.0.3" extract-zip "^1.0.3"
@ -9477,10 +9516,10 @@ node-notifier@^8.0.0:
uuid "^8.3.0" uuid "^8.3.0"
which "^2.0.2" which "^2.0.2"
node-pty@^0.10.1: node-pty@^0.11.0-beta19:
version "0.10.1" version "0.11.0-beta9"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.10.1.tgz#cd05d03a2710315ec40221232ec04186f6ac2c6d" resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.11.0-beta9.tgz#38a899d62b1c5c395ca466dfac5203eff989d350"
integrity sha512-JTdtUS0Im/yRsWJSx7yiW9rtpfmxqxolrtnyKwPLI+6XqTAPW/O2MjS8FYL4I5TsMbH2lVgDb2VMjp+9LoQGNg== integrity sha512-bU/2zYV6xBMVMHaMe+yr4WEw36PCA0hyZ7A0IBQFWy5l1vjsD52sZ9sGJk+dH7bw3xpuBLHMh9Eq4Di8rJz4IQ==
dependencies: dependencies:
nan "^2.14.0" nan "^2.14.0"