From 77195c52227348ea3f989957e6859605ff8b26a6 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Fri, 31 Mar 2023 10:28:29 +0300 Subject: [PATCH] Adapt to more familiar pattern for higher order components Signed-off-by: Janne Savolainen --- ...ting-react-application-hoc.injectable.tsx} | 15 ++++++----- ...er-application-root-wrapper.injectable.tsx | 26 ------------------- ...vider-react-application-hoc.injectable.tsx | 22 ++++++++++++++++ 3 files changed, 30 insertions(+), 33 deletions(-) rename packages/core/src/renderer/frames/{routing-application-root-wrapper.injectable.tsx => routing-react-application-hoc.injectable.tsx} (62%) delete mode 100644 packages/core/src/renderer/frames/theme-provider-application-root-wrapper.injectable.tsx create mode 100644 packages/core/src/renderer/frames/theme-provider-react-application-hoc.injectable.tsx diff --git a/packages/core/src/renderer/frames/routing-application-root-wrapper.injectable.tsx b/packages/core/src/renderer/frames/routing-react-application-hoc.injectable.tsx similarity index 62% rename from packages/core/src/renderer/frames/routing-application-root-wrapper.injectable.tsx rename to packages/core/src/renderer/frames/routing-react-application-hoc.injectable.tsx index 207cc0d422..0b41e30945 100644 --- a/packages/core/src/renderer/frames/routing-application-root-wrapper.injectable.tsx +++ b/packages/core/src/renderer/frames/routing-react-application-hoc.injectable.tsx @@ -6,25 +6,26 @@ import { getInjectable } from "@ogre-tools/injectable"; import { Router } from "react-router"; import historyInjectable from "../navigation/history.injectable"; import React from "react"; + import { - reactApplicationWrapperInjectionToken, + reactApplicationHigherOrderComponentInjectionToken, } from "@k8slens/react-application-root"; -const routingApplicationRootWrapperInjectable = getInjectable({ - id: "routing-application-root-wrapper", +const routingReactApplicationHocInjectable = getInjectable({ + id: "routing-react-application-hoc", instantiate: (di) => { const history = di.inject(historyInjectable); - return (Component) => () => + return ({ children }) => ( - + {children} ); }, - injectionToken: reactApplicationWrapperInjectionToken, + injectionToken: reactApplicationHigherOrderComponentInjectionToken, }); -export default routingApplicationRootWrapperInjectable; +export default routingReactApplicationHocInjectable; diff --git a/packages/core/src/renderer/frames/theme-provider-application-root-wrapper.injectable.tsx b/packages/core/src/renderer/frames/theme-provider-application-root-wrapper.injectable.tsx deleted file mode 100644 index 577bac8efb..0000000000 --- a/packages/core/src/renderer/frames/theme-provider-application-root-wrapper.injectable.tsx +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { getInjectable } from "@ogre-tools/injectable"; -import React from "react"; -import { - reactApplicationWrapperInjectionToken, -} from "@k8slens/react-application-root"; -import { ThemeProvider } from "@material-ui/core"; -import { defaultMuiBaseTheme } from "../mui-base-theme"; - -const themeProviderApplicationRootWrapperInjectable = getInjectable({ - id: "theme-provider-application-root-wrapper", - - instantiate: () => (Component) => () => - ( - - - - ), - - injectionToken: reactApplicationWrapperInjectionToken, -}); - -export default themeProviderApplicationRootWrapperInjectable; diff --git a/packages/core/src/renderer/frames/theme-provider-react-application-hoc.injectable.tsx b/packages/core/src/renderer/frames/theme-provider-react-application-hoc.injectable.tsx new file mode 100644 index 0000000000..fc87fa7cc3 --- /dev/null +++ b/packages/core/src/renderer/frames/theme-provider-react-application-hoc.injectable.tsx @@ -0,0 +1,22 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getInjectable } from "@ogre-tools/injectable"; +import React from "react"; +import { reactApplicationHigherOrderComponentInjectionToken } from "@k8slens/react-application-root"; +import { ThemeProvider } from "@material-ui/core"; +import { defaultMuiBaseTheme } from "../mui-base-theme"; + +const themeProviderReactApplicationHocInjectable = getInjectable({ + id: "theme-provider-react-application-hoc", + + instantiate: + () => + ({ children }) => + {children}, + + injectionToken: reactApplicationHigherOrderComponentInjectionToken, +}); + +export default themeProviderReactApplicationHocInjectable;