From d16023c72245bdf782091934b60b5b0c9c794bdb Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 22 Jun 2021 13:45:25 -0400 Subject: [PATCH] [App Search] Convert Analytics views to new page template (#102851) (#102945) * Convert AnalyticsHeader to AnalyticsFilters - it's basically the same component as before, but without the title section/log retention tooltip, since the header/title will be handled by the new page template * Update AnalyticsLayout to use new page template + add new test_helper for header children * Update breadcrumb behavior - Set analytic breadcrumbs in AnalyticsLayout rather than AnalyticsRouter - Update individual views to pass breadcrumbs (consistent with new page template API) * Update router Co-authored-by: Constance --- .../analytics/analytics_layout.test.tsx | 28 ++-- .../components/analytics/analytics_layout.tsx | 34 +++-- .../components/analytics/analytics_router.tsx | 25 +--- ...er.test.tsx => analytics_filters.test.tsx} | 24 ++-- .../components/analytics_filters.tsx | 111 ++++++++++++++ .../components/analytics_header.scss | 15 -- .../analytics/components/analytics_header.tsx | 136 ------------------ .../components/analytics/components/index.ts | 2 +- .../analytics/views/query_detail.test.tsx | 16 +-- .../analytics/views/query_detail.tsx | 11 +- .../analytics/views/recent_queries.tsx | 2 +- .../analytics/views/top_queries.tsx | 2 +- .../analytics/views/top_queries_no_clicks.tsx | 6 +- .../views/top_queries_no_results.tsx | 6 +- .../views/top_queries_with_clicks.tsx | 6 +- .../components/engine/engine_router.tsx | 10 +- .../test_helpers/get_page_header.tsx | 6 + .../public/applications/test_helpers/index.ts | 1 + 18 files changed, 199 insertions(+), 242 deletions(-) rename x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/{analytics_header.test.tsx => analytics_filters.test.tsx} (87%) create mode 100644 x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_filters.tsx delete mode 100644 x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.scss delete mode 100644 x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.tsx diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx index 9832915f19e9ed..280282a2fc6ecd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.test.tsx @@ -8,18 +8,22 @@ import '../../../__mocks__/shallow_useeffect.mock'; import { mockKibanaValues, setMockValues, setMockActions } from '../../../__mocks__/kea_logic'; import { mockUseParams } from '../../../__mocks__/react_router'; +import '../../__mocks__/engine_logic.mock'; import React from 'react'; import { shallow } from 'enzyme'; -import { FlashMessages } from '../../../shared/flash_messages'; -import { Loading } from '../../../shared/loading'; -import { rerender } from '../../../test_helpers'; -import { LogRetentionCallout } from '../log_retention'; +import { + rerender, + getPageTitle, + getPageHeaderActions, + getPageHeaderChildren, +} from '../../../test_helpers'; +import { LogRetentionTooltip, LogRetentionCallout } from '../log_retention'; import { AnalyticsLayout } from './analytics_layout'; -import { AnalyticsHeader } from './components'; +import { AnalyticsFilters } from './components'; describe('AnalyticsLayout', () => { const { history } = mockKibanaValues; @@ -47,18 +51,20 @@ describe('AnalyticsLayout', () => { ); - expect(wrapper.find(FlashMessages)).toHaveLength(1); expect(wrapper.find(LogRetentionCallout)).toHaveLength(1); + expect(getPageHeaderActions(wrapper).find(LogRetentionTooltip)).toHaveLength(1); + expect(getPageHeaderChildren(wrapper).find(AnalyticsFilters)).toHaveLength(1); - expect(wrapper.find(AnalyticsHeader).prop('title')).toEqual('Hello'); + expect(getPageTitle(wrapper)).toEqual('Hello'); expect(wrapper.find('[data-test-subj="world"]').text()).toEqual('World!'); + + expect(wrapper.prop('pageChrome')).toEqual(['Engines', 'some-engine', 'Analytics']); }); - it('renders a loading component if data is not done loading', () => { - setMockValues({ ...values, dataLoading: true }); - const wrapper = shallow(); + it('passes analytics breadcrumbs', () => { + const wrapper = shallow(); - expect(wrapper.type()).toEqual(Loading); + expect(wrapper.prop('pageChrome')).toEqual(['Engines', 'some-engine', 'Analytics', 'Queries']); }); describe('data loading', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.tsx index 91de4cc4989886..0923f9497a8fe5 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_layout.tsx @@ -10,25 +10,27 @@ import { useParams } from 'react-router-dom'; import { useValues, useActions } from 'kea'; -import { EuiSpacer } from '@elastic/eui'; - -import { FlashMessages } from '../../../shared/flash_messages'; import { KibanaLogic } from '../../../shared/kibana'; -import { Loading } from '../../../shared/loading'; +import { BreadcrumbTrail } from '../../../shared/kibana_chrome/generate_breadcrumbs'; +import { getEngineBreadcrumbs } from '../engine'; +import { AppSearchPageTemplate } from '../layout'; -import { LogRetentionCallout, LogRetentionOptions } from '../log_retention'; +import { LogRetentionTooltip, LogRetentionCallout, LogRetentionOptions } from '../log_retention'; -import { AnalyticsHeader } from './components'; +import { AnalyticsFilters } from './components'; +import { ANALYTICS_TITLE } from './constants'; import { AnalyticsLogic } from './'; interface Props { title: string; + breadcrumbs?: BreadcrumbTrail; isQueryView?: boolean; isAnalyticsView?: boolean; } export const AnalyticsLayout: React.FC = ({ title, + breadcrumbs = [], isQueryView, isAnalyticsView, children, @@ -43,15 +45,21 @@ export const AnalyticsLayout: React.FC = ({ if (isAnalyticsView) loadAnalyticsData(); }, [history.location.search]); - if (dataLoading) return ; - return ( - <> - - + , + ], + children: , + responsive: false, + }} + isLoading={dataLoading} + > {children} - - + ); }; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_router.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_router.tsx index 397f1f1e1e1c38..d56fe949431c3c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_router.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_router.tsx @@ -9,7 +9,6 @@ import React from 'react'; import { Route, Switch, Redirect } from 'react-router-dom'; import { APP_SEARCH_PLUGIN } from '../../../../../common/constants'; -import { SetAppSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome'; import { NotFound } from '../../../shared/not_found'; import { ENGINE_ANALYTICS_PATH, @@ -23,14 +22,7 @@ import { } from '../../routes'; import { generateEnginePath, getEngineBreadcrumbs } from '../engine'; -import { - ANALYTICS_TITLE, - TOP_QUERIES, - TOP_QUERIES_NO_RESULTS, - TOP_QUERIES_NO_CLICKS, - TOP_QUERIES_WITH_CLICKS, - RECENT_QUERIES, -} from './constants'; +import { ANALYTICS_TITLE } from './constants'; import { Analytics, TopQueries, @@ -42,42 +34,37 @@ import { } from './views'; export const AnalyticsRouter: React.FC = () => { - const ANALYTICS_BREADCRUMB = getEngineBreadcrumbs([ANALYTICS_TITLE]); - return ( - - - - - - - + - + ); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_filters.test.tsx similarity index 87% rename from x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.test.tsx rename to x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_filters.test.tsx index 5269ea91100659..7abb02110e2d91 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_filters.test.tsx @@ -12,15 +12,13 @@ import React, { ReactElement } from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; import moment, { Moment } from 'moment'; -import { EuiPageHeader, EuiSelect, EuiDatePickerRange, EuiButton } from '@elastic/eui'; - -import { LogRetentionTooltip } from '../../log_retention'; +import { EuiSelect, EuiDatePickerRange, EuiButton } from '@elastic/eui'; import { DEFAULT_START_DATE, DEFAULT_END_DATE } from '../constants'; -import { AnalyticsHeader } from './'; +import { AnalyticsFilters } from './'; -describe('AnalyticsHeader', () => { +describe('AnalyticsFilters', () => { const { history } = mockKibanaValues; const values = { @@ -45,18 +43,14 @@ describe('AnalyticsHeader', () => { }); it('renders', () => { - wrapper = shallow(); - - expect(wrapper.type()).toEqual(EuiPageHeader); - expect(wrapper.find('h1').text()).toEqual('Hello world'); + wrapper = shallow(); - expect(wrapper.find(LogRetentionTooltip)).toHaveLength(1); expect(wrapper.find(EuiSelect)).toHaveLength(1); expect(wrapper.find(EuiDatePickerRange)).toHaveLength(1); }); it('renders tags & dates with default values when no search query params are present', () => { - wrapper = shallow(); + wrapper = shallow(); expect(getTagsSelect().prop('value')).toEqual(''); expect(getStartDatePicker().props.startDate._i).toEqual(DEFAULT_START_DATE); @@ -69,7 +63,7 @@ describe('AnalyticsHeader', () => { const allTags = [...values.allTags, 'tag1', 'tag2', 'tag3']; setMockValues({ ...values, allTags }); - wrapper = shallow(); + wrapper = shallow(); }); it('renders the tags select with currentTag value and allTags options', () => { @@ -95,7 +89,7 @@ describe('AnalyticsHeader', () => { beforeEach(() => { history.location.search = '?start=1970-01-01&end=1970-01-02'; - wrapper = shallow(); + wrapper = shallow(); }); it('renders the start date picker', () => { @@ -127,7 +121,7 @@ describe('AnalyticsHeader', () => { beforeEach(() => { history.location.search = '?start=1970-01-02&end=1970-01-01'; - wrapper = shallow(); + wrapper = shallow(); }); it('renders the date pickers as invalid', () => { @@ -148,7 +142,7 @@ describe('AnalyticsHeader', () => { }; beforeEach(() => { - wrapper = shallow(); + wrapper = shallow(); }); it('pushes up new tag & date state to the search query', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_filters.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_filters.tsx new file mode 100644 index 00000000000000..0c8455e986ae1d --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_filters.tsx @@ -0,0 +1,111 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useState } from 'react'; + +import { useValues } from 'kea'; +import moment from 'moment'; +import queryString from 'query-string'; + +import { + EuiFlexGroup, + EuiFlexItem, + EuiSelect, + EuiDatePickerRange, + EuiDatePicker, + EuiButton, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; + +import { AnalyticsLogic } from '../'; +import { KibanaLogic } from '../../../../shared/kibana'; + +import { DEFAULT_START_DATE, DEFAULT_END_DATE, SERVER_DATE_FORMAT } from '../constants'; +import { convertTagsToSelectOptions } from '../utils'; + +export const AnalyticsFilters: React.FC = () => { + const { allTags } = useValues(AnalyticsLogic); + const { history } = useValues(KibanaLogic); + + // Parse out existing filters from URL query string + const { start, end, tag } = queryString.parse(history.location.search); + const [startDate, setStartDate] = useState( + start ? moment(start, SERVER_DATE_FORMAT) : moment(DEFAULT_START_DATE) + ); + const [endDate, setEndDate] = useState( + end ? moment(end, SERVER_DATE_FORMAT) : moment(DEFAULT_END_DATE) + ); + const [currentTag, setCurrentTag] = useState((tag as string) || ''); + + // Set the current URL query string on filter + const onApplyFilters = () => { + const search = queryString.stringify({ + start: moment(startDate).format(SERVER_DATE_FORMAT), + end: moment(endDate).format(SERVER_DATE_FORMAT), + tag: currentTag || undefined, + }); + history.push({ search }); + }; + + const hasInvalidDateRange = startDate > endDate; + + return ( + + + setCurrentTag(e.target.value)} + aria-label={i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.tagAriaLabel', + { defaultMessage: 'Filter by analytics tag"' } + )} + fullWidth + /> + + + date && setStartDate(date)} + startDate={startDate} + endDate={endDate} + isInvalid={hasInvalidDateRange} + aria-label={i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.startDateAriaLabel', + { defaultMessage: 'Filter by start date' } + )} + /> + } + endDateControl={ + date && setEndDate(date)} + startDate={startDate} + endDate={endDate} + isInvalid={hasInvalidDateRange} + aria-label={i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.endDateAriaLabel', + { defaultMessage: 'Filter by end date' } + )} + /> + } + fullWidth + /> + + + + {i18n.translate( + 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.applyButtonLabel', + { defaultMessage: 'Apply filters' } + )} + + + + ); +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.scss b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.scss deleted file mode 100644 index abe6c0e0789a8d..00000000000000 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.scss +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -.analyticsHeader { - flex-wrap: wrap; - - &__filters.euiPageHeaderSection { - width: 100%; - margin: $euiSizeM 0; - } -} diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.tsx deleted file mode 100644 index 8a87a5e8c211c8..00000000000000 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_header.tsx +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { useState } from 'react'; - -import { useValues } from 'kea'; -import moment from 'moment'; -import queryString from 'query-string'; - -import { - EuiPageHeader, - EuiPageHeaderSection, - EuiTitle, - EuiFlexGroup, - EuiFlexItem, - EuiSelect, - EuiDatePickerRange, - EuiDatePicker, - EuiButton, -} from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; - -import { AnalyticsLogic } from '../'; -import { KibanaLogic } from '../../../../shared/kibana'; -import { LogRetentionTooltip, LogRetentionOptions } from '../../log_retention'; - -import { DEFAULT_START_DATE, DEFAULT_END_DATE, SERVER_DATE_FORMAT } from '../constants'; -import { convertTagsToSelectOptions } from '../utils'; - -import './analytics_header.scss'; - -interface Props { - title: string; -} -export const AnalyticsHeader: React.FC = ({ title }) => { - const { allTags } = useValues(AnalyticsLogic); - const { history } = useValues(KibanaLogic); - - // Parse out existing filters from URL query string - const { start, end, tag } = queryString.parse(history.location.search); - const [startDate, setStartDate] = useState( - start ? moment(start, SERVER_DATE_FORMAT) : moment(DEFAULT_START_DATE) - ); - const [endDate, setEndDate] = useState( - end ? moment(end, SERVER_DATE_FORMAT) : moment(DEFAULT_END_DATE) - ); - const [currentTag, setCurrentTag] = useState((tag as string) || ''); - - // Set the current URL query string on filter - const onApplyFilters = () => { - const search = queryString.stringify({ - start: moment(startDate).format(SERVER_DATE_FORMAT), - end: moment(endDate).format(SERVER_DATE_FORMAT), - tag: currentTag || undefined, - }); - history.push({ search }); - }; - - const hasInvalidDateRange = startDate > endDate; - - return ( - - - - - -

{title}

-
-
- - - -
-
- - - - setCurrentTag(e.target.value)} - aria-label={i18n.translate( - 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.tagAriaLabel', - { defaultMessage: 'Filter by analytics tag"' } - )} - fullWidth - /> - - - date && setStartDate(date)} - startDate={startDate} - endDate={endDate} - isInvalid={hasInvalidDateRange} - aria-label={i18n.translate( - 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.startDateAriaLabel', - { defaultMessage: 'Filter by start date' } - )} - /> - } - endDateControl={ - date && setEndDate(date)} - startDate={startDate} - endDate={endDate} - isInvalid={hasInvalidDateRange} - aria-label={i18n.translate( - 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.endDateAriaLabel', - { defaultMessage: 'Filter by end date' } - )} - /> - } - fullWidth - /> - - - - {i18n.translate( - 'xpack.enterpriseSearch.appSearch.engine.analytics.filters.applyButtonLabel', - { defaultMessage: 'Apply filters' } - )} - - - - -
- ); -}; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/index.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/index.ts index de5c8209d2347c..5309681b80d6d0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/index.ts @@ -7,7 +7,7 @@ export { AnalyticsCards } from './analytics_cards'; export { AnalyticsChart } from './analytics_chart'; -export { AnalyticsHeader } from './analytics_header'; +export { AnalyticsFilters } from './analytics_filters'; export { AnalyticsSection } from './analytics_section'; export { AnalyticsSearch } from './analytics_search'; export { AnalyticsTable, RecentQueriesTable, QueryClicksTable } from './analytics_tables'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx index a942918fa9c623..f3fee2553d2fde 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.test.tsx @@ -12,16 +12,12 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome'; - import { AnalyticsLayout } from '../analytics_layout'; import { AnalyticsCards, AnalyticsChart, QueryClicksTable } from '../components'; import { QueryDetail } from './'; describe('QueryDetail', () => { - const mockBreadcrumbs = ['Engines', 'some-engine', 'Analytics']; - beforeEach(() => { mockUseParams.mockReturnValue({ query: 'some-query' }); @@ -32,16 +28,10 @@ describe('QueryDetail', () => { }); it('renders', () => { - const wrapper = shallow(); + const wrapper = shallow(); expect(wrapper.find(AnalyticsLayout).prop('title')).toEqual('"some-query"'); - expect(wrapper.find(SetPageChrome).prop('trail')).toEqual([ - 'Engines', - 'some-engine', - 'Analytics', - 'Query', - 'some-query', - ]); + expect(wrapper.find(AnalyticsLayout).prop('breadcrumbs')).toEqual(['Query', 'some-query']); expect(wrapper.find(AnalyticsCards)).toHaveLength(1); expect(wrapper.find(AnalyticsChart)).toHaveLength(1); @@ -50,7 +40,7 @@ describe('QueryDetail', () => { it('renders empty "" search titles correctly', () => { mockUseParams.mockReturnValue({ query: '""' }); - const wrapper = shallow(); + const wrapper = shallow(); expect(wrapper.find(AnalyticsLayout).prop('title')).toEqual('""'); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.tsx index 83c83aa36f1bbf..e68984459cf10f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/query_detail.tsx @@ -12,8 +12,6 @@ import { useValues } from 'kea'; import { EuiPanel, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome'; -import { BreadcrumbTrail } from '../../../../shared/kibana_chrome/generate_breadcrumbs'; import { useDecodedParams } from '../../../utils/encode_path_params'; import { AnalyticsLayout } from '../analytics_layout'; @@ -25,10 +23,7 @@ const QUERY_DETAIL_TITLE = i18n.translate( { defaultMessage: 'Query' } ); -interface Props { - breadcrumbs: BreadcrumbTrail; -} -export const QueryDetail: React.FC = ({ breadcrumbs }) => { +export const QueryDetail: React.FC = () => { const { query } = useDecodedParams(); const queryTitle = query === '""' ? query : `"${query}"`; @@ -37,9 +32,7 @@ export const QueryDetail: React.FC = ({ breadcrumbs }) => { ); return ( - - - + { const { recentQueries } = useValues(AnalyticsLogic); return ( - + diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.tsx index 6459126560b3aa..81b3d08770be6b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries.tsx @@ -18,7 +18,7 @@ export const TopQueries: React.FC = () => { const { topQueries } = useValues(AnalyticsLogic); return ( - + diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.tsx index 8e2591697feaad..2aec88bd372fe3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_clicks.tsx @@ -18,7 +18,11 @@ export const TopQueriesNoClicks: React.FC = () => { const { topQueriesNoClicks } = useValues(AnalyticsLogic); return ( - + diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.tsx index e093a5130d2042..835b259330c839 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_no_results.tsx @@ -18,7 +18,11 @@ export const TopQueriesNoResults: React.FC = () => { const { topQueriesNoResults } = useValues(AnalyticsLogic); return ( - + diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.tsx index 87e276a8382c33..9bea265df55aeb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/views/top_queries_with_clicks.tsx @@ -18,7 +18,11 @@ export const TopQueriesWithClicks: React.FC = () => { const { topQueriesWithClicks } = useValues(AnalyticsLogic); return ( - + diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx index 98627950016fb4..b390b1a52b9278 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx @@ -94,6 +94,11 @@ export const EngineRouter: React.FC = () => { + {canViewEngineAnalytics && ( + + + + )} {canViewEngineDocuments && ( @@ -106,11 +111,6 @@ export const EngineRouter: React.FC = () => { )} {/* TODO: Remove layout once page template migration is over */} }> - {canViewEngineAnalytics && ( - - - - )} {canViewEngineSchema && ( diff --git a/x-pack/plugins/enterprise_search/public/applications/test_helpers/get_page_header.tsx b/x-pack/plugins/enterprise_search/public/applications/test_helpers/get_page_header.tsx index 6e89274dca5703..a251188b5cd90b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/test_helpers/get_page_header.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/test_helpers/get_page_header.tsx @@ -41,3 +41,9 @@ export const getPageHeaderActions = (wrapper: ShallowWrapper) => { ); }; + +export const getPageHeaderChildren = (wrapper: ShallowWrapper) => { + const children = getPageHeader(wrapper).children || null; + + return shallow(
{children}
); +}; diff --git a/x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts b/x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts index ed5c3f85a888ee..7903b4a31c8a96 100644 --- a/x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/test_helpers/index.ts @@ -15,6 +15,7 @@ export { getPageTitle, getPageDescription, getPageHeaderActions, + getPageHeaderChildren, } from './get_page_header'; // Misc