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:
parent
ff30f8ace7
commit
2a9afc7102
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user