-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[App Search] Added a History tab to the Automated Curation detail view #115090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
23 changes: 23 additions & 0 deletions
23
...rise_search/public/applications/app_search/components/curations/curation/history.test.tsx
This file contains hidden or 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,23 @@ | ||
| /* | ||
| * 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 from 'react'; | ||
|
|
||
| import { shallow } from 'enzyme'; | ||
|
|
||
| import { EntSearchLogStream } from '../../../../shared/log_stream'; | ||
|
|
||
| import { History } from './history'; | ||
|
|
||
| describe('History', () => { | ||
| it('renders', () => { | ||
| const wrapper = shallow(<History engineName="foo" query="some text" />); | ||
| expect(wrapper.find(EntSearchLogStream).prop('query')).toEqual( | ||
| 'appsearch.search_relevance_suggestions.query: some text and event.kind: event and event.dataset: search-relevance-suggestions and appsearch.search_relevance_suggestions.engine: foo and event.action: curation_suggestion' | ||
| ); | ||
| }); | ||
| }); |
57 changes: 57 additions & 0 deletions
57
...nterprise_search/public/applications/app_search/components/curations/curation/history.tsx
This file contains hidden or 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,57 @@ | ||
| /* | ||
| * 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 from 'react'; | ||
|
|
||
| import { i18n } from '@kbn/i18n'; | ||
|
|
||
| import { EntSearchLogStream } from '../../../../shared/log_stream'; | ||
| import { DataPanel } from '../../data_panel'; | ||
|
|
||
| interface Props { | ||
| query: string; | ||
| engineName: string; | ||
| } | ||
|
|
||
| export const History: React.FC<Props> = ({ query, engineName }) => { | ||
| const filters = [ | ||
| `appsearch.search_relevance_suggestions.query: ${query}`, | ||
| 'event.kind: event', | ||
| 'event.dataset: search-relevance-suggestions', | ||
| `appsearch.search_relevance_suggestions.engine: ${engineName}`, | ||
| 'event.action: curation_suggestion', | ||
| ]; | ||
|
|
||
| return ( | ||
| <DataPanel | ||
| iconType="tableDensityNormal" | ||
| title={ | ||
| <h2> | ||
| {i18n.translate( | ||
| 'xpack.enterpriseSearch.appSearch.engine.curation.detail.historyTableTitle', | ||
| { | ||
| defaultMessage: 'Automated curation changes', | ||
| } | ||
| )} | ||
| </h2> | ||
| } | ||
| subtitle={i18n.translate( | ||
| 'xpack.enterpriseSearch.appSearch.engine.curation.detail.historyTableDescription', | ||
| { | ||
| defaultMessage: 'A detailed log of recent changes to your automated curation.', | ||
| } | ||
| )} | ||
| hasBorder | ||
| > | ||
| <EntSearchLogStream | ||
| hoursAgo={720} | ||
| query={filters.join(' and ')} | ||
| columns={[{ type: 'timestamp' }, { type: 'message' }]} | ||
| /> | ||
| </DataPanel> | ||
| ); | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I'm writing jest tests for React components, I try to avoid using events like clicks to modify the local state. In the
manual_curation.test.tsxfile you can see an example of how I'd write this kind of testkibana/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/manual_curation.test.tsx
Lines 65 to 101 in ad6340a
You don't have to change it here or how you do it in the future but wanted to present how I've been handling it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think it's a little different. You are using Kea, I'm using local state. Using local state, I think I have to use a click to modify the local state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have a way to mock useState, similar to how we mock useValues/useActions. I'll post in Slack