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

Simplify ClusterContext to remove something only NamespaceStore needs

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-11-28 11:54:56 -05:00
parent ff30f8ace7
commit 2a9afc7102
5 changed files with 3 additions and 5 deletions

View File

@ -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>);
} }

View File

@ -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;
} }

View File

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

View File

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

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