mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
optimize loading all resources when "all namespaces" selected -> single request per resource (when have rights)
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
27c17ea266
commit
0ef0868690
@ -100,13 +100,19 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
|||||||
|
|
||||||
protected async loadItems({ namespaces, api }: KubeObjectStoreLoadingParams): Promise<T[]> {
|
protected async loadItems({ namespaces, api }: KubeObjectStoreLoadingParams): Promise<T[]> {
|
||||||
if (this.context?.cluster.isAllowedResource(api.kind)) {
|
if (this.context?.cluster.isAllowedResource(api.kind)) {
|
||||||
if (api.isNamespaced) {
|
if (!api.isNamespaced) {
|
||||||
return Promise
|
return api.list({}, this.query);
|
||||||
|
}
|
||||||
|
|
||||||
|
const isLoadingAll = this.context.allNamespaces.every(ns => namespaces.includes(ns));
|
||||||
|
|
||||||
|
if (isLoadingAll) {
|
||||||
|
return api.list({}, this.query);
|
||||||
|
} else {
|
||||||
|
return Promise // load resources per namespace
|
||||||
.all(namespaces.map(namespace => api.list({ namespace })))
|
.all(namespaces.map(namespace => api.list({ namespace })))
|
||||||
.then(items => items.flat());
|
.then(items => items.flat());
|
||||||
}
|
}
|
||||||
|
|
||||||
return api.list({}, this.query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user