|
7 | 7 | import * as React from 'react'; |
8 | 8 | import ReactDOM from 'react-dom'; |
9 | 9 | import { CoreStart, AppMountParameters, ScopedHistory } from 'kibana/public'; |
10 | | -import { I18nProvider, FormattedMessage } from '@kbn/i18n/react'; |
11 | | -import { Route, Switch, Router } from 'react-router-dom'; |
12 | | -import { Provider } from 'react-redux'; |
| 10 | +import { FormattedMessage } from '@kbn/i18n/react'; |
| 11 | +import { Route, Switch } from 'react-router-dom'; |
13 | 12 | import { Store } from 'redux'; |
14 | | -import { useObservable } from 'react-use'; |
15 | | -import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; |
16 | | -import { RouteCapture } from './view/route_capture'; |
17 | 13 | import { EndpointPluginStartDependencies } from '../../plugin'; |
18 | 14 | import { appStoreFactory } from './store'; |
19 | 15 | import { AlertIndex } from './view/alerts'; |
20 | 16 | import { HostList } from './view/hosts'; |
21 | 17 | import { PolicyList } from './view/policy'; |
22 | 18 | import { PolicyDetails } from './view/policy'; |
23 | 19 | import { HeaderNavigation } from './components/header_nav'; |
24 | | -import { EuiThemeProvider } from '../../../../../legacy/common/eui_styled_components'; |
| 20 | +import { AppRootProvider } from './view/app_root_provider'; |
25 | 21 | import { Setup } from './view/setup'; |
26 | 22 |
|
27 | 23 | /** |
@@ -50,55 +46,32 @@ interface RouterProps { |
50 | 46 | } |
51 | 47 |
|
52 | 48 | const AppRoot: React.FunctionComponent<RouterProps> = React.memo( |
53 | | - ({ |
54 | | - history, |
55 | | - store, |
56 | | - coreStart: { http, notifications, uiSettings, application }, |
57 | | - depsStart: { data, ingestManager }, |
58 | | - }) => { |
59 | | - const isDarkMode = useObservable<boolean>(uiSettings.get$('theme:darkMode')); |
60 | | - |
| 49 | + ({ history, store, coreStart, depsStart }) => { |
61 | 50 | return ( |
62 | | - <Provider store={store}> |
63 | | - <I18nProvider> |
64 | | - <KibanaContextProvider services={{ http, notifications, application, data }}> |
65 | | - <Setup ingestManager={ingestManager} notifications={notifications} /> |
66 | | - <EuiThemeProvider darkMode={isDarkMode}> |
67 | | - <Router history={history}> |
68 | | - <RouteCapture> |
69 | | - <HeaderNavigation /> |
70 | | - <Switch> |
71 | | - <Route |
72 | | - exact |
73 | | - path="/" |
74 | | - render={() => ( |
75 | | - <h1 data-test-subj="welcomeTitle"> |
76 | | - <FormattedMessage |
77 | | - id="xpack.endpoint.welcomeTitle" |
78 | | - defaultMessage="Hello World" |
79 | | - /> |
80 | | - </h1> |
81 | | - )} |
82 | | - /> |
83 | | - <Route path="/hosts" component={HostList} /> |
84 | | - <Route path="/alerts" component={AlertIndex} /> |
85 | | - <Route path="/policy" exact component={PolicyList} /> |
86 | | - <Route path="/policy/:id" exact component={PolicyDetails} /> |
87 | | - <Route |
88 | | - render={() => ( |
89 | | - <FormattedMessage |
90 | | - id="xpack.endpoint.notFound" |
91 | | - defaultMessage="Page Not Found" |
92 | | - /> |
93 | | - )} |
94 | | - /> |
95 | | - </Switch> |
96 | | - </RouteCapture> |
97 | | - </Router> |
98 | | - </EuiThemeProvider> |
99 | | - </KibanaContextProvider> |
100 | | - </I18nProvider> |
101 | | - </Provider> |
| 51 | + <AppRootProvider store={store} history={history} coreStart={coreStart} depsStart={depsStart}> |
| 52 | + <Setup ingestManager={depsStart.ingestManager} notifications={coreStart.notifications} /> |
| 53 | + <HeaderNavigation /> |
| 54 | + <Switch> |
| 55 | + <Route |
| 56 | + exact |
| 57 | + path="/" |
| 58 | + render={() => ( |
| 59 | + <h1 data-test-subj="welcomeTitle"> |
| 60 | + <FormattedMessage id="xpack.endpoint.welcomeTitle" defaultMessage="Hello World" /> |
| 61 | + </h1> |
| 62 | + )} |
| 63 | + /> |
| 64 | + <Route path="/hosts" component={HostList} /> |
| 65 | + <Route path="/alerts" component={AlertIndex} /> |
| 66 | + <Route path="/policy" exact component={PolicyList} /> |
| 67 | + <Route path="/policy/:id" exact component={PolicyDetails} /> |
| 68 | + <Route |
| 69 | + render={() => ( |
| 70 | + <FormattedMessage id="xpack.endpoint.notFound" defaultMessage="Page Not Found" /> |
| 71 | + )} |
| 72 | + /> |
| 73 | + </Switch> |
| 74 | + </AppRootProvider> |
102 | 75 | ); |
103 | 76 | } |
104 | 77 | ); |
0 commit comments