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

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 2021-02-09 18:52:33 +03:00 committed by GitHub
parent a61425124f
commit 2b22ec0aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}
}