From 21039e2387c25e1d98233ac052fbd3c985ba0e3b Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 1 Dec 2022 08:04:42 -0500 Subject: [PATCH] Remove usage of legacy global ClusterStore.getInstance Signed-off-by: Sebastian Malton --- .../components/cluster-manager/cluster-view.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/cluster-manager/cluster-view.tsx b/src/renderer/components/cluster-manager/cluster-view.tsx index 4129817fa0..4a22c80076 100644 --- a/src/renderer/components/cluster-manager/cluster-view.tsx +++ b/src/renderer/components/cluster-manager/cluster-view.tsx @@ -11,7 +11,6 @@ import { disposeOnUnmount, observer } from "mobx-react"; import { ClusterStatus } from "./cluster-status"; import type { ClusterFrameHandler } from "./cluster-frame-handler"; import type { Cluster } from "../../../common/cluster/cluster"; -import { ClusterStore } from "../../../common/cluster-store/cluster-store"; import { requestClusterActivation } from "../../ipc"; import { withInjectables } from "@ogre-tools/injectable-react"; import type { NavigateToCatalog } from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable"; @@ -20,18 +19,19 @@ import clusterViewRouteParametersInjectable from "./cluster-view-route-parameter import clusterFrameHandlerInjectable from "./cluster-frame-handler.injectable"; import type { CatalogEntityRegistry } from "../../api/catalog/entity/registry"; import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable"; +import type { GetClusterById } from "../../../common/cluster-store/get-by-id.injectable"; +import getClusterByIdInjectable from "../../../common/cluster-store/get-by-id.injectable"; interface Dependencies { clusterId: IComputedValue; clusterFrames: ClusterFrameHandler; navigateToCatalog: NavigateToCatalog; entityRegistry: CatalogEntityRegistry; + getClusterById: GetClusterById; } @observer class NonInjectedClusterView extends React.Component { - private readonly store = ClusterStore.getInstance(); - constructor(props: Dependencies) { super(props); makeObservable(this); @@ -42,7 +42,7 @@ class NonInjectedClusterView extends React.Component { } @computed get cluster(): Cluster | undefined { - return this.store.getById(this.clusterId); + return this.props.getClusterById(this.clusterId); } private readonly isViewLoaded = computed(() => this.props.clusterFrames.hasLoadedView(this.clusterId), { @@ -110,10 +110,11 @@ class NonInjectedClusterView extends React.Component { export const ClusterView = withInjectables(NonInjectedClusterView, { getProps: (di) => ({ - clusterId: di.inject(clusterViewRouteParametersInjectable).clusterId, + ...di.inject(clusterViewRouteParametersInjectable), navigateToCatalog: di.inject(navigateToCatalogInjectable), clusterFrames: di.inject(clusterFrameHandlerInjectable), entityRegistry: di.inject(catalogEntityRegistryInjectable), + getClusterById: di.inject(getClusterByIdInjectable), }), });