Skip to content

Commit

Permalink
[Enterprise Search] Add missing and remove redundant breadcrumbs (#96636
Browse files Browse the repository at this point in the history
) (#96838)

* Workplace Search: Remove redundant Overview breadcrumb from Sources

There is "Source name" breadcrumb that is used for Overview page

* App Search: remove "Overview" breadcrumb from Engine page

So instead of `engines / national-parks-demo / overview (greyed)`
we will have just
`engines / national-parks-demo (greyed)`

* App Search: Add "Engines" breadcrumb to the main App Search page

This needs to be added to 3 states of the page: Normal, Empty and Loading

* Fix failing WS test

* App Search: DRY out SetPageChrome declaration by putting it in header

* Fix failed test "ShallowWrapper::dive() can only be called on components"

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Vadim Yakhin <[email protected]>
  • Loading branch information
kibanamachine and yakhinvadim authored Apr 12, 2021
1 parent 6842bb8 commit 1d3a2bb
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { AnalyticsRouter } from '../analytics';
import { ApiLogs } from '../api_logs';
import { CurationsRouter } from '../curations';
import { DocumentDetail, Documents } from '../documents';
import { OVERVIEW_TITLE } from '../engine_overview';
import { EngineOverview } from '../engine_overview';
import { ENGINES_TITLE } from '../engines';
import { RelevanceTuning } from '../relevance_tuning';
Expand Down Expand Up @@ -122,7 +121,7 @@ export const EngineRouter: React.FC = () => {
</Route>
)}
<Route>
<SetPageChrome trail={[...engineBreadcrumb, OVERVIEW_TITLE]} />
<SetPageChrome trail={[...engineBreadcrumb]} />
<EngineOverview />
</Route>
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useValues, useActions } from 'kea';
import { EuiPageContent, EuiEmptyPrompt, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { EuiButtonTo } from '../../../../shared/react_router_helpers';
import { TelemetryLogic } from '../../../../shared/telemetry';
import { AppLogic } from '../../../app_logic';
Expand All @@ -32,7 +31,6 @@ export const EmptyState: React.FC = () => {

return (
<>
<SetPageChrome />
<EnginesOverviewHeader />
<EuiPageContent hasBorder className="emptyState">
{canManageEngines ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import React from 'react';

import { shallow } from 'enzyme';

import { EuiPageHeader } from '@elastic/eui';

import { EnginesOverviewHeader } from './';

describe('EnginesOverviewHeader', () => {
const wrapper = shallow(<EnginesOverviewHeader />)
.find(EuiPageHeader)
.dive()
.children()
.dive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,42 @@ import { EuiPageHeader, EuiButton } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { getAppSearchUrl } from '../../../../shared/enterprise_search_url';
import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { TelemetryLogic } from '../../../../shared/telemetry';

import { ENGINES_TITLE } from '../constants';

export const EnginesOverviewHeader: React.FC = () => {
const { sendAppSearchTelemetry } = useActions(TelemetryLogic);

return (
<EuiPageHeader
pageTitle={i18n.translate('xpack.enterpriseSearch.appSearch.enginesOverview.title', {
defaultMessage: 'Engines overview',
})}
rightSideItems={[
// eslint-disable-next-line @elastic/eui/href-or-on-click
<EuiButton
size="s"
iconType="popout"
href={getAppSearchUrl()}
target="_blank"
onClick={() =>
sendAppSearchTelemetry({
action: 'clicked',
metric: 'header_launch_button',
})
}
data-test-subj="launchButton"
>
{i18n.translate('xpack.enterpriseSearch.appSearch.productCta', {
defaultMessage: 'Launch App Search',
})}
</EuiButton>,
]}
/>
<>
<SetPageChrome trail={[ENGINES_TITLE]} />
<EuiPageHeader
pageTitle={i18n.translate('xpack.enterpriseSearch.appSearch.enginesOverview.title', {
defaultMessage: 'Engines overview',
})}
rightSideItems={[
// eslint-disable-next-line @elastic/eui/href-or-on-click
<EuiButton
size="s"
iconType="popout"
href={getAppSearchUrl()}
target="_blank"
onClick={() =>
sendAppSearchTelemetry({
action: 'clicked',
metric: 'header_launch_button',
})
}
data-test-subj="launchButton"
>
{i18n.translate('xpack.enterpriseSearch.appSearch.productCta', {
defaultMessage: 'Launch App Search',
})}
</EuiButton>,
]}
/>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import React from 'react';

import { EuiPageContent, EuiSpacer, EuiLoadingContent } from '@elastic/eui';

import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';

import { EnginesOverviewHeader } from './header';

export const LoadingState: React.FC = () => {
return (
<>
<SetPageChrome />
<EnginesOverviewHeader />
<EuiPageContent hasBorder paddingSize="l">
<EuiLoadingContent lines={5} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
} from '@elastic/eui';

import { FlashMessages } from '../../../shared/flash_messages';
import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { LicensingLogic } from '../../../shared/licensing';
import { EuiButtonTo } from '../../../shared/react_router_helpers';
import { convertMetaToPagination, handlePageChange } from '../../../shared/table_pagination';
Expand Down Expand Up @@ -80,7 +79,6 @@ export const EnginesOverview: React.FC = () => {

return (
<>
<SetPageChrome />
<SendTelemetry action="viewed" metric="engines_overview" />

<EnginesOverviewHeader />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('SourceRouter', () => {
const contentBreadCrumb = wrapper.find(SetPageChrome).at(1);
const settingsBreadCrumb = wrapper.find(SetPageChrome).at(2);

expect(overviewBreadCrumb.prop('trail')).toEqual([...loadingBreadcrumbs, NAV.OVERVIEW]);
expect(overviewBreadCrumb.prop('trail')).toEqual([...loadingBreadcrumbs]);
expect(contentBreadCrumb.prop('trail')).toEqual([...loadingBreadcrumbs, NAV.CONTENT]);
expect(settingsBreadCrumb.prop('trail')).toEqual([...loadingBreadcrumbs, NAV.SETTINGS]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const SourceRouter: React.FC = () => {
<Switch>
<Route exact path={sourcePath(SOURCE_DETAILS_PATH, sourceId, isOrganization)}>
<SendTelemetry action="viewed" metric="source_overview" />
<SetPageChrome trail={[NAV.SOURCES, name || '...', NAV.OVERVIEW]} />
<SetPageChrome trail={[NAV.SOURCES, name || '...']} />
<Overview />
</Route>
<Route exact path={sourcePath(SOURCE_CONTENT_PATH, sourceId, isOrganization)}>
Expand Down

0 comments on commit 1d3a2bb

Please sign in to comment.