Skip to content

Commit

Permalink
[Maps] Use theme provider in Maps-app (elastic#119060)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored and TinLe committed Dec 22, 2021
1 parent 0aa9366 commit d61497b
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 d61497b

Please sign in to comment.