Skip to content

Commit

Permalink
[Enterprise Search][bug/tech debt] Fix route navigation (#75369) (#75578
Browse files Browse the repository at this point in the history
)

* Set up navigateToUrl context

* Update RR link helpers to use navigateToUrl

* Update breadcrumbs to use navigateToUrl + refactor

generate_breadcrumbs:
- Change base breadcrumb generator to a custom React useHook instead of passing history/context around
- Change use{Product}Breadcrumbs helpers to mainly involve merging arrays
- Update + simplify tests accordingly (test link behavior in main useBreadcrumb suite, not in subsequent helpers)

set_chrome:
- Update to use new breadcrumb hooks (requires pulling out of useEffect, hooks can't be used inside another hook)
- Clean up/refactor tests

* Update route redirects now that navigation works correctly
  • Loading branch information
Constance authored Aug 20, 2020
1 parent fc526d8 commit 3dcec1c
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ExternalUrl } from '../shared/enterprise_search_url';
*/
export const mockKibanaContext = {
http: httpServiceMock.createSetupContract(),
navigateToUrl: jest.fn(),
setBreadcrumbs: jest.fn(),
setDocTitle: jest.fn(),
config: { host: 'http://localhost:3002' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const AppSearch: React.FC = () => {
</Route>
<Route>
<Redirect to={SETUP_GUIDE_PATH} />
<SetupGuide /> {/* Kibana displays a blank page on redirect if this isn't included */}
</Route>
</Switch>
);
Expand All @@ -50,8 +49,7 @@ export const AppSearch: React.FC = () => {
<Layout navigation={<AppSearchNav />}>
<Switch>
<Route exact path={ROOT_PATH}>
{/* For some reason a Redirect to /engines just doesn't work here - it shows a blank page */}
<EngineOverview />
<Redirect to={ENGINES_PATH} />
</Route>
<Route exact path={ENGINES_PATH}>
<EngineOverview />
Expand Down
10 changes: 9 additions & 1 deletion x-pack/plugins/enterprise_search/public/applications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import ReactDOM from 'react-dom';
import { Router } from 'react-router-dom';

import { I18nProvider } from '@kbn/i18n/react';
import { CoreStart, AppMountParameters, HttpSetup, ChromeBreadcrumb } from 'src/core/public';
import {
AppMountParameters,
CoreStart,
ApplicationStart,
HttpSetup,
ChromeBreadcrumb,
} from 'src/core/public';
import { ClientConfigType, ClientData, PluginsSetup } from '../plugin';
import { LicenseProvider } from './shared/licensing';
import { IExternalUrl } from './shared/enterprise_search_url';
Expand All @@ -18,6 +24,7 @@ export interface IKibanaContext {
config: { host?: string };
externalUrl: IExternalUrl;
http: HttpSetup;
navigateToUrl: ApplicationStart['navigateToUrl'];
setBreadcrumbs(crumbs: ChromeBreadcrumb[]): void;
setDocTitle(title: string): void;
}
Expand All @@ -44,6 +51,7 @@ export const renderApp = (
value={{
config,
http: core.http,
navigateToUrl: core.application.navigateToUrl,
externalUrl: data.externalUrl,
setBreadcrumbs: core.chrome.setBreadcrumbs,
setDocTitle: core.chrome.docTitle.change,
Expand Down
Loading

0 comments on commit 3dcec1c

Please sign in to comment.