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,
isGlobalWatchEnabled: () => true,
isLoadingAll: () => true,
isNamespaceListStatic: () => false,
},
}, api as KubeApi<KubeObject>);
}
@@ -11,7 +11,6 @@ export interface ClusterContext {
readonly contextNamespaces: string[]; // selected by user (see: namespace-select.tsx)
readonly hasSelectedAll: boolean;
isNamespaceListStatic(): boolean;
isLoadingAll(namespaces: string[]): boolean;
isGlobalWatchEnabled(): boolean;
}
@@ -18,7 +18,6 @@ const clusterFrameContextForClusterScopedResourcesInjectable = getInjectable({
isGlobalWatchEnabled: () => cluster.isGlobalWatchEnabled,
// This is always the case for cluster scoped resources
isLoadingAll: () => true,
isNamespaceListStatic: () => cluster.accessibleNamespaces.length > 0,
allNamespaces: [],
contextNamespaces: [], // This value is used as a sentinal
hasSelectedAll: true,
@@ -42,7 +42,6 @@ const clusterFrameContextForNamespacedResourcesInjectable = getInjectable({
});
return {
isNamespaceListStatic: () => cluster.accessibleNamespaces.length > 0,
isLoadingAll: (namespaces) => (
allNamespaces.get().length > 1
&& cluster.accessibleNamespaces.length === 0
+3 -1
View File
@@ -107,11 +107,13 @@ export class NamespaceStore extends KubeObjectStore<Namespace, NamespaceApi> {
}
subscribe() {
const clusterConfiguredAccessibleNamespaces = this.dependencies.clusterConfiguredAccessibleNamespaces.get();
/**
* 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
*/
if (this.dependencies.context.isNamespaceListStatic()) {
if (clusterConfiguredAccessibleNamespaces.length > 0) {
return noop;
}