Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Use theme provider in Maps-app #119060

Merged
merged 3 commits into from
Nov 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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