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:
parent
a61425124f
commit
2b22ec0aa3
@ -7,7 +7,7 @@ import { KubeApi, parseKubeApi } from "./kube-api";
|
|||||||
@autobind()
|
@autobind()
|
||||||
export class ApiManager {
|
export class ApiManager {
|
||||||
private apis = observable.map<string, KubeApi>();
|
private apis = observable.map<string, KubeApi>();
|
||||||
private stores = observable.map<KubeApi, KubeObjectStore>();
|
private stores = observable.map<string, KubeObjectStore>();
|
||||||
|
|
||||||
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {
|
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {
|
||||||
if (typeof pathOrCallback === "string") {
|
if (typeof pathOrCallback === "string") {
|
||||||
@ -46,12 +46,12 @@ export class ApiManager {
|
|||||||
@action
|
@action
|
||||||
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
|
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
|
||||||
apis.forEach(api => {
|
apis.forEach(api => {
|
||||||
this.stores.set(api, store);
|
this.stores.set(api.apiBase, store);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getStore<S extends KubeObjectStore>(api: string | KubeApi): S {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user