From 91b14ee3fc0d28a6680a3882dffb5e6e18762747 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Thu, 4 Nov 2021 09:51:28 +0200 Subject: [PATCH] Demonstrate a step further to have an interface as dependency instead of concrete instance With this we get yet closer to satisfaction of Dependency Inversion Principle. Signed-off-by: Janne Savolainen --- src/common/k8s-api/api-manager.ts | 6 +++++- .../components/kube-object-menu/kube-object-menu.tsx | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/k8s-api/api-manager.ts b/src/common/k8s-api/api-manager.ts index 1dec033db3..2480506d37 100644 --- a/src/common/k8s-api/api-manager.ts +++ b/src/common/k8s-api/api-manager.ts @@ -27,7 +27,11 @@ import type { KubeApi } from "./kube-api"; import type { KubeObject } from "./kube-object"; import { IKubeObjectRef, parseKubeApi, createKubeApiURL } from "./kube-api-parse"; -export class ApiManager { +export interface IGettableStore { + getStore>(api: string | KubeApi): TKubeObjectStore | undefined; +} + +export class ApiManager implements IGettableStore { private apis = observable.map>(); private stores = observable.map>(); diff --git a/src/renderer/components/kube-object-menu/kube-object-menu.tsx b/src/renderer/components/kube-object-menu/kube-object-menu.tsx index 2116221f03..c7ec3d473a 100644 --- a/src/renderer/components/kube-object-menu/kube-object-menu.tsx +++ b/src/renderer/components/kube-object-menu/kube-object-menu.tsx @@ -26,8 +26,8 @@ import { MenuActions, MenuActionsProps } from "../menu/menu-actions"; import identity from "lodash/identity"; import type { KubeObjectMenuRegistry } from "../../../extensions/registries"; -import type { ApiManager } from "../../../common/k8s-api/api-manager"; import type { CatalogEntityRegistry } from "../../api/catalog-entity-registry"; +import type { IGettableStore } from "../../../common/k8s-api/api-manager"; export interface KubeObjectMenuProps extends MenuActionsProps { @@ -37,7 +37,7 @@ export interface KubeObjectMenuProps extends MenuActionsProps { } interface KubeObjectMenuDependencies extends KubeObjectMenuProps{ - apiManager: ApiManager, + apiManager: IGettableStore, hideDetails: Function, editResourceTab: Function, catalogEntityRegistry: CatalogEntityRegistry,