Fix: saving apiManager store keys with string type (#2091)

* Saving apiManager store keys with string type

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

* Replacing stores key from "kind" to "apiBase"

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev authored and GitHub committed 2021-02-09 17:52:33 +02:00
1 parent a61425124f
commit 2b22ec0aa3
1 file changed
+3 -3
+3 -3
View File
@@ -7,7 +7,7 @@ import { KubeApi, parseKubeApi } from "./kube-api";
@autobind()
export class ApiManager {
private apis = observable.map<string, KubeApi>();
private stores = observable.map<KubeApi, KubeObjectStore>();
private stores = observable.map<string, KubeObjectStore>();
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {
if (typeof pathOrCallback === "string") {
@@ -46,12 +46,12 @@ export class ApiManager {
@action
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
apis.forEach(api => {
this.stores.set(api, store);
this.stores.set(api.apiBase, store);
});
}
getStore<S extends KubeObjectStore>(api: string | KubeApi): S {
return this.stores.get(this.resolveApi(api)) as S;
return this.stores.get(this.resolveApi(api)?.apiBase) as S;
}
}