mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[Discover][Embeddable] Pass embeddable filters to Surrounding Docs page (#197190)](https://github.com/elastic/kibana/pull/197190) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2024-10-24T10:16:21Z","message":"[Discover][Embeddable] Pass embeddable filters to Surrounding Docs page (#197190)\n\n## Summary\r\n\r\nThis PR makes sure to pass `filters` to DocViewer from the search panel\r\non Dashboard. And DocViewer will pass `filters` over to Surrounding Docs\r\npage.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"1c3705ba5b5aa60ea451a7d0ff7f95f2d21a1b80","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:DataDiscovery","v8.16.0","backport:version","v8.17.0"],"title":"[Discover][Embeddable] Pass embeddable filters to Surrounding Docs page","number":197190,"url":"https://github.com/elastic/kibana/pull/197190","mergeCommit":{"message":"[Discover][Embeddable] Pass embeddable filters to Surrounding Docs page (#197190)\n\n## Summary\r\n\r\nThis PR makes sure to pass `filters` to DocViewer from the search panel\r\non Dashboard. And DocViewer will pass `filters` over to Surrounding Docs\r\npage.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"1c3705ba5b5aa60ea451a7d0ff7f95f2d21a1b80"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197190","number":197190,"mergeCommit":{"message":"[Discover][Embeddable] Pass embeddable filters to Surrounding Docs page (#197190)\n\n## Summary\r\n\r\nThis PR makes sure to pass `filters` to DocViewer from the search panel\r\non Dashboard. And DocViewer will pass `filters` over to Surrounding Docs\r\npage.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"1c3705ba5b5aa60ea451a7d0ff7f95f2d21a1b80"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
This commit is contained in:
parent
407d794861
commit
bde9a7a280
3 changed files with 26 additions and 11 deletions
|
@ -9,7 +9,7 @@
|
|||
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import type { DataTableRecord } from '@kbn/discover-utils/types';
|
||||
import { AggregateQuery, Query } from '@kbn/es-query';
|
||||
import type { AggregateQuery, Query, Filter } from '@kbn/es-query';
|
||||
import type { SearchResponseWarning } from '@kbn/search-response-warnings';
|
||||
import { MAX_DOC_FIELDS_DISPLAYED, SHOW_MULTIFIELDS } from '@kbn/discover-utils';
|
||||
import {
|
||||
|
@ -30,7 +30,8 @@ import { useProfileAccessor } from '../../context_awareness';
|
|||
interface DiscoverGridEmbeddableProps extends Omit<UnifiedDataTableProps, 'sampleSizeState'> {
|
||||
sampleSizeState: number; // a required prop
|
||||
totalHitCount?: number;
|
||||
query?: AggregateQuery | Query;
|
||||
query: AggregateQuery | Query | undefined;
|
||||
filters: Filter[] | undefined;
|
||||
interceptedWarnings?: SearchResponseWarning[];
|
||||
onAddColumn: (column: string) => void;
|
||||
onRemoveColumn: (column: string) => void;
|
||||
|
@ -65,6 +66,7 @@ export function DiscoverGridEmbeddable(props: DiscoverGridEmbeddableProps) {
|
|||
onClose={() => setExpandedDoc(undefined)}
|
||||
setExpandedDoc={setExpandedDoc}
|
||||
query={props.query}
|
||||
filters={props.filters}
|
||||
/>
|
||||
),
|
||||
[
|
||||
|
@ -73,6 +75,7 @@ export function DiscoverGridEmbeddable(props: DiscoverGridEmbeddableProps) {
|
|||
props.onFilter,
|
||||
props.onRemoveColumn,
|
||||
props.query,
|
||||
props.filters,
|
||||
props.savedSearchId,
|
||||
]
|
||||
);
|
||||
|
|
|
@ -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,
|
||||
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}
|
||||
|
|
|
@ -104,6 +104,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
|
||||
it('navigates to context view from embeddable', async () => {
|
||||
await common.navigateToApp('discover');
|
||||
await header.waitUntilLoadingHasFinished();
|
||||
await filterBar.addFilter({ field: 'extension.raw', operation: 'is', value: 'jpg' });
|
||||
await header.waitUntilLoadingHasFinished();
|
||||
await discover.saveSearch('my search');
|
||||
await header.waitUntilLoadingHasFinished();
|
||||
|
||||
|
@ -134,6 +137,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
log.debug('document table length', nrOfDocs);
|
||||
return nrOfDocs === 6;
|
||||
});
|
||||
await filterBar.hasFilter('extension.raw', 'jpg', false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue