-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/7.x' into backport/7.x/pr-89320
- Loading branch information
Showing
37 changed files
with
1,125 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...arch/public/applications/app_search/components/analytics/components/analytics_header.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
.analyticsHeader { | ||
flex-wrap: wrap; | ||
|
||
&__filters.euiPageHeaderSection { | ||
width: 100%; | ||
margin: $euiSizeM 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.../public/applications/app_search/components/analytics/components/analytics_search.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { mockKibanaValues } from '../../../../__mocks__'; | ||
import '../../../__mocks__/engine_logic.mock'; | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { EuiFieldSearch } from '@elastic/eui'; | ||
|
||
import { AnalyticsSearch } from './'; | ||
|
||
describe('AnalyticsSearch', () => { | ||
const { navigateToUrl } = mockKibanaValues; | ||
const preventDefault = jest.fn(); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const wrapper = shallow(<AnalyticsSearch />); | ||
const setSearchValue = (value: string) => | ||
wrapper.find(EuiFieldSearch).simulate('change', { target: { value } }); | ||
|
||
it('renders', () => { | ||
expect(wrapper.find(EuiFieldSearch)).toHaveLength(1); | ||
}); | ||
|
||
it('updates searchValue state on input change', () => { | ||
expect(wrapper.find(EuiFieldSearch).prop('value')).toEqual(''); | ||
|
||
setSearchValue('some-query'); | ||
expect(wrapper.find(EuiFieldSearch).prop('value')).toEqual('some-query'); | ||
}); | ||
|
||
it('sends the user to the query detail page on search', () => { | ||
wrapper.find('form').simulate('submit', { preventDefault }); | ||
|
||
expect(preventDefault).toHaveBeenCalled(); | ||
expect(navigateToUrl).toHaveBeenCalledWith( | ||
'/engines/some-engine/analytics/query_detail/some-query' | ||
); | ||
}); | ||
|
||
it('falls back to showing the "" query if searchValue is empty', () => { | ||
setSearchValue(''); | ||
wrapper.find('form').simulate('submit', { preventDefault }); | ||
|
||
expect(navigateToUrl).toHaveBeenCalledWith( | ||
'/engines/some-engine/analytics/query_detail/%22%22' // "" gets encoded | ||
); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
...earch/public/applications/app_search/components/analytics/components/analytics_search.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { useValues } from 'kea'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiFieldSearch, EuiButton, EuiSpacer } from '@elastic/eui'; | ||
|
||
import { KibanaLogic } from '../../../../shared/kibana'; | ||
import { ENGINE_ANALYTICS_QUERY_DETAIL_PATH } from '../../../routes'; | ||
import { generateEnginePath } from '../../engine'; | ||
|
||
export const AnalyticsSearch: React.FC = () => { | ||
const [searchValue, setSearchValue] = useState(''); | ||
|
||
const { navigateToUrl } = useValues(KibanaLogic); | ||
const viewQueryDetails = (e: React.SyntheticEvent) => { | ||
e.preventDefault(); | ||
const query = searchValue || '""'; | ||
navigateToUrl(generateEnginePath(ENGINE_ANALYTICS_QUERY_DETAIL_PATH, { query })); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={viewQueryDetails}> | ||
<EuiFlexGroup alignItems="center" gutterSize="m" responsive={false}> | ||
<EuiFlexItem> | ||
<EuiFieldSearch | ||
value={searchValue} | ||
onChange={(e) => setSearchValue(e.target.value)} | ||
placeholder={i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.queryDetailSearchPlaceholder', | ||
{ defaultMessage: 'Go to search term' } | ||
)} | ||
fullWidth | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton type="submit"> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.queryDetailSearchButtonLabel', | ||
{ defaultMessage: 'View details' } | ||
)} | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer /> | ||
</form> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
...public/applications/app_search/components/analytics/components/analytics_section.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import { AnalyticsSection } from './'; | ||
|
||
describe('AnalyticsSection', () => { | ||
it('renders', () => { | ||
const wrapper = shallow( | ||
<AnalyticsSection title="Lorem ipsum" subtitle="Dolor sit amet."> | ||
<div data-test-subj="HelloWorld">Test</div> | ||
</AnalyticsSection> | ||
); | ||
|
||
expect(wrapper.find('h2').text()).toEqual('Lorem ipsum'); | ||
expect(wrapper.find('p').text()).toEqual('Dolor sit amet.'); | ||
expect(wrapper.find('[data-test-subj="HelloWorld"]')).toHaveLength(1); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
...arch/public/applications/app_search/components/analytics/components/analytics_section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiPageContentBody, EuiTitle, EuiText, EuiSpacer } from '@elastic/eui'; | ||
|
||
interface Props { | ||
title: string; | ||
subtitle: string; | ||
} | ||
export const AnalyticsSection: React.FC<Props> = ({ title, subtitle, children }) => ( | ||
<section> | ||
<header> | ||
<EuiTitle size="m"> | ||
<h2>{title}</h2> | ||
</EuiTitle> | ||
<EuiText size="s" color="subdued"> | ||
<p>{subtitle}</p> | ||
</EuiText> | ||
</header> | ||
<EuiSpacer size="m" /> | ||
<EuiPageContentBody>{children}</EuiPageContentBody> | ||
</section> | ||
); |
Oops, something went wrong.