chore: Extract an injectionToken

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
Iku-turso authored and Sebastian Malton committed 2023-04-25 17:38:02 -04:00
1 parent 0dae1594ba
commit db9a3675e1
7 files changed
+19 -14

No files matched your search

@@ -16,7 +16,7 @@ import { Animate } from "../animate";
import { ResizeDirection, ResizeGrowthDirection, ResizeSide, ResizingAnchor } from "../resizing-anchor";
import drawerStorageInjectable, { defaultDrawerWidth } from "./drawer-storage/drawer-storage.injectable";
import { withInjectables } from "@ogre-tools/injectable-react";
import { historyInjectable } from "@k8slens/routing";
import { historyInjectionToken } from "@k8slens/routing";
import type { History } from "history";
import type { StorageLayer } from "../../utils/storage-helper";
@@ -251,7 +251,7 @@ class NonInjectedDrawer extends React.Component<DrawerProps & Dependencies & typ
export const Drawer = withInjectables<Dependencies, DrawerProps>(NonInjectedDrawer as React.ElementType<DrawerProps & Dependencies>, {
getProps: (di, props) => ({
...props,
history: di.inject(historyInjectable),
history: di.inject(historyInjectionToken),
drawerStorage: di.inject(drawerStorageInjectable),
}),
});
@@ -24,7 +24,6 @@ import navigateToHelmChartsInjectable from "../../../common/front-end-routing/ro
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
import { Cluster } from "../../../common/cluster/cluster";
import type { NamespaceStore } from "../+namespaces/store";
import { historyInjectable } from "@k8slens/routing";
import type { MinimalTrayMenuItem } from "../../../main/tray/electron-tray/electron-tray.injectable";
import electronTrayInjectable from "../../../main/tray/electron-tray/electron-tray.injectable";
import { getDiForUnitTesting as getRendererDi } from "../../getDiForUnitTesting";
@@ -71,6 +70,7 @@ import { applicationFeature, startApplicationInjectionToken } from "@k8slens/app
import { testUsingFakeTime } from "../../../test-utils/use-fake-time";
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
import { getMessageBridgeFake } from "@k8slens/messaging-fake-bridge";
import { historyInjectionToken } from "@k8slens/routing";
type MainDiCallback = (container: { mainDi: DiContainer }) => void | Promise<void>;
type WindowDiCallback = (container: { windowDi: DiContainer }) => void | Promise<void>;
@@ -292,7 +292,7 @@ export const getApplicationBuilder = () => {
await callback({ windowDi });
}
const history = windowDi.inject(historyInjectable);
const history = windowDi.inject(historyInjectionToken);
const render = renderFor(windowDi);
@@ -12,7 +12,7 @@ import { DiContextProvider } from "@ogre-tools/injectable-react";
import { Router } from "react-router";
import { DefaultProps } from "../../mui-base-theme";
import { ClusterFrame } from "./cluster-frame";
import { historyInjectable } from "@k8slens/routing";
import { historyInjectionToken } from "@k8slens/routing";
import { computed } from "mobx";
import { Cluster } from "../../../common/cluster/cluster";
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
@@ -34,7 +34,7 @@ describe("<ClusterFrame />", () => {
di = getDiForUnitTesting();
render = () => testingLibraryRender((
<DiContextProvider value={{ di }}>
<Router history={di.inject(historyInjectable)}>
<Router history={di.inject(historyInjectionToken)}>
{DefaultProps(ClusterFrame)}
</Router>
</DiContextProvider>
@@ -4,7 +4,7 @@
*/
import { getInjectable } from "@ogre-tools/injectable";
import { Router } from "react-router";
import { historyInjectable } from "@k8slens/routing";
import { historyInjectionToken } from "@k8slens/routing";
import React from "react";
import {
@@ -15,7 +15,7 @@ const routingReactApplicationHocInjectable = getInjectable({
id: "routing-react-application-hoc",
instantiate: (di) => {
const history = di.inject(historyInjectable);
const history = di.inject(historyInjectionToken);
return ({ children }) =>
(
@@ -5,6 +5,6 @@
import { createMemoryHistory } from "history";
import { getGlobalOverride } from "@k8slens/test-utils";
import { historyInjectable } from "@k8slens/routing";
import { historyInjectionToken } from "@k8slens/routing";
export default getGlobalOverride(historyInjectable, () => createMemoryHistory());
export default getGlobalOverride(historyInjectionToken, () => createMemoryHistory());