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:
parent
d1f5f1cdef
commit
2a5b4af344
@ -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