diff --git a/src/plugins/discover/public/embeddable/__mocks__/get_mocked_api.ts b/src/plugins/discover/public/embeddable/__mocks__/get_mocked_api.ts index fdc9cba8a5bfa..592cf3d80faef 100644 --- a/src/plugins/discover/public/embeddable/__mocks__/get_mocked_api.ts +++ b/src/plugins/discover/public/embeddable/__mocks__/get_mocked_api.ts @@ -8,7 +8,7 @@ */ import { BehaviorSubject } from 'rxjs'; - +import type { Adapters } from '@kbn/inspector-plugin/common'; import { SearchSource } from '@kbn/data-plugin/common'; import type { DataView } from '@kbn/data-views-plugin/common'; import { DataTableRecord } from '@kbn/discover-utils'; @@ -58,6 +58,7 @@ export const getMockedSearchApi = ({ rows: new BehaviorSubject([]), totalHitCount: new BehaviorSubject(0), columnsMeta: new BehaviorSubject | undefined>(undefined), + inspectorAdapters: new BehaviorSubject({}), }, }; }; diff --git a/src/plugins/discover/public/embeddable/get_search_embeddable_factory.tsx b/src/plugins/discover/public/embeddable/get_search_embeddable_factory.tsx index 4117a36a4e048..c1b5cf9f7695f 100644 --- a/src/plugins/discover/public/embeddable/get_search_embeddable_factory.tsx +++ b/src/plugins/discover/public/embeddable/get_search_embeddable_factory.tsx @@ -196,6 +196,7 @@ export const getSearchEmbeddableFactory = ({ savedObjectId: savedObjectId$.getValue(), discoverServices, }), + getInspectorAdapters: () => searchEmbeddable.stateManager.inspectorAdapters.getValue(), }, { ...titleComparators, diff --git a/src/plugins/discover/public/embeddable/initialize_fetch.test.ts b/src/plugins/discover/public/embeddable/initialize_fetch.test.ts index 6fa66115da6e0..061a934dfa2b5 100644 --- a/src/plugins/discover/public/embeddable/initialize_fetch.test.ts +++ b/src/plugins/discover/public/embeddable/initialize_fetch.test.ts @@ -69,6 +69,7 @@ describe('initialize fetch', () => { ].map((hit) => buildDataTableRecord(hit, dataViewMock)) ); expect(stateManager.totalHitCount.getValue()).toEqual(2); + expect(stateManager.inspectorAdapters.getValue().requests).toBeDefined(); }); it('should catch and emit error', async () => { diff --git a/src/plugins/discover/public/embeddable/initialize_fetch.ts b/src/plugins/discover/public/embeddable/initialize_fetch.ts index b502ea94bd371..9ef2a3c167272 100644 --- a/src/plugins/discover/public/embeddable/initialize_fetch.ts +++ b/src/plugins/discover/public/embeddable/initialize_fetch.ts @@ -90,7 +90,7 @@ export function initializeFetch({ stateManager: SearchEmbeddableStateManager; discoverServices: DiscoverServices; }) { - const requestAdapter = new RequestAdapter(); + const inspectorAdapters = { requests: new RequestAdapter() }; let abortController: AbortController | undefined; const fetchSubscription = combineLatest([fetch$(api), api.savedSearch$, api.dataViews]) @@ -127,7 +127,7 @@ export function initializeFetch({ const searchSourceQuery = savedSearch.searchSource.getField('query'); // Log request to inspector - requestAdapter.reset(); + inspectorAdapters.requests.reset(); try { api.dataLoading.next(true); @@ -156,7 +156,7 @@ export function initializeFetch({ filters: fetchContext.filters, dataView, abortSignal: currentAbortController.signal, - inspectorAdapters: discoverServices.inspector, + inspectorAdapters, data: discoverServices.data, expressions: discoverServices.expressions, profilesManager: discoverServices.profilesManager, @@ -181,9 +181,9 @@ export function initializeFetch({ abortSignal: currentAbortController.signal, sessionId: searchSessionId, inspector: { - adapter: requestAdapter, - title: i18n.translate('discover.embeddable.inspectorRequestDataTitle', { - defaultMessage: 'Data', + adapter: inspectorAdapters.requests, + title: i18n.translate('discover.embeddable.inspectorTableRequestTitle', { + defaultMessage: 'Table', }), description: i18n.translate('discover.embeddable.inspectorRequestDescription', { defaultMessage: @@ -195,7 +195,7 @@ export function initializeFetch({ }) ); const interceptedWarnings: SearchResponseWarning[] = []; - discoverServices.data.search.showWarnings(requestAdapter, (warning) => { + discoverServices.data.search.showWarnings(inspectorAdapters.requests, (warning) => { interceptedWarnings.push(warning); return true; // suppress the default behaviour }); @@ -225,6 +225,8 @@ export function initializeFetch({ stateManager.rows.next(next.rows ?? []); stateManager.totalHitCount.next(next.hitCount); + stateManager.inspectorAdapters.next(inspectorAdapters); + api.fetchWarnings$.next(next.warnings ?? []); api.fetchContext$.next(next.fetchContext); if (Object.hasOwn(next, 'columnsMeta')) { diff --git a/src/plugins/discover/public/embeddable/initialize_search_embeddable_api.tsx b/src/plugins/discover/public/embeddable/initialize_search_embeddable_api.tsx index 7b6f20927d347..f5ff51930096f 100644 --- a/src/plugins/discover/public/embeddable/initialize_search_embeddable_api.tsx +++ b/src/plugins/discover/public/embeddable/initialize_search_embeddable_api.tsx @@ -10,7 +10,7 @@ import { pick } from 'lodash'; import deepEqual from 'react-fast-compare'; import { BehaviorSubject, combineLatest, map, Observable, skip } from 'rxjs'; - +import type { Adapters } from '@kbn/inspector-plugin/common'; import { ISearchSource, SerializedSearchSourceFields } from '@kbn/data-plugin/common'; import { DataView } from '@kbn/data-views-plugin/common'; import { DataTableRecord } from '@kbn/discover-utils/types'; @@ -116,6 +116,7 @@ export const initializeSearchEmbeddableApi = async ( const rows$ = new BehaviorSubject([]); const columnsMeta$ = new BehaviorSubject(undefined); const totalHitCount$ = new BehaviorSubject(undefined); + const inspectorAdapters$ = new BehaviorSubject({}); /** * The state manager is used to modify the state of the saved search - this should never be @@ -134,6 +135,7 @@ export const initializeSearchEmbeddableApi = async ( totalHitCount: totalHitCount$, viewMode: savedSearchViewMode$, density: density$, + inspectorAdapters: inspectorAdapters$, }; /** The saved search should be the source of truth for all state */ diff --git a/src/plugins/discover/public/embeddable/types.ts b/src/plugins/discover/public/embeddable/types.ts index 64cf5a390da3a..94d0b10cc3f64 100644 --- a/src/plugins/discover/public/embeddable/types.ts +++ b/src/plugins/discover/public/embeddable/types.ts @@ -9,6 +9,7 @@ import { DataTableRecord } from '@kbn/discover-utils/types'; import type { DefaultEmbeddableApi } from '@kbn/embeddable-plugin/public'; +import { HasInspectorAdapters } from '@kbn/inspector-plugin/public'; import { EmbeddableApiContext, HasEditCapabilities, @@ -47,6 +48,7 @@ export type SearchEmbeddableState = Pick< rows: DataTableRecord[]; columnsMeta: DataTableColumnsMeta | undefined; totalHitCount: number | undefined; + inspectorAdapters: Record; }; export type SearchEmbeddableStateManager = { @@ -55,7 +57,7 @@ export type SearchEmbeddableStateManager = { export type SearchEmbeddableSerializedAttributes = Omit< SearchEmbeddableState, - 'rows' | 'columnsMeta' | 'totalHitCount' | 'searchSource' + 'rows' | 'columnsMeta' | 'totalHitCount' | 'searchSource' | 'inspectorAdapters' > & Pick; @@ -98,6 +100,7 @@ export type SearchEmbeddableApi = DefaultEmbeddableApi< PublishesWritableUnifiedSearch & HasInPlaceLibraryTransforms & HasTimeRange & + HasInspectorAdapters & Partial; export interface PublishesSavedSearch { diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index cd243a3351aae..c94eefe9c9034 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -2600,7 +2600,6 @@ "discover.documentsAriaLabel": "Documents", "discover.docViews.logsOverview.title": "Aperçu du log", "discover.dropZoneTableLabel": "Abandonner la zone pour ajouter un champ en tant que colonne dans la table", - "discover.embeddable.inspectorRequestDataTitle": "Données", "discover.embeddable.inspectorRequestDescription": "Cette requête interroge Elasticsearch afin de récupérer les données pour la recherche.", "discover.embeddable.search.dataViewError": "Vue de données {indexPatternId} manquante", "discover.embeddable.search.displayName": "rechercher", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index f8291d5aa5267..b80f5e6427079 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2599,7 +2599,6 @@ "discover.documentsAriaLabel": "ドキュメント", "discover.docViews.logsOverview.title": "ログ概要", "discover.dropZoneTableLabel": "フィールドを列として表に追加するには、ゾーンをドロップします", - "discover.embeddable.inspectorRequestDataTitle": "データ", "discover.embeddable.inspectorRequestDescription": "このリクエストはElasticsearchにクエリーをかけ、検索データを取得します。", "discover.embeddable.search.dataViewError": "データビュー{indexPatternId}が見つかりません", "discover.embeddable.search.displayName": "検索", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 0d204aad72949..369522e39cd44 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2590,7 +2590,6 @@ "discover.documentsAriaLabel": "文档", "discover.docViews.logsOverview.title": "日志概览", "discover.dropZoneTableLabel": "放置区域以将字段作为列添加到表中", - "discover.embeddable.inspectorRequestDataTitle": "数据", "discover.embeddable.inspectorRequestDescription": "此请求将查询 Elasticsearch 以获取搜索的数据。", "discover.embeddable.search.dataViewError": "缺少数据视图 {indexPatternId}", "discover.embeddable.search.displayName": "搜索",