-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover][Embeddable] Pass embeddable filters to Surrounding Docs page #197190
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
Changes from all commits
e1f3a65
f546afb
80cf831
bc3d4bf
ae0cc56
b42e10b
4615e64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ import { | |
| SORT_DEFAULT_ORDER_SETTING, | ||
| isLegacyTableEnabled, | ||
| } from '@kbn/discover-utils'; | ||
| import { Filter } from '@kbn/es-query'; | ||
| import { | ||
| FetchContext, | ||
| useBatchedOptionalPublishingSubjects, | ||
|
|
@@ -27,7 +26,6 @@ import { SortOrder } from '@kbn/saved-search-plugin/public'; | |
| import { SearchResponseIncompleteWarning } from '@kbn/search-response-warnings/src/types'; | ||
| import { DataGridDensity, DataLoadingState, useColumns } from '@kbn/unified-data-table'; | ||
| import { DocViewFilterFn } from '@kbn/unified-doc-viewer/types'; | ||
|
|
||
| import { DiscoverGridSettings } from '@kbn/saved-search-plugin/common'; | ||
| import useObservable from 'react-use/lib/useObservable'; | ||
| import { DiscoverDocTableEmbeddable } from '../../components/doc_table/create_doc_table_embeddable'; | ||
|
|
@@ -69,8 +67,8 @@ export function SearchEmbeddableGridComponent({ | |
| savedSearch, | ||
| savedSearchId, | ||
| interceptedWarnings, | ||
| query, | ||
| filters, | ||
| apiQuery, | ||
| apiFilters, | ||
| fetchContext, | ||
| rows, | ||
| totalHitCount, | ||
|
|
@@ -90,6 +88,12 @@ export function SearchEmbeddableGridComponent({ | |
| stateManager.grid | ||
| ); | ||
|
|
||
| // `api.query$` and `api.filters$` are the initial values from the saved search SO (as of now) | ||
| // `fetchContext.query` and `fetchContext.filters` are Dashboard's query and filters | ||
|
|
||
| const savedSearchQuery = apiQuery; | ||
| const savedSearchFilters = apiFilters; | ||
|
|
||
| const [panelTitle, panelDescription, savedSearchTitle, savedSearchDescription] = | ||
| useBatchedOptionalPublishingSubjects( | ||
| api.panelTitle, | ||
|
|
@@ -137,7 +141,10 @@ export function SearchEmbeddableGridComponent({ | |
| settings: grid, | ||
| }); | ||
|
|
||
| const dataSource = useMemo(() => createDataSource({ dataView, query }), [dataView, query]); | ||
| const dataSource = useMemo( | ||
| () => createDataSource({ dataView, query: savedSearchQuery }), | ||
| [dataView, savedSearchQuery] | ||
| ); | ||
| const timeRange = useMemo( | ||
| () => (fetchContext ? getTimeRangeFromFetchContext(fetchContext) : undefined), | ||
| [fetchContext] | ||
|
|
@@ -146,8 +153,8 @@ export function SearchEmbeddableGridComponent({ | |
| const cellActionsMetadata = useAdditionalCellActions({ | ||
| dataSource, | ||
| dataView, | ||
| query, | ||
| filters, | ||
| query: savedSearchQuery, | ||
| filters: savedSearchFilters, | ||
|
Comment on lines
+156
to
+157
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I kept this as it was before. We might want to consider including the current Dashboard filters for cell actions too.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it's hard to say which behaviour is best for this. It's something worth discussing at least. |
||
| timeRange, | ||
| }); | ||
|
|
||
|
|
@@ -229,7 +236,7 @@ export function SearchEmbeddableGridComponent({ | |
| <DiscoverDocTableEmbeddableMemoized | ||
| {...sharedProps} | ||
| {...onStateEditedProps} | ||
| filters={savedSearch.searchSource.getField('filter') as Filter[]} | ||
| filters={savedSearchFilters} | ||
| isEsqlMode={isEsql} | ||
| isLoading={Boolean(loading)} | ||
| sharedItemTitle={panelTitle || savedSearchTitle} | ||
|
|
@@ -258,7 +265,8 @@ export function SearchEmbeddableGridComponent({ | |
| isPlainRecord={isEsql} | ||
| loadingState={Boolean(loading) ? DataLoadingState.loading : DataLoadingState.loaded} | ||
| maxAllowedSampleSize={getMaxAllowedSampleSize(discoverServices.uiSettings)} | ||
| query={savedSearch.searchSource.getField('query')} | ||
| query={savedSearchQuery} | ||
| filters={savedSearchFilters} | ||
| savedSearchId={savedSearchId} | ||
| searchTitle={panelTitle || savedSearchTitle} | ||
| services={discoverServices} | ||
|
|
||
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.
If
api.query$andapi.filters$already contain the saved search values, why are we switching tosearchSourcebelow?Uh oh!
There was an error while loading. Please reload this page.
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.
It seemed less verbose to me. Okay, I am going to keep the variables but reassign them to api values 4615e64