diff --git a/src/common/k8s-api/api-manager.ts b/src/common/k8s-api/api-manager.ts index f612dc4bb2..3c494de2ca 100644 --- a/src/common/k8s-api/api-manager.ts +++ b/src/common/k8s-api/api-manager.ts @@ -11,16 +11,16 @@ import type { KubeApi } from "./kube-api"; import type { KubeObject } from "./kube-object"; import { IKubeObjectRef, parseKubeApi, createKubeApiURL } from "./kube-api-parse"; -export class ApiManager { - private apis = observable.map>(); - private stores = observable.map>(); +export class ApiManager { + private apis = observable.map>(); + private stores = observable.map>(); constructor() { makeObservable(this); autoBind(this); } - getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) { + getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) { if (typeof pathOrCallback === "string") { return this.apis.get(pathOrCallback) || this.apis.get(parseKubeApi(pathOrCallback).apiBase); } @@ -32,7 +32,7 @@ export class ApiManager { return iter.find(this.apis.values(), api => api.kind === kind && api.apiVersionWithGroup === apiVersion); } - registerApi(apiBase: string, api: KubeApi) { + registerApi(apiBase: string, api: KubeApi) { if (!api.apiBase) return; if (!this.apis.has(apiBase)) { @@ -46,19 +46,19 @@ export class ApiManager { } } - protected resolveApi(api?: string | KubeApi): KubeApi | undefined { + protected resolveApi(api?: string | KubeApi): KubeApi | undefined { if (!api) { return undefined; } if (typeof api === "string") { - return this.getApi(api) as KubeApi; + return this.getApi(api) as KubeApi; } return api; } - unregisterApi(api: string | KubeApi) { + unregisterApi(api: string | KubeApi) { if (typeof api === "string") this.apis.delete(api); else { const apis = Array.from(this.apis.entries()); @@ -69,13 +69,13 @@ export class ApiManager { } @action - registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) { + registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) { apis.filter(Boolean).forEach(api => { if (api.apiBase) this.stores.set(api.apiBase, store); }); } - getStore>(api: string | KubeApi): S | undefined { + getStore>(api: string | KubeApi): S | undefined { return this.stores.get(this.resolveApi(api)?.apiBase) as S; }