KubeObjectStore & KubeWatchApi fixes and optimizations (#2063)

* Detach NamespaceStore from KubeWatchApi, proper KubeObjectStore.loadAll (rebase of #2033)

Signed-off-by: Roman <ixrock@gmail.com>

* Watch-api requests optimization (#2066)

* subscribe for watching resources in single request when has admin-like access rights

Signed-off-by: Roman <ixrock@gmail.com>

* responding to comments

Signed-off-by: Roman <ixrock@gmail.com>

* fix unit-tests

Signed-off-by: Roman <ixrock@gmail.com>

* fix: reloading stores when preloading enabled and waitUntilLoaded=false

Signed-off-by: Roman <ixrock@gmail.com>

* mark Cluster.canUseWatchApi() and Cluster.refreshAccessibility() as private

Signed-off-by: Roman <ixrock@gmail.com>

* fix unit test: make public Cluster.canUseWatchApi()

Signed-off-by: Roman <ixrock@gmail.com>

* responding to comments in #2066

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman authored and GitHub committed 2021-02-04 11:51:35 +02:00
1 parent f56969a64b
commit 5287e7e528
21 files changed
+155 -101

No files matched your search

@@ -58,11 +58,11 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
}
@action
async loadAll() {
async loadAll(namespaces = namespaceStore.allowedNamespaces) {
this.isLoading = true;
try {
const items = await this.loadItems(namespaceStore.getContextNamespaces());
const items = await this.loadItems(namespaces);
this.items.replace(this.sortItems(items));
this.isLoaded = true;
@@ -73,6 +73,10 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
}
}
async loadSelectedNamespaces(): Promise<void> {
return this.loadAll(namespaceStore.getContextNamespaces());
}
async loadItems(namespaces: string[]) {
return Promise
.all(namespaces.map(namespace => helmReleasesApi.list(namespace)))
@@ -82,7 +86,7 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
async create(payload: IReleaseCreatePayload) {
const response = await helmReleasesApi.create(payload);
if (this.isLoaded) this.loadAll();
if (this.isLoaded) this.loadSelectedNamespaces();
return response;
}
@@ -90,7 +94,7 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
async update(name: string, namespace: string, payload: IReleaseUpdatePayload) {
const response = await helmReleasesApi.update(name, namespace, payload);
if (this.isLoaded) this.loadAll();
if (this.isLoaded) this.loadSelectedNamespaces();
return response;
}
@@ -98,7 +102,7 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
async rollback(name: string, namespace: string, revision: number) {
const response = await helmReleasesApi.rollback(name, namespace, revision);
if (this.isLoaded) this.loadAll();
if (this.isLoaded) this.loadSelectedNamespaces();
return response;
}