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

Fix: load releases for all namespaces at once (#2139)

* Load releases for all namespaces at once

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Check for accessibleNamespaces length

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Replacing loadAll() to loadFromContextNamespaces()

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-02-16 17:53:11 +03:00 committed by GitHub
parent 436bb7683d
commit 2c196ec3ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,7 +33,7 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
}); });
if (amountChanged || labelsChanged) { if (amountChanged || labelsChanged) {
this.loadAll(); this.loadFromContextNamespaces();
} }
this.releaseSecrets = [...secrets]; this.releaseSecrets = [...secrets];
}); });
@ -58,7 +58,7 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
} }
@action @action
async loadAll(namespaces = namespaceStore.allowedNamespaces) { async loadAll(namespaces: string[]) {
this.isLoading = true; this.isLoading = true;
try { try {
@ -78,10 +78,17 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
} }
async loadItems(namespaces: string[]) { async loadItems(namespaces: string[]) {
const isLoadingAll = namespaceStore.allowedNamespaces.every(ns => namespaces.includes(ns));
const noAccessibleNamespaces = namespaceStore.context.cluster.accessibleNamespaces.length === 0;
if (isLoadingAll && noAccessibleNamespaces) {
return helmReleasesApi.list();
} else {
return Promise return Promise
.all(namespaces.map(namespace => helmReleasesApi.list(namespace))) .all(namespaces.map(namespace => helmReleasesApi.list(namespace)))
.then(items => items.flat()); .then(items => items.flat());
} }
}
async create(payload: IReleaseCreatePayload) { async create(payload: IReleaseCreatePayload) {
const response = await helmReleasesApi.create(payload); const response = await helmReleasesApi.create(payload);