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:
commit
83de4fc7f8
@ -12,7 +12,6 @@ import type { AsyncFnMock } from "@async-fn/jest";
|
|||||||
import asyncFn 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 { ElectronWindow, LensWindowConfiguration } from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import { flushPromises } from "../../common/test-utils/flush-promises";
|
|
||||||
import lensResourcesDirInjectable from "../../common/vars/lens-resources-dir.injectable";
|
import lensResourcesDirInjectable from "../../common/vars/lens-resources-dir.injectable";
|
||||||
|
|
||||||
describe("opening application window using tray", () => {
|
describe("opening application window using tray", () => {
|
||||||
@ -24,17 +23,28 @@ describe("opening application window using tray", () => {
|
|||||||
let callForApplicationWindowHtmlMock: AsyncFnMock<() => void>;
|
let callForApplicationWindowHtmlMock: AsyncFnMock<() => void>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
callForSplashWindowHtmlMock = asyncFn();
|
||||||
|
callForApplicationWindowHtmlMock = asyncFn();
|
||||||
|
|
||||||
applicationBuilder = getApplicationBuilder().beforeApplicationStart(
|
applicationBuilder = getApplicationBuilder().beforeApplicationStart(
|
||||||
({ mainDi }) => {
|
({ mainDi }) => {
|
||||||
mainDi.override(lensResourcesDirInjectable, () => "some-lens-resources-directory");
|
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) =>
|
createElectronWindowMock = jest.fn((configuration: LensWindowConfiguration) =>
|
||||||
({
|
({
|
||||||
splash: {
|
splash: {
|
||||||
send: () => {},
|
send: () => {},
|
||||||
close: () => {},
|
close: () => {},
|
||||||
show: () => {},
|
show: () => {},
|
||||||
loadFile: callForSplashWindowHtmlMock,
|
loadFile: loadFileMock,
|
||||||
loadUrl: () => { throw new Error("Should never come here"); },
|
loadUrl: () => { throw new Error("Should never come here"); },
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -43,7 +53,7 @@ describe("opening application window using tray", () => {
|
|||||||
close: () => {},
|
close: () => {},
|
||||||
show: () => {},
|
show: () => {},
|
||||||
loadFile: () => { throw new Error("Should never come here"); },
|
loadFile: () => { throw new Error("Should never come here"); },
|
||||||
loadUrl: callForApplicationWindowHtmlMock,
|
loadUrl: loadUrlMock,
|
||||||
},
|
},
|
||||||
}[configuration.id] as ElectronWindow));
|
}[configuration.id] as ElectronWindow));
|
||||||
|
|
||||||
@ -54,20 +64,10 @@ describe("opening application window using tray", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expectWindowsToBeOpen = expectWindowsToBeOpenFor(mainDi);
|
expectWindowsToBeOpen = expectWindowsToBeOpenFor(mainDi);
|
||||||
|
|
||||||
callForSplashWindowHtmlMock = asyncFn();
|
|
||||||
callForApplicationWindowHtmlMock = asyncFn();
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderPromise = applicationBuilder.render();
|
await applicationBuilder.render();
|
||||||
|
|
||||||
await flushPromises();
|
|
||||||
|
|
||||||
await callForSplashWindowHtmlMock.resolve();
|
|
||||||
await callForApplicationWindowHtmlMock.resolve();
|
|
||||||
|
|
||||||
await renderPromise;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("only an application window is open", () => {
|
it("only an application window is open", () => {
|
||||||
|
|||||||
@ -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;
|
||||||
@ -7,6 +7,7 @@ import { asyncComputed } from "@ogre-tools/injectable-react";
|
|||||||
import namespaceStoreInjectable from "../+namespaces/store.injectable";
|
import namespaceStoreInjectable from "../+namespaces/store.injectable";
|
||||||
import { listReleases } from "../../../common/k8s-api/endpoints/helm-releases.api";
|
import { listReleases } from "../../../common/k8s-api/endpoints/helm-releases.api";
|
||||||
import clusterFrameContextInjectable from "../../cluster-frame-context/cluster-frame-context.injectable";
|
import clusterFrameContextInjectable from "../../cluster-frame-context/cluster-frame-context.injectable";
|
||||||
|
import releaseSecretsInjectable from "./release-secrets.injectable";
|
||||||
|
|
||||||
const releasesInjectable = getInjectable({
|
const releasesInjectable = getInjectable({
|
||||||
id: "releases",
|
id: "releases",
|
||||||
@ -14,10 +15,13 @@ const releasesInjectable = getInjectable({
|
|||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const clusterContext = di.inject(clusterFrameContextInjectable);
|
const clusterContext = di.inject(clusterFrameContextInjectable);
|
||||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
const namespaceStore = di.inject(namespaceStoreInjectable);
|
||||||
|
const releaseSecrets = di.inject(releaseSecretsInjectable);
|
||||||
|
|
||||||
return asyncComputed(async () => {
|
return asyncComputed(async () => {
|
||||||
const contextNamespaces = namespaceStore.contextNamespaces || [];
|
const contextNamespaces = namespaceStore.contextNamespaces || [];
|
||||||
|
|
||||||
|
void releaseSecrets.get();
|
||||||
|
|
||||||
const isLoadingAll =
|
const isLoadingAll =
|
||||||
clusterContext.allNamespaces?.length > 1 &&
|
clusterContext.allNamespaces?.length > 1 &&
|
||||||
clusterContext.cluster?.accessibleNamespaces.length === 0 &&
|
clusterContext.cluster?.accessibleNamespaces.length === 0 &&
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user