Skip to content

Commit

Permalink
[Maps] Use theme provider in Maps-app (#119060)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored Nov 30, 2021
1 parent 22b91fb commit a7d8ee6
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions x-pack/plugins/maps/public/render_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { Router, Switch, Route, Redirect, RouteComponentProps } from 'react-router-dom';
import { i18n } from '@kbn/i18n';
import type { AppMountParameters } from 'kibana/public';
import { KibanaThemeProvider } from '../../../../src/plugins/kibana_react/public';
import {
getCoreChrome,
getCoreI18n,
Expand Down Expand Up @@ -62,7 +63,7 @@ function setAppChrome() {
}

export async function renderApp(
{ element, history, onAppLeave, setHeaderActionMenu }: AppMountParameters,
{ element, history, onAppLeave, setHeaderActionMenu, theme$ }: AppMountParameters,
AppUsageTracker: React.FC
) {
goToSpecifiedPath = (path) => history.push(path);
Expand Down Expand Up @@ -109,27 +110,29 @@ export async function renderApp(
render(
<AppUsageTracker>
<I18nContext>
<Router history={history}>
<Switch>
<Route path={`/map/:savedMapId`} render={renderMapApp} />
<Route exact path={`/map`} render={renderMapApp} />
// Redirect other routes to list, or if hash-containing, their non-hash equivalents
<Route
path={``}
render={({ location: { pathname, hash } }) => {
if (hash) {
// Remove leading hash
const newPath = hash.substr(1);
return <Redirect to={newPath} />;
} else if (pathname === '/' || pathname === '') {
return <ListPage stateTransfer={stateTransfer} />;
} else {
return <Redirect to="/" />;
}
}}
/>
</Switch>
</Router>
<KibanaThemeProvider theme$={theme$}>
<Router history={history}>
<Switch>
<Route path={`/map/:savedMapId`} render={renderMapApp} />
<Route exact path={`/map`} render={renderMapApp} />
// Redirect other routes to list, or if hash-containing, their non-hash equivalents
<Route
path={``}
render={({ location: { pathname, hash } }) => {
if (hash) {
// Remove leading hash
const newPath = hash.substr(1);
return <Redirect to={newPath} />;
} else if (pathname === '/' || pathname === '') {
return <ListPage stateTransfer={stateTransfer} />;
} else {
return <Redirect to="/" />;
}
}}
/>
</Switch>
</Router>
</KibanaThemeProvider>
</I18nContext>
</AppUsageTracker>,
element
Expand Down

0 comments on commit a7d8ee6

Please sign in to comment.