1
0
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:
Roman 2021-02-05 18:02:58 +02:00
parent 27c17ea266
commit 0ef0868690

View File

@ -100,13 +100,19 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
protected async loadItems({ namespaces, api }: KubeObjectStoreLoadingParams): Promise<T[]> {
if (this.context?.cluster.isAllowedResource(api.kind)) {
if (api.isNamespaced) {
return Promise
if (!api.isNamespaced) {
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 })))
.then(items => items.flat());
}
return api.list({}, this.query);
}
return [];