From 410d66ac0f23f6ae11bb545c7c44a2c60594c945 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 6 Mar 2023 14:56:48 -0500 Subject: [PATCH] Implement contextNamespaces logic in forNamespacedResources Signed-off-by: Sebastian Malton --- .../for-namespaced-resources.injectable.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/src/renderer/cluster-frame-context/for-namespaced-resources.injectable.ts b/packages/core/src/renderer/cluster-frame-context/for-namespaced-resources.injectable.ts index 1eb85b3a43..cacdbf1aa7 100644 --- a/packages/core/src/renderer/cluster-frame-context/for-namespaced-resources.injectable.ts +++ b/packages/core/src/renderer/cluster-frame-context/for-namespaced-resources.injectable.ts @@ -8,6 +8,7 @@ import namespaceStoreInjectable from "../components/+namespaces/store.injectable import hostedClusterInjectable from "./hosted-cluster.injectable"; import assert from "assert"; import { computed } from "mobx"; +import selectedNamespacesStorageInjectable from "../../features/namespace-filtering/renderer/storage.injectable"; const clusterFrameContextForNamespacedResourcesInjectable = getInjectable({ id: "cluster-frame-context-for-namespaced-resources", @@ -15,6 +16,7 @@ const clusterFrameContextForNamespacedResourcesInjectable = getInjectable({ instantiate: (di): ClusterContext => { const cluster = di.inject(hostedClusterInjectable); const namespaceStore = di.inject(namespaceStoreInjectable); + const selectedNamespacesStorage = di.inject(selectedNamespacesStorageInjectable); assert(cluster, "This can only be injected within a cluster frame"); @@ -32,7 +34,13 @@ const clusterFrameContextForNamespacedResourcesInjectable = getInjectable({ // fallback to cluster resolved namespaces because we could not load list return cluster.allowedNamespaces.slice(); }); - const contextNamespaces = computed(() => namespaceStore.contextNamespaces); + const contextNamespaces = computed(() => { + const selectedNamespaces = selectedNamespacesStorage.get(); + + return selectedNamespaces.length > 0 + ? selectedNamespaces + : allNamespaces.get(); + }); const hasSelectedAll = computed(() => { const namespaces = new Set(contextNamespaces.get());