Simplify ClusterContext to remove something only NamespaceStore needs

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2022-12-19 08:16:58 -05:00
1 parent ff30f8ace7
commit 2a9afc7102
5 files changed
+3 -5

No files matched your search

@@ -17,7 +17,6 @@ class FakeKubeObjectStore extends KubeObjectStore<KubeObject> {
hasSelectedAll: false, hasSelectedAll: false,
isGlobalWatchEnabled: () => true, isGlobalWatchEnabled: () => true,
isLoadingAll: () => true, isLoadingAll: () => true,
isNamespaceListStatic: () => false,
}, },
}, api as KubeApi<KubeObject>); }, api as KubeApi<KubeObject>);
} }
@@ -11,7 +11,6 @@ export interface ClusterContext {
readonly contextNamespaces: string[]; // selected by user (see: namespace-select.tsx) readonly contextNamespaces: string[]; // selected by user (see: namespace-select.tsx)
readonly hasSelectedAll: boolean; readonly hasSelectedAll: boolean;
isNamespaceListStatic(): boolean;
isLoadingAll(namespaces: string[]): boolean; isLoadingAll(namespaces: string[]): boolean;
isGlobalWatchEnabled(): boolean; isGlobalWatchEnabled(): boolean;
} }
@@ -18,7 +18,6 @@ const clusterFrameContextForClusterScopedResourcesInjectable = getInjectable({
isGlobalWatchEnabled: () => cluster.isGlobalWatchEnabled, isGlobalWatchEnabled: () => cluster.isGlobalWatchEnabled,
// This is always the case for cluster scoped resources // This is always the case for cluster scoped resources
isLoadingAll: () => true, isLoadingAll: () => true,
isNamespaceListStatic: () => cluster.accessibleNamespaces.length > 0,
allNamespaces: [], allNamespaces: [],
contextNamespaces: [], // This value is used as a sentinal contextNamespaces: [], // This value is used as a sentinal
hasSelectedAll: true, hasSelectedAll: true,
@@ -42,7 +42,6 @@ const clusterFrameContextForNamespacedResourcesInjectable = getInjectable({
}); });
return { return {
isNamespaceListStatic: () => cluster.accessibleNamespaces.length > 0,
isLoadingAll: (namespaces) => ( isLoadingAll: (namespaces) => (
allNamespaces.get().length > 1 allNamespaces.get().length > 1
&& cluster.accessibleNamespaces.length === 0 && cluster.accessibleNamespaces.length === 0
+3 -1
View File
@@ -107,11 +107,13 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
} }
subscribe() { subscribe() {
const clusterConfiguredAccessibleNamespaces = this.dependencies.clusterConfiguredAccessibleNamespaces.get();
/** /**
* if user has given static list of namespaces let's not start watches * if user has given static list of namespaces let's not start watches
* because watch adds stuff that's not wanted or will just fail * because watch adds stuff that's not wanted or will just fail
*/ */
if (this.dependencies.context.isNamespaceListStatic()) { if (clusterConfiguredAccessibleNamespaces.length > 0) {
return noop; return noop;
} }