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:
parent
19ded006c0
commit
77195c5222
@ -6,25 +6,26 @@ import { getInjectable } from "@ogre-tools/injectable";
|
|||||||
import { Router } from "react-router";
|
import { Router } from "react-router";
|
||||||
import historyInjectable from "../navigation/history.injectable";
|
import historyInjectable from "../navigation/history.injectable";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
reactApplicationWrapperInjectionToken,
|
reactApplicationHigherOrderComponentInjectionToken,
|
||||||
} from "@k8slens/react-application-root";
|
} from "@k8slens/react-application-root";
|
||||||
|
|
||||||
const routingApplicationRootWrapperInjectable = getInjectable({
|
const routingReactApplicationHocInjectable = getInjectable({
|
||||||
id: "routing-application-root-wrapper",
|
id: "routing-react-application-hoc",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const history = di.inject(historyInjectable);
|
const history = di.inject(historyInjectable);
|
||||||
|
|
||||||
return (Component) => () =>
|
return ({ children }) =>
|
||||||
(
|
(
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
<Component />
|
{children}
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
injectionToken: reactApplicationWrapperInjectionToken,
|
injectionToken: reactApplicationHigherOrderComponentInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default routingApplicationRootWrapperInjectable;
|
export default routingReactApplicationHocInjectable;
|
||||||
@ -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;
|
|
||||||
@ -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;
|
||||||
Loading…
Reference in New Issue
Block a user