1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Adapt to more familiar pattern for higher order components

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2023-03-31 10:28:29 +03:00
parent 19ded006c0
commit 77195c5222
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
3 changed files with 30 additions and 33 deletions

View File

@ -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 }) =>
(
<Router history={history}>
<Component />
{children}
</Router>
);
},
injectionToken: reactApplicationWrapperInjectionToken,
injectionToken: reactApplicationHigherOrderComponentInjectionToken,
});
export default routingApplicationRootWrapperInjectable;
export default routingReactApplicationHocInjectable;

View File

@ -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) => () =>
(
<ThemeProvider theme={defaultMuiBaseTheme}>
<Component />
</ThemeProvider>
),
injectionToken: reactApplicationWrapperInjectionToken,
});
export default themeProviderApplicationRootWrapperInjectable;

View File

@ -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 }) =>
<ThemeProvider theme={defaultMuiBaseTheme}>{children}</ThemeProvider>,
injectionToken: reactApplicationHigherOrderComponentInjectionToken,
});
export default themeProviderReactApplicationHocInjectable;