-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add new AnalyticsSection component * Update views that use AnalyticsSection * [Setup] Update types + final API logic data - export query types so that new table components can use them - reorganize type keys by their (upcoming) table column order, remove unused tags from document obj * [Setup] Migrate InlineTagsList component - used for tags columns in all tables * Create basic AnalyticsTable component - there's a lot of logic separated out into constants.tsx right now, I promise it will make more sense when the one-off tables get added * Update all views that use AnalyticsTable + add 'view all' button links to overview tables * Add RecentQueriesTable component - Why is the API for this specific table so different? who knows, but it do be that way * Update views with RecentQueryTable * Add QueryClicksTable component to QueryDetails view * Create AnalyticsSearch bar for queries subpages * [Polish] Add some space to the bottom of analytics pages * [Design feedback] Tweak header + search form layout - Have analytics filter form be on its own row separate from page title - Change AnalyticsSearch to stretch to full width + add placeholder text + match header gutter + remain one line on mobile * [PR feedback] Type clarification * [PR feedback] Clear mocks * [PR suggestion] File rename constants.tsx -> shared_columns.tsx Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
3e2c484
commit 15c5b00
Showing
35 changed files
with
1,114 additions
and
47 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.