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

Fix issue where releases are not reloaded when new release is added externally (e.g. from terminal) (#5603)

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-06-17 10:26:07 +03:00 committed by GitHub
parent d1f5f1cdef
commit 2a5b4af344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

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 { 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;

View File

@ -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 &&