From d4164abc6639880ec9f667b10af06e5f22ce81e5 Mon Sep 17 00:00:00 2001 From: nreese Date: Fri, 1 Sep 2023 12:24:39 -0600 Subject: [PATCH 01/43] extract incomplete warning and handle in toasts --- packages/kbn-es-types/index.ts | 1 + packages/kbn-es-types/src/index.ts | 3 +- packages/kbn-es-types/src/search.ts | 9 ++ .../incomplete_results_modal.tsx | 113 ++++++++++++++++++ .../public/incomplete_results_modal/index.tsx | 21 ++++ .../open_incomplete_results_modal_button.tsx | 76 ++++++++++++ .../public/search/fetch/extract_warnings.ts | 69 ++++------- .../public/search/fetch/handle_warnings.tsx | 68 ++++------- src/plugins/data/public/search/types.ts | 54 +++------ 9 files changed, 284 insertions(+), 130 deletions(-) create mode 100644 src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx create mode 100644 src/plugins/data/public/incomplete_results_modal/index.tsx create mode 100644 src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx diff --git a/packages/kbn-es-types/index.ts b/packages/kbn-es-types/index.ts index e97df4d4eaa11d..cd2d0a5f2618e0 100644 --- a/packages/kbn-es-types/index.ts +++ b/packages/kbn-es-types/index.ts @@ -18,4 +18,5 @@ export type { AggregationResultOfMap, ESFilter, MaybeReadonlyArray, + ClusterDetails, } from './src'; diff --git a/packages/kbn-es-types/src/index.ts b/packages/kbn-es-types/src/index.ts index a18d6b39410f83..f73b21249dcb3a 100644 --- a/packages/kbn-es-types/src/index.ts +++ b/packages/kbn-es-types/src/index.ts @@ -11,6 +11,7 @@ import { AggregateOf as AggregationResultOf, AggregateOfMap as AggregationResultOfMap, SearchHit, + ClusterDetails, } from './search'; export type ESFilter = estypes.QueryDslQueryContainer; @@ -34,4 +35,4 @@ export type ESSearchResponse< TOptions extends { restTotalHitsAsInt: boolean } = { restTotalHitsAsInt: false } > = InferSearchResponseOf; -export type { InferSearchResponseOf, AggregationResultOf, AggregationResultOfMap, SearchHit }; +export type { InferSearchResponseOf, AggregationResultOf, AggregationResultOfMap, SearchHit, ClusterDetails }; diff --git a/packages/kbn-es-types/src/search.ts b/packages/kbn-es-types/src/search.ts index 13ebc02b65aa6d..4788f9821bab1f 100644 --- a/packages/kbn-es-types/src/search.ts +++ b/packages/kbn-es-types/src/search.ts @@ -644,3 +644,12 @@ export type InferSearchResponseOf< >; }; }; + +export type ClusterDetails = { + status: 'running' | 'successful' | 'partial' | 'skipped' | 'failed'; + indices: string; + took?: number; + timed_out: boolean; + _shards?: estypes.ShardStatistics; + failures?: estypes.ShardFailure[]; +} diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx new file mode 100644 index 00000000000000..15e1b06cf22f9a --- /dev/null +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -0,0 +1,113 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n-react'; +import { i18n } from '@kbn/i18n'; +import { + EuiCodeBlock, + EuiTabbedContent, + EuiCopy, + EuiButton, + EuiModalBody, + EuiModalHeader, + EuiModalHeaderTitle, + EuiModalFooter, + EuiButtonEmpty, + EuiCallOut, +} from '@elastic/eui'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { SearchRequest } from '..'; + +export interface Props { + onClose: () => void; + request: SearchRequest; + response: estypes.SearchResponse; + warning: SearchResponseIncompleteWarning; +} + +export function IncompleteResultsModal({ request, response, warning, onClose }: Props) { + const requestJSON = JSON.stringify(request, null, 2); + const responseJSON = JSON.stringify(response, null, 2); + + const tabs = [ + { + id: 'table', + name: i18n.translate( + 'data.search.searchSource.fetch.incompleteResultsModal.tabHeaderClusterDetails', + { + defaultMessage: 'Cluster details', + description: 'Name of the tab displaying cluster details', + } + ), + content:
cluster details
, + ['data-test-subj']: 'showClusterDetailsButton', + }, + { + id: 'json-request', + name: i18n.translate('data.search.searchSource.fetch.incompleteResultsModal.tabHeaderRequest', { + defaultMessage: 'Request', + description: 'Name of the tab displaying the JSON request', + }), + content: ( + + {requestJSON} + + ), + ['data-test-subj']: 'showRequestButton', + }, + { + id: 'json-response', + name: i18n.translate('data.search.searchSource.fetch.incompleteResultsModal.tabHeaderResponse', { + defaultMessage: 'Response', + description: 'Name of the tab displaying the JSON response', + }), + content: ( + + {responseJSON} + + ), + ['data-test-subj']: 'showResponseButton', + }, + ]; + + return ( + + + + + + + + + + + + {(copy) => ( + + + + )} + + onClose()} fill data-test-subj="closeincompleteResultsModal"> + + + + + ); +} diff --git a/src/plugins/data/public/incomplete_results_modal/index.tsx b/src/plugins/data/public/incomplete_results_modal/index.tsx new file mode 100644 index 00000000000000..6b38a60bff466b --- /dev/null +++ b/src/plugins/data/public/incomplete_results_modal/index.tsx @@ -0,0 +1,21 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import type { OpenIncompleteResultsModalButtonProps } from './open_incomplete_results_modal_button'; + +const Fallback = () =>
; + +const LazyOpenModalButton = React.lazy( + () => import('./open_incomplete_results_modal_button') +); +export const OpenIncompleteResultsModalButton = (props: OpenIncompleteResultsModalButtonProps) => ( + }> + + +); diff --git a/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx b/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx new file mode 100644 index 00000000000000..640bbed95bc504 --- /dev/null +++ b/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx @@ -0,0 +1,76 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React, { useCallback } from 'react'; +import { FormattedMessage } from '@kbn/i18n-react'; +import { EuiLink, EuiButton, EuiButtonProps } from '@elastic/eui'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { ThemeServiceStart } from '@kbn/core/public'; +import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { getOverlays } from '../services'; +import type { SearchRequest } from '..'; +import { IncompleteResultsModal } from './incomplete_results_modal'; + +// @internal +export interface OpenIncompleteResultsModalButtonProps { + theme: ThemeServiceStart; + warning: SearchResponseIncompleteWarning; + size?: EuiButtonProps['size']; + color?: EuiButtonProps['color']; + getRequestMeta: () => { + request: SearchRequest; + response: estypes.SearchResponse; + }; + isButtonEmpty?: boolean; +} + +// Needed for React.lazy +// eslint-disable-next-line import/no-default-export +export default function OpenIncompleteResultsModalButton({ + getRequestMeta, + theme, + warning, + size = 's', + color = 'warning', + isButtonEmpty = false, +}: OpenIncompleteResultsModalButtonProps) { + const onClick = useCallback(() => { + const { request, response } = getRequestMeta(); + const modal = getOverlays().openModal( + toMountPoint( + modal.close()} + />, + { theme$: theme.theme$ } + ), + { + className: 'incompleteResultsModal', + } + ); + }, [getRequestMeta, theme.theme$, warning]); + + const Component = isButtonEmpty ? EuiLink : EuiButton; + + return ( + + + + ); +} diff --git a/src/plugins/data/public/search/fetch/extract_warnings.ts b/src/plugins/data/public/search/fetch/extract_warnings.ts index 7c574acba472c4..27052e833f2f16 100644 --- a/src/plugins/data/public/search/fetch/extract_warnings.ts +++ b/src/plugins/data/public/search/fetch/extract_warnings.ts @@ -8,6 +8,7 @@ import { estypes } from '@elastic/elasticsearch'; import { i18n } from '@kbn/i18n'; +import type { ClusterDetails } from '@kbn/es-types'; import { SearchResponseWarning } from '../types'; /** @@ -16,54 +17,32 @@ import { SearchResponseWarning } from '../types'; export function extractWarnings(rawResponse: estypes.SearchResponse): SearchResponseWarning[] { const warnings: SearchResponseWarning[] = []; - if (rawResponse.timed_out === true) { + let isPartial = false; + let clusters: Record = {}; + if (rawResponse._clusters) { + isPartial = Object.values(rawResponse._clusters.details).some(clusterDetails => clusterDetails.status !== 'successful'); + clusters = rawResponse._clusters.details; + } else if (rawResponse._shards && (rawResponse.timed_out || rawResponse._shards.failed > 0)) { + // local cluster only + isPartial = true; + clusters['(local)'] = { + status: 'partial', + took: rawResponse.took, + timed_out: rawResponse.timed_out, + _shards: rawResponse._shards, + failures: rawResponse._shards.failures, + }; + } + if (isPartial) { warnings.push({ - type: 'timed_out', - message: i18n.translate('data.search.searchSource.fetch.requestTimedOutNotificationMessage', { - defaultMessage: 'Data might be incomplete because your request timed out', - }), - reason: undefined, // exists so that callers do not have to cast when working with shard warnings. + type: 'incomplete', + message: i18n.translate( + 'data.search.searchSource.fetch.incompleteResultsMessage', + { defaultMessage: 'The data might be incomplete or wrong.' } + ), + clusters }); } - if (rawResponse._shards && rawResponse._shards.failed) { - const message = i18n.translate( - 'data.search.searchSource.fetch.shardsFailedNotificationMessage', - { - defaultMessage: '{shardsFailed} of {shardsTotal} shards failed', - values: { - shardsFailed: rawResponse._shards.failed, - shardsTotal: rawResponse._shards.total, - }, - } - ); - const text = i18n.translate( - 'data.search.searchSource.fetch.shardsFailedNotificationDescription', - { defaultMessage: 'The data might be incomplete or wrong.' } - ); - - if (rawResponse._shards.failures) { - rawResponse._shards.failures?.forEach((f) => { - warnings.push({ - type: 'shard_failure', - message, - text, - reason: { - type: f.reason.type, - reason: f.reason.reason, - }, - }); - }); - } else { - // unknown type and reason - warnings.push({ - type: 'shard_failure', - message, - text, - reason: { type: 'generic_shard_warning' }, - }); - } - } - return warnings; } diff --git a/src/plugins/data/public/search/fetch/handle_warnings.tsx b/src/plugins/data/public/search/fetch/handle_warnings.tsx index 3e1353ee2f9a73..6e8df9a821da0f 100644 --- a/src/plugins/data/public/search/fetch/handle_warnings.tsx +++ b/src/plugins/data/public/search/fetch/handle_warnings.tsx @@ -15,9 +15,9 @@ import React from 'react'; import type { MountPoint } from '@kbn/core/public'; import { SearchRequest } from '..'; import { getNotifications } from '../../services'; -import { ShardFailureOpenModalButton, ShardFailureRequest } from '../../shard_failure_modal'; +import { OpenIncompleteResultsModalButton } from '../../incomplete_results_modal'; import { - SearchResponseShardFailureWarning, + SearchResponseIncompleteWarning, SearchResponseWarning, WarningHandlerCallback, } from '../types'; @@ -42,14 +42,11 @@ const getDebouncedWarning = () => { }; }; -const debouncedWarningWithoutReason = getDebouncedWarning(); -const debouncedTimeoutWarning = getDebouncedWarning(); -const debouncedWarning = getDebouncedWarning(); +const debouncedIncompleteWarning = getDebouncedWarning(); /** * @internal - * All warnings are expected to come from the same response. Therefore all "text" properties, which contain the - * response, will be the same. + * All warnings are expected to come from the same response. */ export function handleWarnings({ request, @@ -78,47 +75,30 @@ export function handleWarnings({ return; } - // timeout notification - const [timeout] = internal.filter((w) => w.type === 'timed_out'); - if (timeout) { - debouncedTimeoutWarning(sessionId + timeout.message, timeout.message); - } - - // shard warning failure notification - const shardFailures = internal.filter((w) => w.type === 'shard_failure'); - if (shardFailures.length === 0) { + // Incomplete data failure notification + const incompleteWarnings = internal.filter((w) => w.type === 'incomplete'); + if (incompleteWarnings.length === 0) { return; } - const [warning] = shardFailures as SearchResponseShardFailureWarning[]; - const title = warning.message; - - // if warning message contains text (warning response), show in ShardFailureOpenModalButton - if (warning.text) { - const text = toMountPoint( - <> - {warning.text} - - - ({ - request: request as ShardFailureRequest, - response, - })} - /> - - , + const [incompleteWarning] = incompleteWarnings as SearchResponseIncompleteWarning[]; + debouncedIncompleteWarning( + sessionId + incompleteWarning.type, + incompleteWarning.message, + toMountPoint( + + ({ + request, + response, + })} + warning={incompleteWarning} + /> + , { theme$: theme.theme$ } - ); - - debouncedWarning(sessionId + warning.text, title, text); - return; - } - - // timeout warning, or shard warning with no failure reason - debouncedWarningWithoutReason(sessionId + title, title); + ) + ); } /** diff --git a/src/plugins/data/public/search/types.ts b/src/plugins/data/public/search/types.ts index d1fde7bd4d7e60..bb490b80e59eb5 100644 --- a/src/plugins/data/public/search/types.ts +++ b/src/plugins/data/public/search/types.ts @@ -7,6 +7,7 @@ */ import { estypes } from '@elastic/elasticsearch'; +import type { ClusterDetails } from '@kbn/es-types'; import type { PackageInfo } from '@kbn/core/server'; import { DataViewsContract } from '@kbn/data-views-plugin/common'; import { RequestAdapter } from '@kbn/inspector-plugin/public'; @@ -96,54 +97,28 @@ export interface SearchServiceStartDependencies { } /** - * A warning object for a search response with internal ES timeouts + * A warning object for a search response with incomplete ES results + * ES returns incomplete results when: + * 1) Set timeout flag on search and the timeout expires on cluster + * 2) Some shard failures on a cluster + * 3) skipped remote(s) (skip_unavailable=true) + * a. all shards failed + * b. disconnected/not-connected * @public */ -export interface SearchResponseTimeoutWarning { +export interface SearchResponseIncompleteWarning { /** - * type: for sorting out timeout warnings + * type: for sorting out incomplete warnings */ - type: 'timed_out'; + type: 'incomplete'; /** * message: human-friendly message */ message: string; /** - * reason: not given for timeout. This exists so that callers do not have to cast when working with shard failure warnings. + * clusters: cluster details. */ - reason: undefined; -} - -/** - * A warning object for a search response with internal ES shard failures - * @public - */ -export interface SearchResponseShardFailureWarning { - /** - * type: for sorting out shard failure warnings - */ - type: 'shard_failure'; - /** - * message: human-friendly message - */ - message: string; - /** - * text: text to show in ShardFailureModal (optional) - */ - text?: string; - /** - * reason: ShardFailureReason from es client - */ - reason: { - /** - * type: failure code from Elasticsearch - */ - type: 'generic_shard_warning' | estypes.ShardFailure['reason']['type']; - /** - * reason: failure reason from Elasticsearch - */ - reason?: estypes.ShardFailure['reason']['reason']; - }; + clusters: Record; } /** @@ -151,8 +126,7 @@ export interface SearchResponseShardFailureWarning { * @public */ export type SearchResponseWarning = - | SearchResponseTimeoutWarning - | SearchResponseShardFailureWarning; + | SearchResponseIncompleteWarning; /** * A callback function which can intercept warnings when passed to {@link showWarnings}. Pass `true` from the From d93aedbd37a5f8bd5283e2772ec1b5c4b457fef8 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 1 Sep 2023 18:43:31 +0000 Subject: [PATCH 02/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- packages/kbn-es-types/src/index.ts | 8 ++++- packages/kbn-es-types/src/search.ts | 2 +- .../incomplete_results_modal.tsx | 35 +++++++++++++------ .../public/incomplete_results_modal/index.tsx | 4 +-- .../public/search/fetch/extract_warnings.ts | 13 +++---- .../public/search/fetch/handle_warnings.tsx | 2 +- src/plugins/data/public/search/types.ts | 3 +- 7 files changed, 42 insertions(+), 25 deletions(-) diff --git a/packages/kbn-es-types/src/index.ts b/packages/kbn-es-types/src/index.ts index f73b21249dcb3a..f22e43fc7e7051 100644 --- a/packages/kbn-es-types/src/index.ts +++ b/packages/kbn-es-types/src/index.ts @@ -35,4 +35,10 @@ export type ESSearchResponse< TOptions extends { restTotalHitsAsInt: boolean } = { restTotalHitsAsInt: false } > = InferSearchResponseOf; -export type { InferSearchResponseOf, AggregationResultOf, AggregationResultOfMap, SearchHit, ClusterDetails }; +export type { + InferSearchResponseOf, + AggregationResultOf, + AggregationResultOfMap, + SearchHit, + ClusterDetails, +}; diff --git a/packages/kbn-es-types/src/search.ts b/packages/kbn-es-types/src/search.ts index 4788f9821bab1f..502a7464e53517 100644 --- a/packages/kbn-es-types/src/search.ts +++ b/packages/kbn-es-types/src/search.ts @@ -645,7 +645,7 @@ export type InferSearchResponseOf< }; }; -export type ClusterDetails = { +export interface ClusterDetails { status: 'running' | 'successful' | 'partial' | 'skipped' | 'failed'; indices: string; took?: number; diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index 15e1b06cf22f9a..633b45c57c5b46 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -19,7 +19,6 @@ import { EuiModalHeaderTitle, EuiModalFooter, EuiButtonEmpty, - EuiCallOut, } from '@elastic/eui'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SearchRequest } from '..'; @@ -50,12 +49,19 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: }, { id: 'json-request', - name: i18n.translate('data.search.searchSource.fetch.incompleteResultsModal.tabHeaderRequest', { - defaultMessage: 'Request', - description: 'Name of the tab displaying the JSON request', - }), + name: i18n.translate( + 'data.search.searchSource.fetch.incompleteResultsModal.tabHeaderRequest', + { + defaultMessage: 'Request', + description: 'Name of the tab displaying the JSON request', + } + ), content: ( - + {requestJSON} ), @@ -63,12 +69,19 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: }, { id: 'json-response', - name: i18n.translate('data.search.searchSource.fetch.incompleteResultsModal.tabHeaderResponse', { - defaultMessage: 'Response', - description: 'Name of the tab displaying the JSON response', - }), + name: i18n.translate( + 'data.search.searchSource.fetch.incompleteResultsModal.tabHeaderResponse', + { + defaultMessage: 'Response', + description: 'Name of the tab displaying the JSON response', + } + ), content: ( - + {responseJSON} ), diff --git a/src/plugins/data/public/incomplete_results_modal/index.tsx b/src/plugins/data/public/incomplete_results_modal/index.tsx index 6b38a60bff466b..9cb02367e67a5d 100644 --- a/src/plugins/data/public/incomplete_results_modal/index.tsx +++ b/src/plugins/data/public/incomplete_results_modal/index.tsx @@ -11,9 +11,7 @@ import type { OpenIncompleteResultsModalButtonProps } from './open_incomplete_re const Fallback = () =>
; -const LazyOpenModalButton = React.lazy( - () => import('./open_incomplete_results_modal_button') -); +const LazyOpenModalButton = React.lazy(() => import('./open_incomplete_results_modal_button')); export const OpenIncompleteResultsModalButton = (props: OpenIncompleteResultsModalButtonProps) => ( }> diff --git a/src/plugins/data/public/search/fetch/extract_warnings.ts b/src/plugins/data/public/search/fetch/extract_warnings.ts index 27052e833f2f16..6659944ded96bf 100644 --- a/src/plugins/data/public/search/fetch/extract_warnings.ts +++ b/src/plugins/data/public/search/fetch/extract_warnings.ts @@ -20,7 +20,9 @@ export function extractWarnings(rawResponse: estypes.SearchResponse): SearchResp let isPartial = false; let clusters: Record = {}; if (rawResponse._clusters) { - isPartial = Object.values(rawResponse._clusters.details).some(clusterDetails => clusterDetails.status !== 'successful'); + isPartial = Object.values(rawResponse._clusters.details).some( + (clusterDetails) => clusterDetails.status !== 'successful' + ); clusters = rawResponse._clusters.details; } else if (rawResponse._shards && (rawResponse.timed_out || rawResponse._shards.failed > 0)) { // local cluster only @@ -36,11 +38,10 @@ export function extractWarnings(rawResponse: estypes.SearchResponse): SearchResp if (isPartial) { warnings.push({ type: 'incomplete', - message: i18n.translate( - 'data.search.searchSource.fetch.incompleteResultsMessage', - { defaultMessage: 'The data might be incomplete or wrong.' } - ), - clusters + message: i18n.translate('data.search.searchSource.fetch.incompleteResultsMessage', { + defaultMessage: 'The data might be incomplete or wrong.', + }), + clusters, }); } diff --git a/src/plugins/data/public/search/fetch/handle_warnings.tsx b/src/plugins/data/public/search/fetch/handle_warnings.tsx index 6e8df9a821da0f..a95c5235f83122 100644 --- a/src/plugins/data/public/search/fetch/handle_warnings.tsx +++ b/src/plugins/data/public/search/fetch/handle_warnings.tsx @@ -8,7 +8,7 @@ import { estypes } from '@elastic/elasticsearch'; import { debounce } from 'lodash'; -import { EuiSpacer, EuiTextAlign } from '@elastic/eui'; +import { EuiTextAlign } from '@elastic/eui'; import { ThemeServiceStart } from '@kbn/core/public'; import { toMountPoint } from '@kbn/kibana-react-plugin/public'; import React from 'react'; diff --git a/src/plugins/data/public/search/types.ts b/src/plugins/data/public/search/types.ts index bb490b80e59eb5..2daceefeadb77a 100644 --- a/src/plugins/data/public/search/types.ts +++ b/src/plugins/data/public/search/types.ts @@ -125,8 +125,7 @@ export interface SearchResponseIncompleteWarning { * A warning object for a search response with warnings * @public */ -export type SearchResponseWarning = - | SearchResponseIncompleteWarning; +export type SearchResponseWarning = SearchResponseIncompleteWarning; /** * A callback function which can intercept warnings when passed to {@link showWarnings}. Pass `true` from the From 2046549f544a5fa2bef7ec1457f5a2651ae4fd58 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 1 Sep 2023 18:50:05 +0000 Subject: [PATCH 03/43] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- src/plugins/data/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/data/tsconfig.json b/src/plugins/data/tsconfig.json index 9d46f36ffd29ce..81820900557d7b 100644 --- a/src/plugins/data/tsconfig.json +++ b/src/plugins/data/tsconfig.json @@ -49,7 +49,8 @@ "@kbn/core-saved-objects-server", "@kbn/core-saved-objects-utils-server", "@kbn/data-service", - "@kbn/react-kibana-context-render" + "@kbn/react-kibana-context-render", + "@kbn/es-types" ], "exclude": [ "target/**/*", From 7d15531f004f1ed57baa7818852d65f74b22dc00 Mon Sep 17 00:00:00 2001 From: nreese Date: Fri, 1 Sep 2023 14:41:38 -0600 Subject: [PATCH 04/43] tslint --- .../incomplete_results_modal.tsx | 1 + .../open_incomplete_results_modal_button.tsx | 1 + .../search/fetch/extract_warnings.test.ts | 301 ++++++++++++------ .../public/search/fetch/extract_warnings.ts | 36 +-- .../search/fetch/handle_warnings.test.ts | 182 ----------- src/plugins/data/public/search/index.ts | 1 + .../data/public/search/search_service.test.ts | 84 ----- 7 files changed, 224 insertions(+), 382 deletions(-) delete mode 100644 src/plugins/data/public/search/fetch/handle_warnings.test.ts diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index 633b45c57c5b46..4dec1f6f984c0f 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -22,6 +22,7 @@ import { } from '@elastic/eui'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SearchRequest } from '..'; +import type { SearchResponseIncompleteWarning } from '../search'; export interface Props { onClose: () => void; diff --git a/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx b/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx index 640bbed95bc504..ddc9d94442971f 100644 --- a/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx +++ b/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx @@ -15,6 +15,7 @@ import { toMountPoint } from '@kbn/kibana-react-plugin/public'; import { getOverlays } from '../services'; import type { SearchRequest } from '..'; import { IncompleteResultsModal } from './incomplete_results_modal'; +import type { SearchResponseIncompleteWarning } from '../search'; // @internal export interface OpenIncompleteResultsModalButtonProps { diff --git a/src/plugins/data/public/search/fetch/extract_warnings.test.ts b/src/plugins/data/public/search/fetch/extract_warnings.test.ts index 28a45ca9e6d656..4082bdb85fc7fd 100644 --- a/src/plugins/data/public/search/fetch/extract_warnings.test.ts +++ b/src/plugins/data/public/search/fetch/extract_warnings.test.ts @@ -10,113 +10,220 @@ import { estypes } from '@elastic/elasticsearch'; import { extractWarnings } from './extract_warnings'; describe('extract search response warnings', () => { - it('should extract warnings from response with shard failures', () => { - const response = { - took: 25, - timed_out: false, - _shards: { - total: 4, - successful: 2, - skipped: 0, - failed: 2, - failures: [ - { - shard: 0, - index: 'sample-01-rollup', - node: 'VFTFJxpHSdaoiGxJFLSExQ', - reason: { - type: 'illegal_argument_exception', - reason: - 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', + describe('single cluster', () => { + it('should extract incomplete warning from response with shard failures', () => { + const response = { + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'illegal_argument_exception', + reason: + 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', + }, }, - }, - ], - }, - hits: { total: 18239, max_score: null, hits: [] }, - aggregations: {}, - }; + ], + }, + hits: { total: 18239, max_score: null, hits: [] }, + aggregations: {}, + }; - expect(extractWarnings(response)).toEqual([ - { - type: 'shard_failure', - message: '2 of 4 shards failed', - reason: { - type: 'illegal_argument_exception', - reason: - 'Field [kubernetes.container.memory.available.bytes] of type' + - ' [aggregate_metric_double] is not supported for aggregation [percentiles]', + expect(extractWarnings(response)).toEqual([ + { + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: response._shards, + failures: response._shards.failures, + } + }, }, - text: 'The data might be incomplete or wrong.', - }, - ]); - }); + ]); + }); - it('should extract timeout warning', () => { - const warnings = { - took: 999, - timed_out: true, - _shards: {} as estypes.ShardStatistics, - hits: { hits: [] }, - }; - expect(extractWarnings(warnings)).toEqual([ - { - type: 'timed_out', - message: 'Data might be incomplete because your request timed out', - }, - ]); + it('should extract incomplete warning from response with time out', () => { + const response = { + took: 999, + timed_out: true, + _shards: {} as estypes.ShardStatistics, + hits: { hits: [] }, + }; + expect(extractWarnings(response)).toEqual([ + { + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 999, + timed_out: true, + _shards: response._shards, + failures: response._shards.failures, + } + }, + }, + ]); + }); }); - it('should extract shards failed warnings', () => { - const warnings = { - _shards: { - failed: 77, - total: 79, - }, - } as estypes.SearchResponse; - expect(extractWarnings(warnings)).toEqual([ - { - type: 'shard_failure', - message: '77 of 79 shards failed', - reason: { type: 'generic_shard_warning' }, - text: 'The data might be incomplete or wrong.', - }, - ]); - }); + describe('remote clusters', () => { + it('should extract incomplete warning from response with shard failures', () => { + const response = { + took: 25, + timed_out: false, + "_shards": { + "total": 4, + "successful": 3, + "skipped": 0, + "failed": 1, + "failures": [ + { + "shard": 0, + "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", + "node": "NVzFRd6SS4qT9o0k2vIzlg", + "reason": { + "type": "query_shard_exception", + "reason": "failed to create query: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123", + "index_uuid": "z1sPO8E4TdWcijNgsL_BxQ", + "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", + "caused_by": { + "type": "runtime_exception", + "reason": "runtime_exception: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123" + } + } + } + ] + }, + "_clusters": { + "total": 2, + "successful": 2, + "skipped": 0, + "details": { + "(local)": { + "status": "successful", + "indices": "kibana_sample_data_logs,kibana_sample_data_flights", + "took": 1, + "timed_out": false, + "_shards": { + "total": 2, + "successful": 2, + "skipped": 0, + "failed": 0 + } + }, + "remote1": { + "status": "partial", + "indices": "kibana_sample_data_logs,kibana_sample_data_flights", + "took": 5, + "timed_out": false, + "_shards": { + "total": 2, + "successful": 1, + "skipped": 0, + "failed": 1 + }, + "failures": [ + { + "shard": 0, + "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", + "node": "NVzFRd6SS4qT9o0k2vIzlg", + "reason": { + "type": "query_shard_exception", + "reason": "failed to create query: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123", + "index_uuid": "z1sPO8E4TdWcijNgsL_BxQ", + "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", + "caused_by": { + "type": "runtime_exception", + "reason": "runtime_exception: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123" + } + } + } + ] + } + } + }, + hits: { total: 18239, max_score: null, hits: [] }, + aggregations: {}, + }; - it('should extract shards failed warning failure reason type', () => { - const warnings = extractWarnings({ - _shards: { - failed: 77, - total: 79, - }, - } as estypes.SearchResponse); - expect(warnings).toEqual([ - { - type: 'shard_failure', - message: '77 of 79 shards failed', - reason: { type: 'generic_shard_warning' }, - text: 'The data might be incomplete or wrong.', - }, - ]); - }); + expect(extractWarnings(response)).toEqual([ + { + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: response._clusters.details, + }, + ]); + }); - it('extracts multiple warnings', () => { - const warnings = extractWarnings({ - timed_out: true, - _shards: { - failed: 77, - total: 79, - }, - } as estypes.SearchResponse); - const [shardFailures, timedOut] = [ - warnings.filter(({ type }) => type !== 'timed_out'), - warnings.filter(({ type }) => type === 'timed_out'), - ]; - expect(shardFailures[0]!.message).toBeDefined(); - expect(timedOut[0]!.message).toBeDefined(); + it('should extract incomplete warning from response with time out', () => { + const response = { + took: 999, + timed_out: true, + "_shards": { + "total": 6, + "successful": 6, + "skipped": 0, + "failed": 0 + }, + "_clusters": { + "total": 2, + "successful": 2, + "skipped": 0, + "details": { + "(local)": { + "status": "successful", + "indices": "kibana_sample_data_ecommerce,kibana_sample_data_logs,kibana_sample_data_flights", + "took": 0, + "timed_out": false, + "_shards": { + "total": 3, + "successful": 3, + "skipped": 0, + "failed": 0 + } + }, + "remote1": { + "status": "partial", + "indices": "kibana_sample_data*", + "took": 10005, + "timed_out": true, + "_shards": { + "total": 3, + "successful": 3, + "skipped": 0, + "failed": 0 + } + } + } + }, + hits: { hits: [] }, + }; + expect(extractWarnings(response)).toEqual([ + { + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: response._clusters.details, + }, + ]); + }); }); - it('should not include shardStats or types fields if there are no warnings', () => { + it('should not include warnings when there are none', () => { const warnings = extractWarnings({ timed_out: false, _shards: { diff --git a/src/plugins/data/public/search/fetch/extract_warnings.ts b/src/plugins/data/public/search/fetch/extract_warnings.ts index 6659944ded96bf..a35d1e3925d3c3 100644 --- a/src/plugins/data/public/search/fetch/extract_warnings.ts +++ b/src/plugins/data/public/search/fetch/extract_warnings.ts @@ -17,31 +17,29 @@ import { SearchResponseWarning } from '../types'; export function extractWarnings(rawResponse: estypes.SearchResponse): SearchResponseWarning[] { const warnings: SearchResponseWarning[] = []; - let isPartial = false; - let clusters: Record = {}; - if (rawResponse._clusters) { - isPartial = Object.values(rawResponse._clusters.details).some( - (clusterDetails) => clusterDetails.status !== 'successful' - ); - clusters = rawResponse._clusters.details; - } else if (rawResponse._shards && (rawResponse.timed_out || rawResponse._shards.failed > 0)) { - // local cluster only - isPartial = true; - clusters['(local)'] = { - status: 'partial', - took: rawResponse.took, - timed_out: rawResponse.timed_out, - _shards: rawResponse._shards, - failures: rawResponse._shards.failures, - }; - } + const isPartial = rawResponse._clusters + ? Object.values((rawResponse._clusters as estypes.ClusterStatistics & { details: Record }).details).some( + (clusterDetails) => clusterDetails.status !== 'successful' + ) + : rawResponse.timed_out || rawResponse._shards.failed > 0; if (isPartial) { warnings.push({ type: 'incomplete', message: i18n.translate('data.search.searchSource.fetch.incompleteResultsMessage', { defaultMessage: 'The data might be incomplete or wrong.', }), - clusters, + clusters: rawResponse._clusters + ? (rawResponse._clusters as estypes.ClusterStatistics & { details: Record }).details + : { + '(local)': { + status: 'partial', + indices: '', + took: rawResponse.took, + timed_out: rawResponse.timed_out, + _shards: rawResponse._shards, + failures: rawResponse._shards.failures, + } + }, }); } diff --git a/src/plugins/data/public/search/fetch/handle_warnings.test.ts b/src/plugins/data/public/search/fetch/handle_warnings.test.ts deleted file mode 100644 index bc07eb36739913..00000000000000 --- a/src/plugins/data/public/search/fetch/handle_warnings.test.ts +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { estypes } from '@elastic/elasticsearch'; -import { notificationServiceMock } from '@kbn/core-notifications-browser-mocks'; -import { themeServiceMock } from '@kbn/core/public/mocks'; -import { setNotifications } from '../../services'; -import { SearchResponseWarning } from '../types'; -import { filterWarnings, handleWarnings } from './handle_warnings'; -import * as extract from './extract_warnings'; -import { SearchRequest } from '../../../common'; - -jest.mock('@kbn/i18n', () => { - return { - i18n: { - translate: (_id: string, { defaultMessage }: { defaultMessage: string }) => defaultMessage, - }, - }; -}); -jest.mock('./extract_warnings', () => ({ - extractWarnings: jest.fn(() => []), -})); - -const theme = themeServiceMock.createStartContract(); -const warnings: SearchResponseWarning[] = [ - { - type: 'timed_out' as const, - message: 'Something timed out!', - reason: undefined, - }, - { - type: 'shard_failure' as const, - message: 'Some shards failed!', - text: 'test text', - reason: { type: 'illegal_argument_exception', reason: 'Illegal argument! Go to jail!' }, - }, - { - type: 'shard_failure' as const, - message: 'Some shards failed!', - reason: { type: 'generic_shard_failure' }, - }, -]; - -const sessionId = 'abcd'; - -describe('Filtering and showing warnings', () => { - const notifications = notificationServiceMock.createStartContract(); - jest.useFakeTimers(); - - describe('handleWarnings', () => { - const request = { body: {} }; - beforeEach(() => { - jest.resetAllMocks(); - jest.advanceTimersByTime(30000); - setNotifications(notifications); - (notifications.toasts.addWarning as jest.Mock).mockReset(); - (extract.extractWarnings as jest.Mock).mockImplementation(() => warnings); - }); - - test('should notify if timed out', () => { - (extract.extractWarnings as jest.Mock).mockImplementation(() => [warnings[0]]); - const response = { rawResponse: { timed_out: true } } as unknown as estypes.SearchResponse; - handleWarnings({ request, response, theme }); - // test debounce, addWarning should only be called once - handleWarnings({ request, response, theme }); - - expect(notifications.toasts.addWarning).toBeCalledTimes(1); - expect(notifications.toasts.addWarning).toBeCalledWith({ title: 'Something timed out!' }); - - // test debounce, call addWarning again due to sessionId - handleWarnings({ request, response, theme, sessionId }); - expect(notifications.toasts.addWarning).toBeCalledTimes(2); - }); - - test('should notify if shards failed for unknown type/reason', () => { - (extract.extractWarnings as jest.Mock).mockImplementation(() => [warnings[2]]); - const response = { - rawResponse: { _shards: { failed: 1, total: 2, successful: 1, skipped: 1 } }, - } as unknown as estypes.SearchResponse; - handleWarnings({ request, response, theme }); - // test debounce, addWarning should only be called once - handleWarnings({ request, response, theme }); - - expect(notifications.toasts.addWarning).toBeCalledTimes(1); - expect(notifications.toasts.addWarning).toBeCalledWith({ title: 'Some shards failed!' }); - - // test debounce, call addWarning again due to sessionId - handleWarnings({ request, response, theme, sessionId }); - expect(notifications.toasts.addWarning).toBeCalledTimes(2); - }); - - test('should add mount point for shard modal failure button if warning.text is provided', () => { - (extract.extractWarnings as jest.Mock).mockImplementation(() => [warnings[1]]); - const response = { - rawResponse: { _shards: { failed: 1, total: 2, successful: 1, skipped: 1 } }, - } as unknown as estypes.SearchResponse; - handleWarnings({ request, response, theme }); - // test debounce, addWarning should only be called once - handleWarnings({ request, response, theme }); - - expect(notifications.toasts.addWarning).toBeCalledTimes(1); - expect(notifications.toasts.addWarning).toBeCalledWith({ - title: 'Some shards failed!', - text: expect.any(Function), - }); - - // test debounce, call addWarning again due to sessionId - handleWarnings({ request, response, theme, sessionId }); - expect(notifications.toasts.addWarning).toBeCalledTimes(2); - }); - - test('should notify once if the response contains multiple failures', () => { - (extract.extractWarnings as jest.Mock).mockImplementation(() => [warnings[1], warnings[2]]); - const response = { - rawResponse: { _shards: { failed: 1, total: 2, successful: 1, skipped: 1 } }, - } as unknown as estypes.SearchResponse; - handleWarnings({ request, response, theme }); - - expect(notifications.toasts.addWarning).toBeCalledTimes(1); - expect(notifications.toasts.addWarning).toBeCalledWith({ - title: 'Some shards failed!', - text: expect.any(Function), - }); - }); - - test('should notify once if the response contains some unfiltered failures', () => { - const callback = (warning: SearchResponseWarning) => - warning.reason?.type !== 'generic_shard_failure'; - const response = { - rawResponse: { _shards: { failed: 1, total: 2, successful: 1, skipped: 1 } }, - } as unknown as estypes.SearchResponse; - handleWarnings({ request, response, theme, callback }); - - expect(notifications.toasts.addWarning).toBeCalledTimes(1); - expect(notifications.toasts.addWarning).toBeCalledWith({ title: 'Some shards failed!' }); - }); - - test('should not notify if the response contains no unfiltered failures', () => { - const callback = () => true; - const response = { - rawResponse: { _shards: { failed: 1, total: 2, successful: 1, skipped: 1 } }, - } as unknown as estypes.SearchResponse; - handleWarnings({ request, response, theme, callback }); - - expect(notifications.toasts.addWarning).toBeCalledTimes(0); - }); - }); - - describe('filterWarnings', () => { - const callback = jest.fn(); - const request = {} as SearchRequest; - const response = {} as estypes.SearchResponse; - - beforeEach(() => { - callback.mockImplementation(() => { - throw new Error('not initialized'); - }); - }); - - it('filters out all', () => { - callback.mockImplementation(() => true); - expect(filterWarnings(warnings, callback, request, response, 'id')).toEqual([]); - }); - - it('filters out some', () => { - callback.mockImplementation( - (warning: SearchResponseWarning) => warning.reason?.type !== 'generic_shard_failure' - ); - expect(filterWarnings(warnings, callback, request, response, 'id')).toEqual([warnings[2]]); - }); - - it('filters out none', () => { - callback.mockImplementation(() => false); - expect(filterWarnings(warnings, callback, request, response, 'id')).toEqual(warnings); - }); - }); -}); diff --git a/src/plugins/data/public/search/index.ts b/src/plugins/data/public/search/index.ts index 46024da1096d01..fe193c867475f5 100644 --- a/src/plugins/data/public/search/index.ts +++ b/src/plugins/data/public/search/index.ts @@ -10,6 +10,7 @@ export * from './expressions'; export type { SearchResponseWarning, + SearchResponseIncompleteWarning, ISearchSetup, ISearchStart, ISearchStartSearchSource, diff --git a/src/plugins/data/public/search/search_service.test.ts b/src/plugins/data/public/search/search_service.test.ts index c94cde6b8f747f..3b82c140582bbf 100644 --- a/src/plugins/data/public/search/search_service.test.ts +++ b/src/plugins/data/public/search/search_service.test.ts @@ -155,90 +155,6 @@ describe('Search service', () => { expect(notifications.toasts.addWarning).toBeCalledTimes(0); }); - - it('will show single notification when some warnings are filtered', () => { - callback = (warning) => warning.reason?.type === 'illegal_argument_exception'; - shards.failures = [ - { - reason: { - type: 'illegal_argument_exception', - reason: 'reason of "illegal_argument_exception"', - }, - }, - { - reason: { - type: 'other_kind_of_exception', - reason: 'reason of other_kind_of_exception', - }, - }, - { reason: { type: 'fatal_warning', reason: 'this is a fatal warning message' } }, - ] as unknown as estypes.ShardFailure[]; - - const responder = inspector.adapter.start('request1'); - responder.ok(getMockResponseWithShards(shards)); - data.showWarnings(inspector.adapter, callback); - - expect(notifications.toasts.addWarning).toBeCalledTimes(1); - expect(notifications.toasts.addWarning).toBeCalledWith({ - title: '2 of 4 shards failed', - text: expect.any(Function), - }); - }); - - it('can show a timed_out warning', () => { - const responder = inspector.adapter.start('request1'); - shards = { total: 4, successful: 4, skipped: 0, failed: 0 }; - const response1 = getMockResponseWithShards(shards); - response1.json.rawResponse.timed_out = true; - responder.ok(response1); - data.showWarnings(inspector.adapter, callback); - - expect(notifications.toasts.addWarning).toBeCalledTimes(1); - expect(notifications.toasts.addWarning).toBeCalledWith({ - title: 'Data might be incomplete because your request timed out', - }); - }); - - it('can show two warnings if response has shard failures and also timed_out', () => { - const responder = inspector.adapter.start('request1'); - const response1 = getMockResponseWithShards(shards); - response1.json.rawResponse.timed_out = true; - responder.ok(response1); - data.showWarnings(inspector.adapter, callback); - - expect(notifications.toasts.addWarning).toBeCalledTimes(2); - expect(notifications.toasts.addWarning).nthCalledWith(1, { - title: 'Data might be incomplete because your request timed out', - }); - expect(notifications.toasts.addWarning).nthCalledWith(2, { - title: '2 of 4 shards failed', - text: expect.any(Function), - }); - }); - - it('will show multiple warnings when multiple responses have shard failures', () => { - const responder1 = inspector.adapter.start('request1'); - const responder2 = inspector.adapter.start('request2'); - responder1.ok(getMockResponseWithShards(shards)); - responder2.ok({ - json: { - rawResponse: { - timed_out: true, - }, - }, - }); - - data.showWarnings(inspector.adapter, callback); - - expect(notifications.toasts.addWarning).toBeCalledTimes(2); - expect(notifications.toasts.addWarning).nthCalledWith(1, { - title: '2 of 4 shards failed', - text: expect.any(Function), - }); - expect(notifications.toasts.addWarning).nthCalledWith(2, { - title: 'Data might be incomplete because your request timed out', - }); - }); }); }); }); From 74f7c8895e36c8560e53296ac1ec559132e3ffad Mon Sep 17 00:00:00 2001 From: nreese Date: Fri, 1 Sep 2023 14:44:27 -0600 Subject: [PATCH 05/43] another test case --- .../search/fetch/extract_warnings.test.ts | 67 ++++++++++++++++--- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/src/plugins/data/public/search/fetch/extract_warnings.test.ts b/src/plugins/data/public/search/fetch/extract_warnings.test.ts index 4082bdb85fc7fd..46702b6c7cf17c 100644 --- a/src/plugins/data/public/search/fetch/extract_warnings.test.ts +++ b/src/plugins/data/public/search/fetch/extract_warnings.test.ts @@ -79,6 +79,18 @@ describe('extract search response warnings', () => { }, ]); }); + + it('should not include warnings when there are none', () => { + const warnings = extractWarnings({ + timed_out: false, + _shards: { + failed: 0, + total: 9000, + }, + } as estypes.SearchResponse); + + expect(warnings).toEqual([]); + }); }); describe('remote clusters', () => { @@ -221,17 +233,52 @@ describe('extract search response warnings', () => { }, ]); }); - }); - it('should not include warnings when there are none', () => { - const warnings = extractWarnings({ - timed_out: false, - _shards: { - failed: 0, - total: 9000, - }, - } as estypes.SearchResponse); + it('should not include warnings when there are none', () => { + const warnings = extractWarnings({ + took: 10, + timed_out: false, + "_shards": { + "total": 4, + "successful": 4, + "skipped": 0, + "failed": 0 + }, + "_clusters": { + "total": 2, + "successful": 2, + "skipped": 0, + "details": { + "(local)": { + "status": "successful", + "indices": "kibana_sample_data_logs,kibana_sample_data_flights", + "took": 0, + "timed_out": false, + "_shards": { + "total": 2, + "successful": 2, + "skipped": 0, + "failed": 0 + } + }, + "remote1": { + "status": "successful", + "indices": "kibana_sample_data_logs,kibana_sample_data_flights", + "took": 1, + "timed_out": false, + "_shards": { + "total": 2, + "successful": 2, + "skipped": 0, + "failed": 0 + } + } + } + }, + hits: { hits: [] }, + } as estypes.SearchResponse); - expect(warnings).toEqual([]); + expect(warnings).toEqual([]); + }); }); }); From e87efd7544f87f7d61441a098ee2eefac61c209a Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 1 Sep 2023 20:49:30 +0000 Subject: [PATCH 06/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../search/fetch/extract_warnings.test.ts | 275 +++++++++--------- 1 file changed, 140 insertions(+), 135 deletions(-) diff --git a/src/plugins/data/public/search/fetch/extract_warnings.test.ts b/src/plugins/data/public/search/fetch/extract_warnings.test.ts index 46702b6c7cf17c..fed0969c2004f9 100644 --- a/src/plugins/data/public/search/fetch/extract_warnings.test.ts +++ b/src/plugins/data/public/search/fetch/extract_warnings.test.ts @@ -49,7 +49,7 @@ describe('extract search response warnings', () => { timed_out: false, _shards: response._shards, failures: response._shards.failures, - } + }, }, }, ]); @@ -74,7 +74,7 @@ describe('extract search response warnings', () => { timed_out: true, _shards: response._shards, failures: response._shards.failures, - } + }, }, }, ]); @@ -98,76 +98,80 @@ describe('extract search response warnings', () => { const response = { took: 25, timed_out: false, - "_shards": { - "total": 4, - "successful": 3, - "skipped": 0, - "failed": 1, - "failures": [ + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, + failures: [ { - "shard": 0, - "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", - "node": "NVzFRd6SS4qT9o0k2vIzlg", - "reason": { - "type": "query_shard_exception", - "reason": "failed to create query: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123", - "index_uuid": "z1sPO8E4TdWcijNgsL_BxQ", - "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", - "caused_by": { - "type": "runtime_exception", - "reason": "runtime_exception: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123" - } - } - } - ] + shard: 0, + index: 'remote1:.ds-kibana_sample_data_logs-2023.08.21-000001', + node: 'NVzFRd6SS4qT9o0k2vIzlg', + reason: { + type: 'query_shard_exception', + reason: + 'failed to create query: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123', + index_uuid: 'z1sPO8E4TdWcijNgsL_BxQ', + index: 'remote1:.ds-kibana_sample_data_logs-2023.08.21-000001', + caused_by: { + type: 'runtime_exception', + reason: + 'runtime_exception: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123', + }, + }, + }, + ], }, - "_clusters": { - "total": 2, - "successful": 2, - "skipped": 0, - "details": { - "(local)": { - "status": "successful", - "indices": "kibana_sample_data_logs,kibana_sample_data_flights", - "took": 1, - "timed_out": false, - "_shards": { - "total": 2, - "successful": 2, - "skipped": 0, - "failed": 0 - } + _clusters: { + total: 2, + successful: 2, + skipped: 0, + details: { + '(local)': { + status: 'successful', + indices: 'kibana_sample_data_logs,kibana_sample_data_flights', + took: 1, + timed_out: false, + _shards: { + total: 2, + successful: 2, + skipped: 0, + failed: 0, + }, }, - "remote1": { - "status": "partial", - "indices": "kibana_sample_data_logs,kibana_sample_data_flights", - "took": 5, - "timed_out": false, - "_shards": { - "total": 2, - "successful": 1, - "skipped": 0, - "failed": 1 + remote1: { + status: 'partial', + indices: 'kibana_sample_data_logs,kibana_sample_data_flights', + took: 5, + timed_out: false, + _shards: { + total: 2, + successful: 1, + skipped: 0, + failed: 1, }, - "failures": [ + failures: [ { - "shard": 0, - "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", - "node": "NVzFRd6SS4qT9o0k2vIzlg", - "reason": { - "type": "query_shard_exception", - "reason": "failed to create query: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123", - "index_uuid": "z1sPO8E4TdWcijNgsL_BxQ", - "index": "remote1:.ds-kibana_sample_data_logs-2023.08.21-000001", - "caused_by": { - "type": "runtime_exception", - "reason": "runtime_exception: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123" - } - } - } - ] - } - } + shard: 0, + index: 'remote1:.ds-kibana_sample_data_logs-2023.08.21-000001', + node: 'NVzFRd6SS4qT9o0k2vIzlg', + reason: { + type: 'query_shard_exception', + reason: + 'failed to create query: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123', + index_uuid: 'z1sPO8E4TdWcijNgsL_BxQ', + index: 'remote1:.ds-kibana_sample_data_logs-2023.08.21-000001', + caused_by: { + type: 'runtime_exception', + reason: + 'runtime_exception: [.ds-kibana_sample_data_logs-2023.08.21-000001][0] local shard failure message 123', + }, + }, + }, + ], + }, + }, }, hits: { total: 18239, max_score: null, hits: [] }, aggregations: {}, @@ -186,42 +190,43 @@ describe('extract search response warnings', () => { const response = { took: 999, timed_out: true, - "_shards": { - "total": 6, - "successful": 6, - "skipped": 0, - "failed": 0 + _shards: { + total: 6, + successful: 6, + skipped: 0, + failed: 0, }, - "_clusters": { - "total": 2, - "successful": 2, - "skipped": 0, - "details": { - "(local)": { - "status": "successful", - "indices": "kibana_sample_data_ecommerce,kibana_sample_data_logs,kibana_sample_data_flights", - "took": 0, - "timed_out": false, - "_shards": { - "total": 3, - "successful": 3, - "skipped": 0, - "failed": 0 - } + _clusters: { + total: 2, + successful: 2, + skipped: 0, + details: { + '(local)': { + status: 'successful', + indices: + 'kibana_sample_data_ecommerce,kibana_sample_data_logs,kibana_sample_data_flights', + took: 0, + timed_out: false, + _shards: { + total: 3, + successful: 3, + skipped: 0, + failed: 0, + }, }, - "remote1": { - "status": "partial", - "indices": "kibana_sample_data*", - "took": 10005, - "timed_out": true, - "_shards": { - "total": 3, - "successful": 3, - "skipped": 0, - "failed": 0 - } - } - } + remote1: { + status: 'partial', + indices: 'kibana_sample_data*', + took: 10005, + timed_out: true, + _shards: { + total: 3, + successful: 3, + skipped: 0, + failed: 0, + }, + }, + }, }, hits: { hits: [] }, }; @@ -238,42 +243,42 @@ describe('extract search response warnings', () => { const warnings = extractWarnings({ took: 10, timed_out: false, - "_shards": { - "total": 4, - "successful": 4, - "skipped": 0, - "failed": 0 + _shards: { + total: 4, + successful: 4, + skipped: 0, + failed: 0, }, - "_clusters": { - "total": 2, - "successful": 2, - "skipped": 0, - "details": { - "(local)": { - "status": "successful", - "indices": "kibana_sample_data_logs,kibana_sample_data_flights", - "took": 0, - "timed_out": false, - "_shards": { - "total": 2, - "successful": 2, - "skipped": 0, - "failed": 0 - } + _clusters: { + total: 2, + successful: 2, + skipped: 0, + details: { + '(local)': { + status: 'successful', + indices: 'kibana_sample_data_logs,kibana_sample_data_flights', + took: 0, + timed_out: false, + _shards: { + total: 2, + successful: 2, + skipped: 0, + failed: 0, + }, }, - "remote1": { - "status": "successful", - "indices": "kibana_sample_data_logs,kibana_sample_data_flights", - "took": 1, - "timed_out": false, - "_shards": { - "total": 2, - "successful": 2, - "skipped": 0, - "failed": 0 - } - } - } + remote1: { + status: 'successful', + indices: 'kibana_sample_data_logs,kibana_sample_data_flights', + took: 1, + timed_out: false, + _shards: { + total: 2, + successful: 2, + skipped: 0, + failed: 0, + }, + }, + }, }, hits: { hits: [] }, } as estypes.SearchResponse); From 3d3c439bd07ffafc05cc333288ada0d951b62f9e Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 1 Sep 2023 21:21:25 +0000 Subject: [PATCH 07/43] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../public/search/fetch/extract_warnings.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/data/public/search/fetch/extract_warnings.ts b/src/plugins/data/public/search/fetch/extract_warnings.ts index a35d1e3925d3c3..34b30d5f971bf5 100644 --- a/src/plugins/data/public/search/fetch/extract_warnings.ts +++ b/src/plugins/data/public/search/fetch/extract_warnings.ts @@ -18,9 +18,13 @@ export function extractWarnings(rawResponse: estypes.SearchResponse): SearchResp const warnings: SearchResponseWarning[] = []; const isPartial = rawResponse._clusters - ? Object.values((rawResponse._clusters as estypes.ClusterStatistics & { details: Record }).details).some( - (clusterDetails) => clusterDetails.status !== 'successful' - ) + ? Object.values( + ( + rawResponse._clusters as estypes.ClusterStatistics & { + details: Record; + } + ).details + ).some((clusterDetails) => clusterDetails.status !== 'successful') : rawResponse.timed_out || rawResponse._shards.failed > 0; if (isPartial) { warnings.push({ @@ -29,7 +33,11 @@ export function extractWarnings(rawResponse: estypes.SearchResponse): SearchResp defaultMessage: 'The data might be incomplete or wrong.', }), clusters: rawResponse._clusters - ? (rawResponse._clusters as estypes.ClusterStatistics & { details: Record }).details + ? ( + rawResponse._clusters as estypes.ClusterStatistics & { + details: Record; + } + ).details : { '(local)': { status: 'partial', @@ -38,7 +46,7 @@ export function extractWarnings(rawResponse: estypes.SearchResponse): SearchResp timed_out: rawResponse.timed_out, _shards: rawResponse._shards, failures: rawResponse._shards.failures, - } + }, }, }); } From be16158555d3eda2cc22487abde390bb1c2bfdde Mon Sep 17 00:00:00 2001 From: nreese Date: Fri, 1 Sep 2023 17:27:53 -0600 Subject: [PATCH 08/43] fix discover --- .../search_response_warnings.tsx | 11 +----- ...t_search_response_intercepted_warnings.tsx | 38 ++++--------------- .../data/common/search/aggs/agg_type.ts | 2 +- .../buckets/_terms_other_bucket_helper.ts | 4 +- .../esaggs/request_handler.test.ts | 6 +-- .../expressions/esaggs/request_handler.ts | 6 +-- .../search/expressions/kibana_context_type.ts | 2 +- .../search/search_source/search_source.ts | 2 +- .../data/common/search/search_source/types.ts | 4 +- src/plugins/data/public/index.ts | 1 + .../public/search/expressions/esaggs.test.ts | 2 +- .../data/public/search/expressions/esaggs.ts | 4 +- .../data/public/search/search_service.ts | 2 +- .../server/search/expressions/esaggs.test.ts | 2 +- .../data/server/search/expressions/esaggs.ts | 2 +- src/plugins/discover/common/constants.ts | 3 +- .../application/context/services/anchor.ts | 6 +-- .../context/utils/fetch_hits_in_interval.ts | 6 +-- .../application/main/utils/fetch_documents.ts | 6 +-- .../embeddable/saved_search_embeddable.tsx | 6 +-- .../public/chart/hooks/use_total_hits.ts | 2 +- .../embeddable/visualize_embeddable.tsx | 2 +- 22 files changed, 35 insertions(+), 84 deletions(-) diff --git a/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.tsx b/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.tsx index 3c92096aa982b3..27b05b063eb164 100644 --- a/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.tsx +++ b/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.tsx @@ -270,22 +270,13 @@ function WarningContent({ groupStyles?: Partial; 'data-test-subj': string; }) { - const hasDescription = 'text' in originalWarning; - return ( - {hasDescription ? {originalWarning.message} : originalWarning.message} + {originalWarning.message} - {hasDescription ? ( - - -

{originalWarning.text}

-
-
- ) : null} {action ? {action} : null}
); diff --git a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx index 38ad0da2639f7e..ac2c165ad43318 100644 --- a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx +++ b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx @@ -10,8 +10,7 @@ import React from 'react'; import { uniqBy } from 'lodash'; import { type DataPublicPluginStart, - type ShardFailureRequest, - ShardFailureOpenModalButton, + OpenIncompleteResultsModalButton, } from '@kbn/data-plugin/public'; import type { RequestAdapter } from '@kbn/inspector-plugin/common'; import type { CoreStart } from '@kbn/core-lifecycle-browser'; @@ -33,14 +32,7 @@ export const getSearchResponseInterceptedWarnings = ({ theme: CoreStart['theme']; }; adapter: RequestAdapter; - options?: { - disableShardFailureWarning?: boolean; - }; }): SearchResponseInterceptedWarning[] | undefined => { - if (!options?.disableShardFailureWarning) { - return undefined; - } - const interceptedWarnings: SearchResponseInterceptedWarning[] = []; services.data.search.showWarnings(adapter, (warning, meta) => { @@ -49,13 +41,13 @@ export const getSearchResponseInterceptedWarnings = ({ interceptedWarnings.push({ originalWarning: warning, action: - warning.type === 'shard_failure' && warning.text && warning.message ? ( - ({ - request: request as ShardFailureRequest, + request, response, })} color="primary" @@ -66,23 +58,7 @@ export const getSearchResponseInterceptedWarnings = ({ return true; // suppress the default behaviour }); - return removeInterceptedWarningDuplicates(interceptedWarnings); -}; - -/** - * Removes duplicated warnings - * @param interceptedWarnings - */ -export const removeInterceptedWarningDuplicates = ( - interceptedWarnings: SearchResponseInterceptedWarning[] | undefined -): SearchResponseInterceptedWarning[] | undefined => { - if (!interceptedWarnings?.length) { - return undefined; - } - - const uniqInterceptedWarnings = uniqBy(interceptedWarnings, (interceptedWarning) => - JSON.stringify(interceptedWarning.originalWarning) - ); + console.log(interceptedWarnings); - return uniqInterceptedWarnings?.length ? uniqInterceptedWarnings : undefined; + return interceptedWarnings; }; diff --git a/src/plugins/data/common/search/aggs/agg_type.ts b/src/plugins/data/common/search/aggs/agg_type.ts index 4812ac6f07c5f1..f0b2b2702dbf90 100644 --- a/src/plugins/data/common/search/aggs/agg_type.ts +++ b/src/plugins/data/common/search/aggs/agg_type.ts @@ -30,7 +30,7 @@ type PostFlightRequestFn = ( inspectorRequestAdapter?: RequestAdapter, abortSignal?: AbortSignal, searchSessionId?: string, - disableShardFailureWarning?: boolean + disableWarningToasts?: boolean ) => Promise>; export interface AggTypeConfig< diff --git a/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts b/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts index 97378837332660..bfa51493b34b2b 100644 --- a/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts +++ b/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts @@ -392,7 +392,7 @@ export const createOtherBucketPostFlightRequest = ( inspectorRequestAdapter, abortSignal, searchSessionId, - disableShardFailureWarning + disableWarningToasts ) => { if (!resp.aggregations) return resp; const nestedSearchSource = searchSource.createChild(); @@ -406,7 +406,7 @@ export const createOtherBucketPostFlightRequest = ( nestedSearchSource.fetch$({ abortSignal, sessionId: searchSessionId, - disableShardFailureWarning, + disableWarningToasts, inspector: { adapter: inspectorRequestAdapter, title: i18n.translate('data.search.aggs.buckets.terms.otherBucketTitle', { diff --git a/src/plugins/data/common/search/expressions/esaggs/request_handler.test.ts b/src/plugins/data/common/search/expressions/esaggs/request_handler.test.ts index e0555fbd240767..4c42fdc985ff46 100644 --- a/src/plugins/data/common/search/expressions/esaggs/request_handler.test.ts +++ b/src/plugins/data/common/search/expressions/esaggs/request_handler.test.ts @@ -53,7 +53,7 @@ describe('esaggs expression function - public', () => { query: undefined, searchSessionId: 'abc123', searchSourceService: searchSourceCommonMock, - disableShardWarnings: false, + disableWarningToasts: false, timeFields: ['@timestamp', 'utc_time'], timeRange: undefined, }; @@ -139,7 +139,7 @@ describe('esaggs expression function - public', () => { description: 'This request queries Elasticsearch to fetch the data for the visualization.', adapter: undefined, }, - disableShardFailureWarning: false, + disableWarningToasts: false, }); }); @@ -159,7 +159,7 @@ describe('esaggs expression function - public', () => { description: 'MyDescription', adapter: undefined, }, - disableShardFailureWarning: false, + disableWarningToasts: false, }); }); diff --git a/src/plugins/data/common/search/expressions/esaggs/request_handler.ts b/src/plugins/data/common/search/expressions/esaggs/request_handler.ts index 196ebfa55810f2..7f0155d74082fc 100644 --- a/src/plugins/data/common/search/expressions/esaggs/request_handler.ts +++ b/src/plugins/data/common/search/expressions/esaggs/request_handler.ts @@ -30,7 +30,7 @@ export interface RequestHandlerParams { searchSourceService: ISearchStartSearchSource; timeFields?: string[]; timeRange?: TimeRange; - disableShardWarnings?: boolean; + disableWarningToasts?: boolean; getNow?: () => Date; executionContext?: KibanaExecutionContext; title?: string; @@ -48,7 +48,7 @@ export const handleRequest = ({ searchSourceService, timeFields, timeRange, - disableShardWarnings, + disableWarningToasts, getNow, executionContext, title, @@ -110,7 +110,7 @@ export const handleRequest = ({ requestSearchSource .fetch$({ abortSignal, - disableShardFailureWarning: disableShardWarnings, + disableWarningToasts, sessionId: searchSessionId, inspector: { adapter: inspectorAdapters.requests, diff --git a/src/plugins/data/common/search/expressions/kibana_context_type.ts b/src/plugins/data/common/search/expressions/kibana_context_type.ts index cec788d27d856d..d6947d2d46ce39 100644 --- a/src/plugins/data/common/search/expressions/kibana_context_type.ts +++ b/src/plugins/data/common/search/expressions/kibana_context_type.ts @@ -15,7 +15,7 @@ export type ExecutionContextSearch = { filters?: Filter[]; query?: Query | Query[]; timeRange?: TimeRange; - disableShardWarnings?: boolean; + disableWarningToasts?: boolean; }; export type ExpressionValueSearchContext = ExpressionValueBoxed< diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index b74b7e111b5ce1..f05f198451e0a1 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -520,7 +520,7 @@ export class SearchSource { options.inspector?.adapter, options.abortSignal, options.sessionId, - options.disableShardFailureWarning + options.disableWarningToasts ); } } diff --git a/src/plugins/data/common/search/search_source/types.ts b/src/plugins/data/common/search/search_source/types.ts index 140c2dd59a59d6..60c0d3713ec643 100644 --- a/src/plugins/data/common/search/search_source/types.ts +++ b/src/plugins/data/common/search/search_source/types.ts @@ -249,7 +249,7 @@ export interface SearchSourceSearchOptions extends ISearchOptions { inspector?: IInspectorInfo; /** - * Disable default warnings of shard failures + * Set to true to disable warning toasts and customize warning display */ - disableShardFailureWarning?: boolean; + disableWarningToasts?: boolean; } diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index d8aa9a35a29a76..cd998257d75d65 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -275,6 +275,7 @@ export type { // TODO: move to @kbn/search-response-warnings export type { ShardFailureRequest } from './shard_failure_modal'; export { ShardFailureOpenModalButton } from './shard_failure_modal'; +export { OpenIncompleteResultsModalButton } from './incomplete_results_modal'; export type { AggsStart } from './search/aggs'; diff --git a/src/plugins/data/public/search/expressions/esaggs.test.ts b/src/plugins/data/public/search/expressions/esaggs.test.ts index de35e0b238da95..cf3b04029a2c87 100644 --- a/src/plugins/data/public/search/expressions/esaggs.test.ts +++ b/src/plugins/data/public/search/expressions/esaggs.test.ts @@ -126,7 +126,7 @@ describe('esaggs expression function - public', () => { searchSessionId: 'abc123', searchSourceService: startDependencies.searchSource, timeFields: args.timeFields, - disableShardWarnings: false, + disableWarningToasts: false, timeRange: undefined, getNow: undefined, }); diff --git a/src/plugins/data/public/search/expressions/esaggs.ts b/src/plugins/data/public/search/expressions/esaggs.ts index eecaa5890ba353..28a559bbe96544 100644 --- a/src/plugins/data/public/search/expressions/esaggs.ts +++ b/src/plugins/data/public/search/expressions/esaggs.ts @@ -61,7 +61,7 @@ export function getFunctionDefinition({ return { aggConfigs, indexPattern, searchSource, getNow, handleEsaggsRequest }; }).pipe( switchMap(({ aggConfigs, indexPattern, searchSource, getNow, handleEsaggsRequest }) => { - const { disableShardWarnings } = getSearchContext(); + const { disableWarningToasts } = getSearchContext(); return handleEsaggsRequest({ abortSignal, @@ -74,7 +74,7 @@ export function getFunctionDefinition({ searchSourceService: searchSource, timeFields: args.timeFields, timeRange: get(input, 'timeRange', undefined), - disableShardWarnings: (disableShardWarnings || false) as boolean, + disableWarningToasts: disableWarningToasts ?? false, getNow, executionContext: getExecutionContext(), }); diff --git a/src/plugins/data/public/search/search_service.ts b/src/plugins/data/public/search/search_service.ts index 79229eaff91bff..46314256962433 100644 --- a/src/plugins/data/public/search/search_service.ts +++ b/src/plugins/data/public/search/search_service.ts @@ -243,7 +243,7 @@ export class SearchService implements Plugin { getConfig: uiSettings.get.bind(uiSettings), search, onResponse: (request, response, options) => { - if (!options.disableShardFailureWarning) { + if (!options.disableWarningToasts) { const { rawResponse } = response; handleWarnings({ diff --git a/src/plugins/data/server/search/expressions/esaggs.test.ts b/src/plugins/data/server/search/expressions/esaggs.test.ts index 9954fb2457968a..da903f6ff7101c 100644 --- a/src/plugins/data/server/search/expressions/esaggs.test.ts +++ b/src/plugins/data/server/search/expressions/esaggs.test.ts @@ -131,7 +131,7 @@ describe('esaggs expression function - server', () => { query: undefined, searchSessionId: 'abc123', searchSourceService: startDependencies.searchSource, - disableShardWarnings: false, + disableWarningToasts: false, timeFields: args.timeFields, timeRange: undefined, }); diff --git a/src/plugins/data/server/search/expressions/esaggs.ts b/src/plugins/data/server/search/expressions/esaggs.ts index eedd1db8d03080..2e1afc03509572 100644 --- a/src/plugins/data/server/search/expressions/esaggs.ts +++ b/src/plugins/data/server/search/expressions/esaggs.ts @@ -72,7 +72,7 @@ export function getFunctionDefinition({ query: get(input, 'query', undefined) as any, searchSessionId: getSearchSessionId(), searchSourceService: searchSource, - disableShardWarnings: false, + disableWarningToasts: false, timeFields: args.timeFields, timeRange: get(input, 'timeRange', undefined), }) diff --git a/src/plugins/discover/common/constants.ts b/src/plugins/discover/common/constants.ts index e80f9d2449ebc4..4e49d29cd6d4c6 100644 --- a/src/plugins/discover/common/constants.ts +++ b/src/plugins/discover/common/constants.ts @@ -17,7 +17,6 @@ export enum VIEW_MODE { AGGREGATED_LEVEL = 'aggregated', } -export const DISABLE_SHARD_FAILURE_WARNING = true; export const getDefaultRowsPerPage = (uiSettings: IUiSettingsClient): number => { return parseInt(uiSettings.get(SAMPLE_ROWS_PER_PAGE_SETTING), 10) || DEFAULT_ROWS_PER_PAGE; -}; +}; \ No newline at end of file diff --git a/src/plugins/discover/public/application/context/services/anchor.ts b/src/plugins/discover/public/application/context/services/anchor.ts index daf99030201a4f..f5d0f78a834415 100644 --- a/src/plugins/discover/public/application/context/services/anchor.ts +++ b/src/plugins/discover/public/application/context/services/anchor.ts @@ -17,7 +17,6 @@ import { type SearchResponseInterceptedWarning, } from '@kbn/search-response-warnings'; import type { DiscoverServices } from '../../../build_services'; -import { DISABLE_SHARD_FAILURE_WARNING } from '../../../../common/constants'; export async function fetchAnchor( anchorId: string, @@ -35,7 +34,7 @@ export async function fetchAnchor( const adapter = new RequestAdapter(); const { rawResponse } = await lastValueFrom( searchSource.fetch$({ - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, + disableWarningToasts: true, inspector: { adapter, title: 'anchor', @@ -56,9 +55,6 @@ export async function fetchAnchor( interceptedWarnings: getSearchResponseInterceptedWarnings({ services, adapter, - options: { - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, - }, }), }; } diff --git a/src/plugins/discover/public/application/context/utils/fetch_hits_in_interval.ts b/src/plugins/discover/public/application/context/utils/fetch_hits_in_interval.ts index c6fed56de4c19d..d9a06e08fbada2 100644 --- a/src/plugins/discover/public/application/context/utils/fetch_hits_in_interval.ts +++ b/src/plugins/discover/public/application/context/utils/fetch_hits_in_interval.ts @@ -17,7 +17,6 @@ import { import { RequestAdapter } from '@kbn/inspector-plugin/common'; import { convertTimeValueToIso } from './date_conversion'; import { IntervalValue } from './generate_intervals'; -import { DISABLE_SHARD_FAILURE_WARNING } from '../../../../common/constants'; import type { SurrDocType } from '../services/context'; import type { DiscoverServices } from '../../../build_services'; @@ -91,7 +90,7 @@ export async function fetchHitsInInterval( .setField('sort', sort) .setField('version', true) .fetch$({ - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, + disableWarningToasts: true, inspector: { adapter, title: type, @@ -107,9 +106,6 @@ export async function fetchHitsInInterval( interceptedWarnings: getSearchResponseInterceptedWarnings({ services, adapter, - options: { - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, - }, }), }; } diff --git a/src/plugins/discover/public/application/main/utils/fetch_documents.ts b/src/plugins/discover/public/application/main/utils/fetch_documents.ts index 892da705f4b8fe..e849b347a22fff 100644 --- a/src/plugins/discover/public/application/main/utils/fetch_documents.ts +++ b/src/plugins/discover/public/application/main/utils/fetch_documents.ts @@ -13,7 +13,6 @@ import { SAMPLE_SIZE_SETTING, buildDataTableRecordList } from '@kbn/discover-uti import type { EsHitRecord } from '@kbn/discover-utils/types'; import { getSearchResponseInterceptedWarnings } from '@kbn/search-response-warnings'; import type { RecordsFetchResponse } from '../../types'; -import { DISABLE_SHARD_FAILURE_WARNING } from '../../../../common/constants'; import { FetchDeps } from './fetch_all'; /** @@ -60,7 +59,7 @@ export const fetchDocuments = ( }), }, executionContext, - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, + disableWarningToasts: true, }) .pipe( filter((res) => isCompleteResponse(res)), @@ -75,9 +74,6 @@ export const fetchDocuments = ( ? getSearchResponseInterceptedWarnings({ services, adapter, - options: { - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, - }, }) : []; diff --git a/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx b/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx index 9a44ae3834f7c8..38698722e443d6 100644 --- a/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx +++ b/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx @@ -64,7 +64,6 @@ import type { UnifiedDataTableSettings } from '@kbn/unified-data-table'; import { columnActions } from '@kbn/unified-data-table'; import { VIEW_MODE, - DISABLE_SHARD_FAILURE_WARNING, getDefaultRowsPerPage, } from '../../common/constants'; import type { ISearchEmbeddable, SearchInput, SearchOutput } from './types'; @@ -371,7 +370,7 @@ export class SavedSearchEmbeddable }), }, executionContext, - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, + disableWarningToasts: true, }) ); @@ -379,9 +378,6 @@ export class SavedSearchEmbeddable searchProps.interceptedWarnings = getSearchResponseInterceptedWarnings({ services: this.services, adapter: this.inspectorAdapters.requests, - options: { - disableShardFailureWarning: DISABLE_SHARD_FAILURE_WARNING, - }, }); } diff --git a/src/plugins/unified_histogram/public/chart/hooks/use_total_hits.ts b/src/plugins/unified_histogram/public/chart/hooks/use_total_hits.ts index c260d3171697bd..2beed34b3d9193 100644 --- a/src/plugins/unified_histogram/public/chart/hooks/use_total_hits.ts +++ b/src/plugins/unified_histogram/public/chart/hooks/use_total_hits.ts @@ -206,7 +206,7 @@ const fetchTotalHitsSearchSource = async ({ executionContext: { description: 'fetch total hits', }, - disableShardFailureWarning: true, // TODO: show warnings as a badge next to total hits number + disableWarningToasts: true, // TODO: show warnings as a badge next to total hits number }) .pipe( filter((res) => isCompleteResponse(res)), diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx b/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx index 9d34d2fb26ca6a..c02b7a58577a94 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx @@ -582,7 +582,7 @@ export class VisualizeEmbeddable timeRange: this.timeRange, query: this.input.query, filters: this.input.filters, - disableShardWarnings: true, + disableWarningToasts: true, }, variables: { embeddableTitle: this.getTitle(), From 1385564e83e12b91afc18ec10ca722ada4386241 Mon Sep 17 00:00:00 2001 From: nreese Date: Fri, 1 Sep 2023 17:40:12 -0600 Subject: [PATCH 09/43] remove console.log --- .../src/utils/get_search_response_intercepted_warnings.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx index ac2c165ad43318..b5a7eb818166a4 100644 --- a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx +++ b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx @@ -58,7 +58,5 @@ export const getSearchResponseInterceptedWarnings = ({ return true; // suppress the default behaviour }); - console.log(interceptedWarnings); - return interceptedWarnings; }; From 47ca3f91d3bdb066d67915cd52a0a98033c95b99 Mon Sep 17 00:00:00 2001 From: nreese Date: Tue, 5 Sep 2023 08:53:28 -0600 Subject: [PATCH 10/43] tslint --- src/plugins/data/public/search/expressions/esaggs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/public/search/expressions/esaggs.ts b/src/plugins/data/public/search/expressions/esaggs.ts index 28a559bbe96544..5ae0b72e1fe581 100644 --- a/src/plugins/data/public/search/expressions/esaggs.ts +++ b/src/plugins/data/public/search/expressions/esaggs.ts @@ -74,7 +74,7 @@ export function getFunctionDefinition({ searchSourceService: searchSource, timeFields: args.timeFields, timeRange: get(input, 'timeRange', undefined), - disableWarningToasts: disableWarningToasts ?? false, + disableWarningToasts: (disableWarningToasts || false) as boolean, getNow, executionContext: getExecutionContext(), }); From 353c5288b5e193f42011a12379b7f9b27da8062f Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Sep 2023 15:27:15 +0000 Subject: [PATCH 11/43] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../src/utils/get_search_response_intercepted_warnings.tsx | 1 - src/plugins/discover/common/constants.ts | 2 +- .../discover/public/embeddable/saved_search_embeddable.tsx | 5 +---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx index b5a7eb818166a4..534883f5a7c0b6 100644 --- a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx +++ b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx @@ -7,7 +7,6 @@ */ import React from 'react'; -import { uniqBy } from 'lodash'; import { type DataPublicPluginStart, OpenIncompleteResultsModalButton, diff --git a/src/plugins/discover/common/constants.ts b/src/plugins/discover/common/constants.ts index 4e49d29cd6d4c6..8ac1280592ff68 100644 --- a/src/plugins/discover/common/constants.ts +++ b/src/plugins/discover/common/constants.ts @@ -19,4 +19,4 @@ export enum VIEW_MODE { export const getDefaultRowsPerPage = (uiSettings: IUiSettingsClient): number => { return parseInt(uiSettings.get(SAMPLE_ROWS_PER_PAGE_SETTING), 10) || DEFAULT_ROWS_PER_PAGE; -}; \ No newline at end of file +}; diff --git a/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx b/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx index 38698722e443d6..6b4856d3a298fd 100644 --- a/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx +++ b/src/plugins/discover/public/embeddable/saved_search_embeddable.tsx @@ -62,10 +62,7 @@ import { import type { UnifiedDataTableProps } from '@kbn/unified-data-table'; import type { UnifiedDataTableSettings } from '@kbn/unified-data-table'; import { columnActions } from '@kbn/unified-data-table'; -import { - VIEW_MODE, - getDefaultRowsPerPage, -} from '../../common/constants'; +import { VIEW_MODE, getDefaultRowsPerPage } from '../../common/constants'; import type { ISearchEmbeddable, SearchInput, SearchOutput } from './types'; import type { DiscoverServices } from '../build_services'; import { getSortForEmbeddable, SortPair } from '../utils/sorting'; From 1619d1748f35fef2e517c5bd981f68a5664ef6d0 Mon Sep 17 00:00:00 2001 From: nreese Date: Tue, 5 Sep 2023 10:44:16 -0600 Subject: [PATCH 12/43] tslint packages/kbn-search-response-warnings --- .../kbn-search-response-warnings/index.ts | 1 - .../src/__mocks__/search_response_warnings.ts | 66 ++-- .../search_response_warnings.test.tsx.snap | 346 +----------------- .../search_response_warnings.test.tsx | 10 +- ...rch_response_intercepted_warnings.test.tsx | 205 +++-------- ...t_search_response_intercepted_warnings.tsx | 3 +- 6 files changed, 93 insertions(+), 538 deletions(-) diff --git a/packages/kbn-search-response-warnings/index.ts b/packages/kbn-search-response-warnings/index.ts index 8ef18d86b9a927..b0f17338aa5081 100644 --- a/packages/kbn-search-response-warnings/index.ts +++ b/packages/kbn-search-response-warnings/index.ts @@ -15,5 +15,4 @@ export { export { getSearchResponseInterceptedWarnings, - removeInterceptedWarningDuplicates, } from './src/utils/get_search_response_intercepted_warnings'; diff --git a/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts b/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts index 9fe2cf02a16718..b1972a6c4bf4c1 100644 --- a/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts +++ b/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts @@ -8,43 +8,33 @@ import type { SearchResponseWarning } from '@kbn/data-plugin/public'; -export const searchResponseTimeoutWarningMock: SearchResponseWarning = { - type: 'timed_out', - message: 'Data might be incomplete because your request timed out', - reason: undefined, -}; - -export const searchResponseShardFailureWarningMock: SearchResponseWarning = { - type: 'shard_failure', - message: '3 of 4 shards failed', - text: 'The data might be incomplete or wrong.', - reason: { - type: 'illegal_argument_exception', - reason: 'Field [__anonymous_] of type [boolean] does not support custom formats', - }, -}; - -export const searchResponseWarningsMock: SearchResponseWarning[] = [ - searchResponseTimeoutWarningMock, - searchResponseShardFailureWarningMock, - { - type: 'shard_failure', - message: '3 of 4 shards failed', - text: 'The data might be incomplete or wrong.', - reason: { - type: 'query_shard_exception', - reason: - 'failed to create query: [.ds-kibana_sample_data_logs-2023.07.11-000001][0] Testing shard failures!', - }, - }, - { - type: 'shard_failure', - message: '1 of 4 shards failed', - text: 'The data might be incomplete or wrong.', - reason: { - type: 'query_shard_exception', - reason: - 'failed to create query: [.ds-kibana_sample_data_logs-2023.07.11-000001][0] Testing shard failures!', +export const searchResponseIncompleteWarningLocalCluster: SearchResponseWarning = { + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, + }, + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'illegal_argument_exception', + reason: + 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', + }, + }, + ], }, }, -]; +}; \ No newline at end of file diff --git a/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap b/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap index 01f917a0e6dbcd..6c5ac2eac1ceb2 100644 --- a/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap +++ b/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap @@ -13,7 +13,7 @@ exports[`SearchResponseWarnings renders "badge" correctly 1`] = ` @@ -68,238 +68,14 @@ exports[`SearchResponseWarnings renders "callout" correctly 1`] = ` class="euiText emotion-euiText-s" data-test-subj="test1_warningTitle" > - Data might be incomplete because your request timed out -
-
- - -
- -
- -

- - -

  • -
    -

    -

    -
    -
    -
    -
    -
    - - 3 of 4 shards failed - -
    -
    -
    -
    -

    - The data might be incomplete or wrong. -

    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -

    -

    -
  • -
  • -
    -

    -

    -
    -
    -
    -
    -
    - - 3 of 4 shards failed - -
    -
    -
    -
    -

    - The data might be incomplete or wrong. -

    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -

    -

    -
  • -
  • -
    -

    -

    -
    -
    -
    -
    -
    - - 1 of 4 shards failed - -
    -
    -
    -
    -

    - The data might be incomplete or wrong. -

    + The data might be incomplete or wrong.
    @@ -377,124 +153,14 @@ exports[`SearchResponseWarnings renders "empty_prompt" correctly 1`] = ` class="euiText emotion-euiText-m" data-test-subj="test3_warningTitle" > - Data might be incomplete because your request timed out -
    -
    -
    -
  • -
  • -
    -
    -
    - - 3 of 4 shards failed - -
    -
    -
    -
    -

    - The data might be incomplete or wrong. -

    -
    -
    -
    - -
    -
    -
  • -
  • -
    -
    -
    - - 3 of 4 shards failed - -
    -
    -
    -
    -

    - The data might be incomplete or wrong. -

    -
    -
    -
    - -
    -
    -
  • -
  • -
    -
    -
    - - 1 of 4 shards failed - -
    -
    -
    -
    -

    - The data might be incomplete or wrong. -

    + The data might be incomplete or wrong.
    diff --git a/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx b/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx index 6e3c1b1a0d08d6..fc1cdda4f41fc0 100644 --- a/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx +++ b/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx @@ -9,12 +9,12 @@ import React from 'react'; import { mountWithIntl } from '@kbn/test-jest-helpers'; import { SearchResponseWarnings } from './search_response_warnings'; -import { searchResponseWarningsMock } from '../../__mocks__/search_response_warnings'; +import { searchResponseIncompleteWarningLocalCluster } from '../../__mocks__/search_response_warnings'; -const interceptedWarnings = searchResponseWarningsMock.map((originalWarning, index) => ({ - originalWarning, - action: originalWarning.type === 'shard_failure' ? : undefined, -})); +const interceptedWarnings = [{ + originalWarning: searchResponseIncompleteWarningLocalCluster, + action: , +}]; describe('SearchResponseWarnings', () => { it('renders "callout" correctly', () => { diff --git a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.test.tsx b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.test.tsx index 34ae546f42ba6b..b6bf93169ae639 100644 --- a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.test.tsx +++ b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.test.tsx @@ -9,11 +9,8 @@ import { RequestAdapter } from '@kbn/inspector-plugin/common'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { coreMock } from '@kbn/core/public/mocks'; -import { - getSearchResponseInterceptedWarnings, - removeInterceptedWarningDuplicates, -} from './get_search_response_intercepted_warnings'; -import { searchResponseWarningsMock } from '../__mocks__/search_response_warnings'; +import { getSearchResponseInterceptedWarnings } from './get_search_response_intercepted_warnings'; +import { searchResponseIncompleteWarningLocalCluster } from '../__mocks__/search_response_warnings'; const servicesMock = { data: dataPluginMock.createStartContract(), @@ -23,162 +20,66 @@ const servicesMock = { describe('getSearchResponseInterceptedWarnings', () => { const adapter = new RequestAdapter(); - it('should catch warnings correctly', () => { + it('should return intercepted incomplete data warnings', () => { const services = { ...servicesMock, }; services.data.search.showWarnings = jest.fn((_, callback) => { // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[0], {}); - // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[1], {}); - // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[2], {}); - // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[3], {}); - - // plus duplicates - // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[0], {}); - // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[1], {}); - // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[2], {}); + callback?.(searchResponseIncompleteWarningLocalCluster, {}); }); - expect( - getSearchResponseInterceptedWarnings({ - services, - adapter, - options: { - disableShardFailureWarning: true, - }, - }) - ).toMatchInlineSnapshot(` - Array [ - Object { - "action": undefined, - "originalWarning": Object { - "message": "Data might be incomplete because your request timed out", - "reason": undefined, - "type": "timed_out", - }, - }, - Object { - "action": , - "originalWarning": Object { - "message": "3 of 4 shards failed", - "reason": Object { - "reason": "Field [__anonymous_] of type [boolean] does not support custom formats", - "type": "illegal_argument_exception", - }, - "text": "The data might be incomplete or wrong.", - "type": "shard_failure", - }, - }, - Object { - "action": , - "originalWarning": Object { - "message": "3 of 4 shards failed", - "reason": Object { - "reason": "failed to create query: [.ds-kibana_sample_data_logs-2023.07.11-000001][0] Testing shard failures!", - "type": "query_shard_exception", + const warnings = getSearchResponseInterceptedWarnings({ + services, + adapter, + }); + + expect(warnings.length).toBe(1); + expect(warnings[0].originalWarning).toEqual(searchResponseIncompleteWarningLocalCluster); + expect(warnings[0].action).toMatchInlineSnapshot(` + , - "originalWarning": Object { - "message": "1 of 4 shards failed", - "reason": Object { - "reason": "failed to create query: [.ds-kibana_sample_data_logs-2023.07.11-000001][0] Testing shard failures!", - "type": "query_shard_exception", + "failures": Array [ + Object { + "index": "sample-01-rollup", + "node": "VFTFJxpHSdaoiGxJFLSExQ", + "reason": Object { + "reason": "Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]", + "type": "illegal_argument_exception", + }, + "shard": 0, + }, + ], + "indices": "", + "status": "partial", + "timed_out": false, + "took": 25, + }, }, - "text": "The data might be incomplete or wrong.", - "type": "shard_failure", - }, - }, - ] + "message": "The data might be incomplete or wrong.", + "type": "incomplete", + } + } + /> `); }); - - it('should not catch any warnings if disableShardFailureWarning is false', () => { - const services = { - ...servicesMock, - }; - services.data.search.showWarnings = jest.fn((_, callback) => { - // @ts-expect-error for empty meta - callback?.(searchResponseWarningsMock[0], {}); - }); - expect( - getSearchResponseInterceptedWarnings({ - services, - adapter, - options: { - disableShardFailureWarning: false, - }, - }) - ).toBeUndefined(); - }); -}); - -describe('removeInterceptedWarningDuplicates', () => { - it('should remove duplicates successfully', () => { - const interceptedWarnings = searchResponseWarningsMock.map((originalWarning) => ({ - originalWarning, - })); - - expect(removeInterceptedWarningDuplicates([interceptedWarnings[0]])).toEqual([ - interceptedWarnings[0], - ]); - expect(removeInterceptedWarningDuplicates(interceptedWarnings)).toEqual(interceptedWarnings); - expect( - removeInterceptedWarningDuplicates([...interceptedWarnings, ...interceptedWarnings]) - ).toEqual(interceptedWarnings); - }); - - it('should return undefined if the list is empty', () => { - expect(removeInterceptedWarningDuplicates([])).toBeUndefined(); - expect(removeInterceptedWarningDuplicates(undefined)).toBeUndefined(); - }); }); diff --git a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx index 534883f5a7c0b6..6518d12109a1dc 100644 --- a/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx +++ b/packages/kbn-search-response-warnings/src/utils/get_search_response_intercepted_warnings.tsx @@ -24,14 +24,13 @@ import type { SearchResponseInterceptedWarning } from '../types'; export const getSearchResponseInterceptedWarnings = ({ services, adapter, - options, }: { services: { data: DataPublicPluginStart; theme: CoreStart['theme']; }; adapter: RequestAdapter; -}): SearchResponseInterceptedWarning[] | undefined => { +}): SearchResponseInterceptedWarning[] => { const interceptedWarnings: SearchResponseInterceptedWarning[] = []; services.data.search.showWarnings(adapter, (warning, meta) => { From d3e1b376fba5f59f1492c698b1bef75f1dec8e8f Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:52:15 +0000 Subject: [PATCH 13/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- packages/kbn-search-response-warnings/index.ts | 4 +--- .../src/__mocks__/search_response_warnings.ts | 2 +- .../search_response_warnings.test.tsx | 10 ++++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/kbn-search-response-warnings/index.ts b/packages/kbn-search-response-warnings/index.ts index b0f17338aa5081..c9d4087841933d 100644 --- a/packages/kbn-search-response-warnings/index.ts +++ b/packages/kbn-search-response-warnings/index.ts @@ -13,6 +13,4 @@ export { type SearchResponseWarningsProps, } from './src/components/search_response_warnings'; -export { - getSearchResponseInterceptedWarnings, -} from './src/utils/get_search_response_intercepted_warnings'; +export { getSearchResponseInterceptedWarnings } from './src/utils/get_search_response_intercepted_warnings'; diff --git a/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts b/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts index b1972a6c4bf4c1..d4110f1bb62b76 100644 --- a/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts +++ b/packages/kbn-search-response-warnings/src/__mocks__/search_response_warnings.ts @@ -37,4 +37,4 @@ export const searchResponseIncompleteWarningLocalCluster: SearchResponseWarning ], }, }, -}; \ No newline at end of file +}; diff --git a/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx b/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx index fc1cdda4f41fc0..ca51bd8babee85 100644 --- a/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx +++ b/packages/kbn-search-response-warnings/src/components/search_response_warnings/search_response_warnings.test.tsx @@ -11,10 +11,12 @@ import { mountWithIntl } from '@kbn/test-jest-helpers'; import { SearchResponseWarnings } from './search_response_warnings'; import { searchResponseIncompleteWarningLocalCluster } from '../../__mocks__/search_response_warnings'; -const interceptedWarnings = [{ - originalWarning: searchResponseIncompleteWarningLocalCluster, - action: , -}]; +const interceptedWarnings = [ + { + originalWarning: searchResponseIncompleteWarningLocalCluster, + action: , + }, +]; describe('SearchResponseWarnings', () => { it('renders "callout" correctly', () => { From f9ca751317c8cc5d1a8ac1391d84ed1ef4c9c271 Mon Sep 17 00:00:00 2001 From: nreese Date: Tue, 5 Sep 2023 12:50:52 -0600 Subject: [PATCH 14/43] update lens for incomplete warning --- .../kbn-search-response-warnings/index.ts | 1 + ...ed_downsampled_aggregation_failure.test.ts | 75 +++++++++++++++++++ ...pported_downsampled_aggregation_failure.ts | 21 ++++++ src/plugins/data/public/index.ts | 1 + .../datasources/form_based/form_based.tsx | 4 +- .../public/datasources/form_based/utils.tsx | 48 ++++++------ .../workspace_panel/workspace_panel.tsx | 2 +- .../lens/public/embeddable/embeddable.tsx | 2 +- .../lens/public/state_management/selectors.ts | 2 +- x-pack/plugins/lens/public/utils.ts | 15 ++-- x-pack/plugins/lens/tsconfig.json | 1 + 11 files changed, 131 insertions(+), 41 deletions(-) create mode 100644 packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts create mode 100644 packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts diff --git a/packages/kbn-search-response-warnings/index.ts b/packages/kbn-search-response-warnings/index.ts index c9d4087841933d..d81b3510553e63 100644 --- a/packages/kbn-search-response-warnings/index.ts +++ b/packages/kbn-search-response-warnings/index.ts @@ -14,3 +14,4 @@ export { } from './src/components/search_response_warnings'; export { getSearchResponseInterceptedWarnings } from './src/utils/get_search_response_intercepted_warnings'; +export { hasUnsupportedDownsampledAggregationFailure } from './src/utils/has_unsupported_downsampled_aggregation_failure'; diff --git a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts new file mode 100644 index 00000000000000..fb6b14a2027ee8 --- /dev/null +++ b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts @@ -0,0 +1,75 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { hasUnsupportedDownsampledAggregationFailure } from './has_unsupported_downsampled_aggregation_failure'; + +test('should return false when unsupported_aggregation_on_downsampled_index shard failure does not exist', () => { + expect(hasUnsupportedDownsampledAggregationFailure({ + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, + }, + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'illegal_argument_exception', + reason: + 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', + }, + }, + ], + }, + } + })).toBe(false); +}); + +test('should return true when unsupported_aggregation_on_downsampled_index shard failure exists', () => { + expect(hasUnsupportedDownsampledAggregationFailure({ + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, + }, + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'unsupported_aggregation_on_downsampled_index', + reason: + 'blah blah blah timeseries data', + }, + }, + ], + }, + } + })).toBe(true); +}); \ No newline at end of file diff --git a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts new file mode 100644 index 00000000000000..834664f4e31674 --- /dev/null +++ b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts @@ -0,0 +1,21 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { SearchResponseWarning, SearchResponseIncompleteWarning } from '@kbn/data-plugin/public'; + +export function hasUnsupportedDownsampledAggregationFailure(warning: SearchResponseWarning) { + return warning.type === 'incomplete' + ? Object.values((warning as SearchResponseIncompleteWarning).clusters).some((clusterDetails) => { + return clusterDetails.failures + ? clusterDetails.failures.some((shardFailure) => { + return shardFailure.reason?.type === 'unsupported_aggregation_on_downsampled_index'; + }) + : false; + }) + : false; +} \ No newline at end of file diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index cd998257d75d65..cba87c99bf9ae5 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -170,6 +170,7 @@ export type { Reason, WaitUntilNextSessionCompletesOptions, SearchResponseWarning, + SearchResponseIncompleteWarning, } from './search'; export { diff --git a/x-pack/plugins/lens/public/datasources/form_based/form_based.tsx b/x-pack/plugins/lens/public/datasources/form_based/form_based.tsx index 51ed27f328838c..88f6c67113bce4 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/form_based.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/form_based.tsx @@ -64,7 +64,7 @@ import { import { getFiltersInLayer, - getShardFailuresWarningMessages, + getSearchWarningMessages, getVisualDefaultsForLayer, isColumnInvalid, cloneLayer, @@ -811,7 +811,7 @@ export function getFormBasedDatasource({ }, getSearchWarningMessages: (state, warning, request, response) => { - return [...getShardFailuresWarningMessages(state, warning, request, response, core.theme)]; + return [...getSearchWarningMessages(state, warning, request, response, core.theme)]; }, checkIntegrity: (state, indexPatterns) => { diff --git a/x-pack/plugins/lens/public/datasources/form_based/utils.tsx b/x-pack/plugins/lens/public/datasources/form_based/utils.tsx index 33c60b89f3ce45..a5e66c0176395b 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/utils.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/utils.tsx @@ -9,6 +9,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import type { DocLinksStart, ThemeServiceStart } from '@kbn/core/public'; +import { hasUnsupportedDownsampledAggregationFailure } from '@kbn/search-response-warnings'; import type { DatatableUtilitiesService } from '@kbn/data-plugin/common'; import { TimeRange } from '@kbn/es-query'; import { EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; @@ -20,8 +21,7 @@ import { SearchRequest } from '@kbn/data-plugin/common'; import { SearchResponseWarning, - ShardFailureOpenModalButton, - ShardFailureRequest, + OpenIncompleteResultsModalButton, } from '@kbn/data-plugin/public'; import { estypes } from '@elastic/elasticsearch'; @@ -260,7 +260,7 @@ const accuracyModeEnabledWarning = ( ), }); -export function getShardFailuresWarningMessages( +export function getSearchWarningMessages( state: FormBasedPersistedState, warning: SearchResponseWarning, request: SearchRequest, @@ -268,10 +268,9 @@ export function getShardFailuresWarningMessages( theme: ThemeServiceStart ): UserMessage[] { if (state) { - if (warning.type === 'shard_failure') { - switch (warning.reason.type) { - case 'unsupported_aggregation_on_downsampled_index': - return Object.values(state.layers).flatMap((layer) => + if (warning.type === 'incomplete') { + return hasUnsupportedDownsampledAggregationFailure(warning) + ? Object.values(state.layers).flatMap((layer) => uniq( Object.values(layer.columns) .filter((col) => @@ -302,11 +301,10 @@ export function getShardFailuresWarningMessages( }), } as UserMessage) ) - ); - default: - return [ + ) + : [ { - uniqueId: `shard_failure`, + uniqueId: `incomplete`, severity: 'warning', fixableInEditor: true, displayLocations: [{ id: 'toolbar' }, { id: 'embeddableBadge' }], @@ -314,28 +312,24 @@ export function getShardFailuresWarningMessages( longMessage: ( <> - {warning.message} -

    {warning.text}

    + {warning.message}
    - {warning.text ? ( - ({ - request: request as ShardFailureRequest, - response, - })} - color="primary" - isButtonEmpty={true} - /> - ) : null} + ({ + request, + response, + })} + color="primary" + isButtonEmpty={true} + /> ), } as UserMessage, ]; - } } } return []; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 4e66763b54a947..6af4fe67c06223 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -729,7 +729,7 @@ export const VisualizationWrapper = ({ to: context.dateRange.toDate, }, filters: context.filters, - disableShardWarnings: true, + disableWarningToasts: true, }), [context] ); diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx index 67dea2f98231c4..67764b46f6609c 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx @@ -1196,7 +1196,7 @@ export class Embeddable this.savedVis.state.filters, this.savedVis.references ), - disableShardWarnings: true, + disableWarningToasts: true, }; if (input.query) { diff --git a/x-pack/plugins/lens/public/state_management/selectors.ts b/x-pack/plugins/lens/public/state_management/selectors.ts index 407aacba9e4a2f..6bf40638554f94 100644 --- a/x-pack/plugins/lens/public/state_management/selectors.ts +++ b/x-pack/plugins/lens/public/state_management/selectors.ts @@ -62,7 +62,7 @@ export const selectExecutionContextSearch = createSelector(selectExecutionContex to: res.dateRange.toDate, }, filters: res.filters, - disableShardWarnings: true, + disableWarningToasts: true, })); const selectInjectedDependencies = (_state: LensState, dependencies: unknown) => dependencies; diff --git a/x-pack/plugins/lens/public/utils.ts b/x-pack/plugins/lens/public/utils.ts index b1deface2cd774..90011c6bad7358 100644 --- a/x-pack/plugins/lens/public/utils.ts +++ b/x-pack/plugins/lens/public/utils.ts @@ -349,29 +349,26 @@ export const getSearchWarningMessages = ( searchService: ISearchStart; } ): UserMessage[] => { - const warningsMap: Map = new Map(); + const userMessages: UserMessage[] = []; deps.searchService.showWarnings(adapter, (warning, meta) => { - const { request, response, requestId } = meta; + const { request, response } = meta; - const warningMessages = datasource.getSearchWarningMessages?.( + const userMessagesFromWarning = datasource.getSearchWarningMessages?.( state, warning, request, response ); - if (warningMessages?.length) { - const key = (requestId ?? '') + warning.type + warning.reason?.type ?? ''; - if (!warningsMap.has(key)) { - warningsMap.set(key, warningMessages); - } + if (userMessagesFromWarning?.length) { + userMessages.push(...userMessagesFromWarning); return true; } return false; }); - return [...warningsMap.values()].flat(); + return userMessages; }; function getSafeLabel(label: string) { diff --git a/x-pack/plugins/lens/tsconfig.json b/x-pack/plugins/lens/tsconfig.json index 484734f1ae38fe..ca536dc187c3f6 100644 --- a/x-pack/plugins/lens/tsconfig.json +++ b/x-pack/plugins/lens/tsconfig.json @@ -86,6 +86,7 @@ "@kbn/content-management-utils", "@kbn/serverless", "@kbn/ebt-tools", + "@kbn/search-response-warnings", ], "exclude": [ "target/**/*", From 60452d835fa07314b37d80fe4bd44afbdad8df08 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:56:36 +0000 Subject: [PATCH 15/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- ...ed_downsampled_aggregation_failure.test.ts | 117 +++++++++--------- ...pported_downsampled_aggregation_failure.ts | 23 ++-- .../public/datasources/form_based/utils.tsx | 9 +- 3 files changed, 76 insertions(+), 73 deletions(-) diff --git a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts index fb6b14a2027ee8..f7c06017d16d84 100644 --- a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts +++ b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts @@ -9,67 +9,70 @@ import { hasUnsupportedDownsampledAggregationFailure } from './has_unsupported_downsampled_aggregation_failure'; test('should return false when unsupported_aggregation_on_downsampled_index shard failure does not exist', () => { - expect(hasUnsupportedDownsampledAggregationFailure({ - type: 'incomplete', - message: 'The data might be incomplete or wrong.', - clusters: { - '(local)': { - status: 'partial', - indices: '', - took: 25, - timed_out: false, - _shards: { - total: 4, - successful: 3, - skipped: 0, - failed: 1, - }, - failures: [ - { - shard: 0, - index: 'sample-01-rollup', - node: 'VFTFJxpHSdaoiGxJFLSExQ', - reason: { - type: 'illegal_argument_exception', - reason: - 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', - }, + expect( + hasUnsupportedDownsampledAggregationFailure({ + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, }, - ], + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'illegal_argument_exception', + reason: + 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', + }, + }, + ], + }, }, - } - })).toBe(false); + }) + ).toBe(false); }); test('should return true when unsupported_aggregation_on_downsampled_index shard failure exists', () => { - expect(hasUnsupportedDownsampledAggregationFailure({ - type: 'incomplete', - message: 'The data might be incomplete or wrong.', - clusters: { - '(local)': { - status: 'partial', - indices: '', - took: 25, - timed_out: false, - _shards: { - total: 4, - successful: 3, - skipped: 0, - failed: 1, - }, - failures: [ - { - shard: 0, - index: 'sample-01-rollup', - node: 'VFTFJxpHSdaoiGxJFLSExQ', - reason: { - type: 'unsupported_aggregation_on_downsampled_index', - reason: - 'blah blah blah timeseries data', - }, + expect( + hasUnsupportedDownsampledAggregationFailure({ + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, }, - ], + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'unsupported_aggregation_on_downsampled_index', + reason: 'blah blah blah timeseries data', + }, + }, + ], + }, }, - } - })).toBe(true); -}); \ No newline at end of file + }) + ).toBe(true); +}); diff --git a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts index 834664f4e31674..d6dcd4e1764983 100644 --- a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts +++ b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.ts @@ -6,16 +6,21 @@ * Side Public License, v 1. */ -import type { SearchResponseWarning, SearchResponseIncompleteWarning } from '@kbn/data-plugin/public'; +import type { + SearchResponseWarning, + SearchResponseIncompleteWarning, +} from '@kbn/data-plugin/public'; export function hasUnsupportedDownsampledAggregationFailure(warning: SearchResponseWarning) { return warning.type === 'incomplete' - ? Object.values((warning as SearchResponseIncompleteWarning).clusters).some((clusterDetails) => { - return clusterDetails.failures - ? clusterDetails.failures.some((shardFailure) => { - return shardFailure.reason?.type === 'unsupported_aggregation_on_downsampled_index'; - }) - : false; - }) + ? Object.values((warning as SearchResponseIncompleteWarning).clusters).some( + (clusterDetails) => { + return clusterDetails.failures + ? clusterDetails.failures.some((shardFailure) => { + return shardFailure.reason?.type === 'unsupported_aggregation_on_downsampled_index'; + }) + : false; + } + ) : false; -} \ No newline at end of file +} diff --git a/x-pack/plugins/lens/public/datasources/form_based/utils.tsx b/x-pack/plugins/lens/public/datasources/form_based/utils.tsx index a5e66c0176395b..73caafa33fc8ec 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/utils.tsx +++ b/x-pack/plugins/lens/public/datasources/form_based/utils.tsx @@ -19,10 +19,7 @@ import { groupBy, escape, uniq, uniqBy } from 'lodash'; import type { Query } from '@kbn/data-plugin/common'; import { SearchRequest } from '@kbn/data-plugin/common'; -import { - SearchResponseWarning, - OpenIncompleteResultsModalButton, -} from '@kbn/data-plugin/public'; +import { SearchResponseWarning, OpenIncompleteResultsModalButton } from '@kbn/data-plugin/public'; import { estypes } from '@elastic/elasticsearch'; import { isQueryValid } from '@kbn/visualization-ui-components'; @@ -311,9 +308,7 @@ export function getSearchWarningMessages( shortMessage: '', longMessage: ( <> - - {warning.message} - + {warning.message} Date: Tue, 5 Sep 2023 14:48:48 -0600 Subject: [PATCH 16/43] tslint visualizations plugin --- .../public/embeddable/visualize_embeddable.tsx | 11 ++++++----- src/plugins/visualizations/tsconfig.json | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx b/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx index c02b7a58577a94..bd4be893689633 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx @@ -19,6 +19,7 @@ import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { TimefilterContract } from '@kbn/data-plugin/public'; import type { DataView } from '@kbn/data-views-plugin/public'; import { Warnings } from '@kbn/charts-plugin/public'; +import { hasUnsupportedDownsampledAggregationFailure } from '@kbn/search-response-warnings'; import { Adapters, AttributeService, @@ -351,11 +352,11 @@ export class VisualizeEmbeddable this.deps .start() .plugins.data.search.showWarnings(this.getInspectorAdapters()!.requests!, (warning) => { - if ( - warning.type === 'shard_failure' && - warning.reason.type === 'unsupported_aggregation_on_downsampled_index' - ) { - warnings.push(warning.reason.reason || warning.message); + if (hasUnsupportedDownsampledAggregationFailure(warning)) { + warnings.push(i18n.translate('visualizations.embeddable.tsdbRollupWarning', { + defaultMessage: + 'Visualization uses a function that is unsupported by rolled up data. Select a different function or change the time range.', + })); return true; } if (this.vis.type.suppressWarnings?.()) { diff --git a/src/plugins/visualizations/tsconfig.json b/src/plugins/visualizations/tsconfig.json index e643d9fa1fd610..a835f3151c60c1 100644 --- a/src/plugins/visualizations/tsconfig.json +++ b/src/plugins/visualizations/tsconfig.json @@ -63,7 +63,8 @@ "@kbn/content-management-table-list-view", "@kbn/content-management-utils", "@kbn/serverless", - "@kbn/no-data-page-plugin" + "@kbn/no-data-page-plugin", + "@kbn/search-response-warnings" ], "exclude": [ "target/**/*", From 45868ce94cc5c2c6a7759f12bd985f0c4a4a1b40 Mon Sep 17 00:00:00 2001 From: nreese Date: Tue, 5 Sep 2023 15:11:30 -0600 Subject: [PATCH 17/43] i18n fixes --- .../translations/translations/fr-FR.json | 138 +++++++++--------- .../translations/translations/ja-JP.json | 138 +++++++++--------- .../translations/translations/zh-CN.json | 138 +++++++++--------- 3 files changed, 201 insertions(+), 213 deletions(-) diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index e320b5a24c8be6..6f1bae9fc1fd70 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -1317,7 +1317,6 @@ "data.search.aggs.rareTerms.aggTypesLabel": "Termes rares de {fieldName}", "data.search.es_search.queryTimeValue": "{queryTime} ms", "data.search.functions.geoBoundingBox.arguments.error": "Au moins un des groupes de paramètres suivants doit être fourni : {parameters}.", - "data.search.searchSource.fetch.shardsFailedNotificationMessage": "Échec de {shardsFailed} des {shardsTotal} partitions", "data.search.searchSource.indexPatternIdDescription": "ID dans l'index {kibanaIndexPattern}.", "data.search.searchSource.queryTimeValue": "{queryTime} ms", "data.search.searchSource.requestTimeValue": "{requestTime} ms", @@ -2064,7 +2063,6 @@ "data.search.searchSource.dataViewDescription": "La vue de données qui a été interrogée.", "data.search.searchSource.dataViewIdLabel": "ID de vue de données", "data.search.searchSource.dataViewLabel": "Vue de données", - "data.search.searchSource.fetch.requestTimedOutNotificationMessage": "Les données peuvent être incomplètes parce que votre requête est arrivée à échéance.", "data.search.searchSource.fetch.shardsFailedModal.close": "Fermer", "data.search.searchSource.fetch.shardsFailedModal.copyToClipboard": "Copier la réponse dans le presse-papiers", "data.search.searchSource.fetch.shardsFailedModal.showDetails": "Afficher les détails", @@ -2072,7 +2070,6 @@ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderResponse": "Réponse", "data.search.searchSource.fetch.shardsFailedModal.tabHeaderShardFailures": "Échecs de partition", "data.search.searchSource.fetch.shardsFailedModal.tableColReason": "Raison", - "data.search.searchSource.fetch.shardsFailedNotificationDescription": "Les données peuvent être incomplètes ou erronées.", "data.search.searchSource.hitsDescription": "Le nombre de documents renvoyés par la requête.", "data.search.searchSource.hitsLabel": "Résultats", "data.search.searchSource.hitsTotalDescription": "Le nombre de documents correspondant à la requête.", @@ -2299,36 +2296,7 @@ "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "Afficher les documents alentour", "discover.documentsAriaLabel": "Documents", "discover.documentsErrorTitle": "Erreur lors de la recherche", - "unifiedDocViewer.docView.table.actions.label": "Actions", - "unifiedDocViewer.docView.table.actions.open": "Actions ouvertes", - "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "Une ou plusieurs valeurs dans ce champ sont trop longues et ne peuvent pas être recherchées ni filtrées.", - "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "Ce champ comporte une ou plusieurs valeurs mal formées qui ne peuvent pas être recherchées ni filtrées.", - "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "Une ou plusieurs valeurs dans ce champ ont été ignorées par Elasticsearch et ne peuvent pas être recherchées ni filtrées.", - "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "La valeur dans ce champ est trop longue et ne peut pas être recherchée ni filtrée.", - "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "La valeur dans ce champ est mal formée et ne peut pas être recherchée ni filtrée.", - "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "La valeur dans ce champ a été ignorée par Elasticsearch et ne peut pas être recherchée ni filtrée.", - "unifiedDocViewer.docView.table.searchPlaceHolder": "Rechercher les noms de champs", - "unifiedDocViewer.docViews.json.jsonTitle": "JSON", - "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "Filtrer sur le champ", - "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "Filtrer sur le champ", - "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "Filtrer sur la valeur", - "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "Filtrer sur la valeur", - "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "Exclure la valeur", - "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "Exclure la valeur", - "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "Contient des valeurs ignorées", - "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "Valeur ignorée", - "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "Épingler le champ", - "unifiedDocViewer.docViews.table.pinFieldLabel": "Épingler le champ", "discover.docViews.table.scoreSortWarningTooltip": "Filtrez sur _score pour pouvoir récupérer les valeurs correspondantes.", - "unifiedDocViewer.docViews.table.tableTitle": "Tableau", - "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "Afficher/Masquer la colonne dans le tableau", - "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "Afficher/Masquer la colonne dans le tableau", - "unifiedDocViewer.fieldChooser.discoverField.name": "Afficher/Masquer les détails du champ", - "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "Impossible de filtrer sur les champs méta", - "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "Impossible de filtrer sur les champs scriptés", - "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "Les champs non indexés ou les valeurs ignorées ne peuvent pas être recherchés", - "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "Désépingler le champ", - "unifiedDocViewer.docViews.table.unpinFieldLabel": "Désépingler le champ", "discover.dropZoneTableLabel": "Abandonner la zone pour ajouter un champ en tant que colonne dans la table", "discover.dscTour.stepAddFields.imageAltText": "Dans la liste Champs disponibles, cliquez sur l'icône Plus pour afficher/masquer un champ dans le tableau de documents.", "discover.dscTour.stepAddFields.title": "Ajouter des champs dans le tableau", @@ -2349,13 +2317,8 @@ "discover.embeddable.search.displayName": "rechercher", "discover.errorCalloutShowErrorMessage": "Afficher les détails", "discover.fieldChooser.availableFieldsTooltip": "Champs disponibles pour l'affichage dans le tableau.", - "unifiedDocViewer.fieldChooser.discoverField.actions": "Actions", "discover.fieldChooser.discoverField.addFieldTooltip": "Ajouter le champ en tant que colonne", - "unifiedDocViewer.fieldChooser.discoverField.multiField": "champ multiple", - "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "Les champs multiples peuvent avoir plusieurs valeurs.", - "unifiedDocViewer.fieldChooser.discoverField.name": "Champ", "discover.fieldChooser.discoverField.removeFieldTooltip": "Supprimer le champ du tableau", - "unifiedDocViewer.fieldChooser.discoverField.value": "Valeur", "discover.goToDiscoverButtonText": "Aller à Discover", "discover.grid.flyout.documentNavigation": "Navigation dans le document", "discover.grid.flyout.toastColumnAdded": "La colonne \"{columnName}\" a été ajoutée.", @@ -2371,10 +2334,7 @@ "discover.inspectorRequestDescriptionDocument": "Cette requête interroge Elasticsearch afin de récupérer les documents.", "discover.invalidFiltersWarnToast.description": "Les références d'ID de la vue de données dans certains filtres appliqués diffèrent de la vue de données actuelle.", "discover.invalidFiltersWarnToast.title": "Références d'index différentes", - "unifiedDocViewer.json.codeEditorAriaLabel": "Affichage JSON en lecture seule d’un document Elasticsearch", - "unifiedDocViewer.json.copyToClipboardLabel": "Copier dans le presse-papiers", "discover.loadingDocuments": "Chargement des documents", - "unifiedDocViewer.loadingJSON": "Chargement de JSON", "discover.localMenu.alertsDescription": "Alertes", "discover.localMenu.fallbackReportTitle": "Recherche Discover sans titre", "discover.localMenu.inspectTitle": "Inspecter", @@ -2431,9 +2391,6 @@ "discover.serverLocatorExtension.titleFromLocatorUnknown": "Recherche inconnue", "discover.singleDocRoute.errorTitle": "Une erreur s'est produite", "discover.skipToBottomButtonLabel": "Atteindre la fin du tableau", - "unifiedDocViewer.sourceViewer.errorMessage": "Impossible de récupérer les données pour le moment. Actualisez l'onglet et réessayez.", - "unifiedDocViewer.sourceViewer.errorMessageTitle": "Une erreur s'est produite.", - "unifiedDocViewer.sourceViewer.refresh": "Actualiser", "discover.toggleSidebarAriaLabel": "Activer/Désactiver la barre latérale", "discover.topNav.openSearchPanel.manageSearchesButtonLabel": "Gérer les recherches", "discover.topNav.openSearchPanel.noSearchesFoundDescription": "Aucune recherche correspondante trouvée.", @@ -2450,6 +2407,73 @@ "discover.viewAlert.searchSourceErrorTitle": "Erreur lors de la récupération de la source de recherche", "discover.viewModes.document.label": "Documents", "discover.viewModes.fieldStatistics.label": "Statistiques de champ", + "discover.fieldNameIcons.binaryAriaLabel": "Binaire", + "discover.fieldNameIcons.booleanAriaLabel": "Booléen", + "discover.fieldNameIcons.conflictFieldAriaLabel": "Conflit", + "discover.fieldNameIcons.counterFieldAriaLabel": "Indicateur de compteur", + "discover.fieldNameIcons.dateFieldAriaLabel": "Date", + "discover.fieldNameIcons.dateRangeFieldAriaLabel": "Plage de dates", + "discover.fieldNameIcons.denseVectorFieldAriaLabel": "Vecteur dense", + "discover.fieldNameIcons.flattenedFieldAriaLabel": "Lissé", + "discover.fieldNameIcons.gaugeFieldAriaLabel": "Indicateur de jauge", + "discover.fieldNameIcons.geoPointFieldAriaLabel": "Point géographique", + "discover.fieldNameIcons.geoShapeFieldAriaLabel": "Forme géométrique", + "discover.fieldNameIcons.histogramFieldAriaLabel": "Histogramme", + "discover.fieldNameIcons.ipAddressFieldAriaLabel": "Adresse IP", + "discover.fieldNameIcons.ipRangeFieldAriaLabel": "Plage d'IP", + "discover.fieldNameIcons.keywordFieldAriaLabel": "Mot-clé", + "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", + "discover.fieldNameIcons.nestedFieldAriaLabel": "Imbriqué", + "discover.fieldNameIcons.numberFieldAriaLabel": "Nombre", + "discover.fieldNameIcons.pointFieldAriaLabel": "Point", + "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "Fonctionnalité de rang", + "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "Fonctionnalités de rang", + "discover.fieldNameIcons.recordAriaLabel": "Enregistrements", + "discover.fieldNameIcons.shapeFieldAriaLabel": "Forme", + "discover.fieldNameIcons.sourceFieldAriaLabel": "Champ source", + "discover.fieldNameIcons.stringFieldAriaLabel": "Chaîne", + "discover.fieldNameIcons.textFieldAriaLabel": "Texte", + "discover.fieldNameIcons.unknownFieldAriaLabel": "Champ inconnu", + "discover.fieldNameIcons.versionFieldAriaLabel": "Version", + "unifiedDocViewer.docView.table.actions.label": "Actions", + "unifiedDocViewer.docView.table.actions.open": "Actions ouvertes", + "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "Une ou plusieurs valeurs dans ce champ sont trop longues et ne peuvent pas être recherchées ni filtrées.", + "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "Ce champ comporte une ou plusieurs valeurs mal formées qui ne peuvent pas être recherchées ni filtrées.", + "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "Une ou plusieurs valeurs dans ce champ ont été ignorées par Elasticsearch et ne peuvent pas être recherchées ni filtrées.", + "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "La valeur dans ce champ est trop longue et ne peut pas être recherchée ni filtrée.", + "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "La valeur dans ce champ est mal formée et ne peut pas être recherchée ni filtrée.", + "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "La valeur dans ce champ a été ignorée par Elasticsearch et ne peut pas être recherchée ni filtrée.", + "unifiedDocViewer.docView.table.searchPlaceHolder": "Rechercher les noms de champs", + "unifiedDocViewer.docViews.json.jsonTitle": "JSON", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "Filtrer sur le champ", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "Filtrer sur le champ", + "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "Filtrer sur la valeur", + "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "Filtrer sur la valeur", + "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "Exclure la valeur", + "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "Exclure la valeur", + "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "Contient des valeurs ignorées", + "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "Valeur ignorée", + "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "Épingler le champ", + "unifiedDocViewer.docViews.table.pinFieldLabel": "Épingler le champ", + "unifiedDocViewer.docViews.table.tableTitle": "Tableau", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "Afficher/Masquer la colonne dans le tableau", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "Afficher/Masquer la colonne dans le tableau", + "unifiedDocViewer.fieldChooser.discoverField.name": "Champ", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "Impossible de filtrer sur les champs méta", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "Impossible de filtrer sur les champs scriptés", + "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "Les champs non indexés ou les valeurs ignorées ne peuvent pas être recherchés", + "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "Désépingler le champ", + "unifiedDocViewer.docViews.table.unpinFieldLabel": "Désépingler le champ", + "unifiedDocViewer.fieldChooser.discoverField.actions": "Actions", + "unifiedDocViewer.fieldChooser.discoverField.multiField": "champ multiple", + "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "Les champs multiples peuvent avoir plusieurs valeurs.", + "unifiedDocViewer.fieldChooser.discoverField.value": "Valeur", + "unifiedDocViewer.json.codeEditorAriaLabel": "Affichage JSON en lecture seule d’un document Elasticsearch", + "unifiedDocViewer.json.copyToClipboardLabel": "Copier dans le presse-papiers", + "unifiedDocViewer.loadingJSON": "Chargement de JSON", + "unifiedDocViewer.sourceViewer.errorMessage": "Impossible de récupérer les données pour le moment. Actualisez l'onglet et réessayez.", + "unifiedDocViewer.sourceViewer.errorMessageTitle": "Une erreur s'est produite.", + "unifiedDocViewer.sourceViewer.refresh": "Actualiser", "unifiedDataTable.tableHeader.timeFieldIconTooltipAriaLabel": "{timeFieldName} – Ce champ représente l'heure à laquelle les événements se sont produits.", "unifiedDataTable.searchGenerationWithDescription": "Tableau généré par la recherche {searchTitle}", "unifiedDataTable.searchGenerationWithDescriptionGrid": "Tableau généré par la recherche {searchTitle} ({searchDescription})", @@ -5685,34 +5709,6 @@ "unifiedFieldList.fieldNameDescription.textField": "Texte intégral tel que le corps d'un e-mail ou la description d'un produit.", "unifiedFieldList.fieldNameDescription.unknownField": "Champ inconnu", "unifiedFieldList.fieldNameDescription.versionField": "Versions des logiciels. Prend en charge les règles de priorité de la Gestion sémantique des versions.", - "discover.fieldNameIcons.binaryAriaLabel": "Binaire", - "discover.fieldNameIcons.booleanAriaLabel": "Booléen", - "discover.fieldNameIcons.conflictFieldAriaLabel": "Conflit", - "discover.fieldNameIcons.counterFieldAriaLabel": "Indicateur de compteur", - "discover.fieldNameIcons.dateFieldAriaLabel": "Date", - "discover.fieldNameIcons.dateRangeFieldAriaLabel": "Plage de dates", - "discover.fieldNameIcons.denseVectorFieldAriaLabel": "Vecteur dense", - "discover.fieldNameIcons.flattenedFieldAriaLabel": "Lissé", - "discover.fieldNameIcons.gaugeFieldAriaLabel": "Indicateur de jauge", - "discover.fieldNameIcons.geoPointFieldAriaLabel": "Point géographique", - "discover.fieldNameIcons.geoShapeFieldAriaLabel": "Forme géométrique", - "discover.fieldNameIcons.histogramFieldAriaLabel": "Histogramme", - "discover.fieldNameIcons.ipAddressFieldAriaLabel": "Adresse IP", - "discover.fieldNameIcons.ipRangeFieldAriaLabel": "Plage d'IP", - "discover.fieldNameIcons.keywordFieldAriaLabel": "Mot-clé", - "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", - "discover.fieldNameIcons.nestedFieldAriaLabel": "Imbriqué", - "discover.fieldNameIcons.numberFieldAriaLabel": "Nombre", - "discover.fieldNameIcons.pointFieldAriaLabel": "Point", - "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "Fonctionnalité de rang", - "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "Fonctionnalités de rang", - "discover.fieldNameIcons.recordAriaLabel": "Enregistrements", - "discover.fieldNameIcons.shapeFieldAriaLabel": "Forme", - "discover.fieldNameIcons.sourceFieldAriaLabel": "Champ source", - "discover.fieldNameIcons.stringFieldAriaLabel": "Chaîne", - "discover.fieldNameIcons.textFieldAriaLabel": "Texte", - "discover.fieldNameIcons.unknownFieldAriaLabel": "Champ inconnu", - "discover.fieldNameIcons.versionFieldAriaLabel": "Version", "unifiedFieldList.fieldNameSearch.filterByNameLabel": "Rechercher les noms de champs", "unifiedFieldList.fieldPopover.addExistsFilterLabel": "Filtrer sur le champ", "unifiedFieldList.fieldPopover.deleteFieldLabel": "Supprimer le champ de la vue de données", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 26fa98a750f8d6..78ad7515810bcc 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -1331,7 +1331,6 @@ "data.search.aggs.rareTerms.aggTypesLabel": "{fieldName}の希少な用語", "data.search.es_search.queryTimeValue": "{queryTime}ms", "data.search.functions.geoBoundingBox.arguments.error": "次のパラメーターのグループの1つ以上を指定する必要があります:{parameters}。", - "data.search.searchSource.fetch.shardsFailedNotificationMessage": "{shardsTotal}件中{shardsFailed}件のシャードでエラーが発生しました", "data.search.searchSource.indexPatternIdDescription": "{kibanaIndexPattern}インデックス内のIDです。", "data.search.searchSource.queryTimeValue": "{queryTime}ms", "data.search.searchSource.requestTimeValue": "{requestTime}ms", @@ -2078,7 +2077,6 @@ "data.search.searchSource.dataViewDescription": "照会されたデータビュー。", "data.search.searchSource.dataViewIdLabel": "データビューID", "data.search.searchSource.dataViewLabel": "データビュー", - "data.search.searchSource.fetch.requestTimedOutNotificationMessage": "リクエストがタイムアウトしたため、データが不完全な可能性があります", "data.search.searchSource.fetch.shardsFailedModal.close": "閉じる", "data.search.searchSource.fetch.shardsFailedModal.copyToClipboard": "応答をクリップボードにコピー", "data.search.searchSource.fetch.shardsFailedModal.showDetails": "詳細を表示", @@ -2086,7 +2084,6 @@ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderResponse": "応答", "data.search.searchSource.fetch.shardsFailedModal.tabHeaderShardFailures": "シャードエラー", "data.search.searchSource.fetch.shardsFailedModal.tableColReason": "理由", - "data.search.searchSource.fetch.shardsFailedNotificationDescription": "データが不完全か誤りの可能性があります。", "data.search.searchSource.hitsDescription": "クエリにより返されたドキュメントの数です。", "data.search.searchSource.hitsLabel": "ヒット数", "data.search.searchSource.hitsTotalDescription": "クエリに一致するドキュメントの数です。", @@ -2314,36 +2311,7 @@ "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "周りのドキュメントを表示", "discover.documentsAriaLabel": "ドキュメント", "discover.documentsErrorTitle": "検索エラー", - "unifiedDocViewer.docView.table.actions.label": "アクション", - "unifiedDocViewer.docView.table.actions.open": "アクションを開く", - "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "このフィールドの1つ以上の値が長すぎるため、検索またはフィルタリングできません。", - "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "このフィールドは、検索またはフィルタリングできない正しくない形式の値が1つ以上あります。", - "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "このフィールドの1つ以上の値がElasticsearchによって無視されたため、検索またはフィルタリングできません。", - "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "このフィールドの値が長すぎるため、検索またはフィルタリングできません。", - "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "このフィールドの値の形式が正しくないため、検索またはフィルタリングできません。", - "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "このフィールドの値はElasticsearchによって無視されたため、検索またはフィルタリングできません。", - "unifiedDocViewer.docView.table.searchPlaceHolder": "検索フィールド名", - "unifiedDocViewer.docViews.json.jsonTitle": "JSON", - "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "フィールド表示のフィルター", - "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "フィールド表示のフィルター", - "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "値でフィルター", - "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "値でフィルター", - "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "値を除外", - "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "値を除外", - "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "無視された値を含む", - "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "無視された値", - "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "フィールドを固定", - "unifiedDocViewer.docViews.table.pinFieldLabel": "フィールドを固定", "discover.docViews.table.scoreSortWarningTooltip": "_scoreの値を取得するには、並べ替える必要があります。", - "unifiedDocViewer.docViews.table.tableTitle": "表", - "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "表の列を切り替える", - "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "表の列を切り替える", - "unifiedDocViewer.fieldChooser.discoverField.name": "フィールド詳細を切り替える", - "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "メタフィールドの有無でフィルタリングできません", - "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "スクリプトフィールドの有無でフィルタリングできません", - "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "インデックスがないフィールドまたは無視された値は検索できません", - "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "フィールドを固定解除", - "unifiedDocViewer.docViews.table.unpinFieldLabel": "フィールドを固定解除", "discover.dropZoneTableLabel": "フィールドを列として表に追加するには、ゾーンをドロップします", "discover.dscTour.stepAddFields.imageAltText": "[使用可能なフィールド]リストで、プラスアイコンをクリックし、フィールドをドキュメントテーブルに切り替えます。", "discover.dscTour.stepAddFields.title": "フィールドをテーブルに追加", @@ -2364,13 +2332,8 @@ "discover.embeddable.search.displayName": "検索", "discover.errorCalloutShowErrorMessage": "詳細を表示", "discover.fieldChooser.availableFieldsTooltip": "フィールドをテーブルに表示できます。", - "unifiedDocViewer.fieldChooser.discoverField.actions": "アクション", "discover.fieldChooser.discoverField.addFieldTooltip": "フィールドを列として追加", - "unifiedDocViewer.fieldChooser.discoverField.multiField": "複数フィールド", - "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "複数フィールドにはフィールドごとに複数の値を入力できます", - "unifiedDocViewer.fieldChooser.discoverField.name": "フィールド", "discover.fieldChooser.discoverField.removeFieldTooltip": "フィールドを表から削除", - "unifiedDocViewer.fieldChooser.discoverField.value": "値", "discover.goToDiscoverButtonText": "Discoverに移動", "discover.grid.flyout.documentNavigation": "ドキュメントナビゲーション", "discover.grid.flyout.toastColumnAdded": "列'{columnName}'が追加されました", @@ -2386,10 +2349,7 @@ "discover.inspectorRequestDescriptionDocument": "このリクエストはElasticsearchにクエリをかけ、ドキュメントを取得します。", "discover.invalidFiltersWarnToast.description": "一部の適用されたフィルターのデータビューID参照は、現在のデータビューとは異なります。", "discover.invalidFiltersWarnToast.title": "別のインデックス参照", - "unifiedDocViewer.json.codeEditorAriaLabel": "Elasticsearch ドキュメントの JSON ビューのみを読み込む", - "unifiedDocViewer.json.copyToClipboardLabel": "クリップボードにコピー", "discover.loadingDocuments": "ドキュメントを読み込み中", - "unifiedDocViewer.loadingJSON": "JSONを読み込んでいます", "discover.localMenu.alertsDescription": "アラート", "discover.localMenu.fallbackReportTitle": "無題のDiscover検索", "discover.localMenu.inspectTitle": "検査", @@ -2446,9 +2406,6 @@ "discover.serverLocatorExtension.titleFromLocatorUnknown": "不明な検索", "discover.singleDocRoute.errorTitle": "エラーが発生しました", "discover.skipToBottomButtonLabel": "テーブルの最後に移動", - "unifiedDocViewer.sourceViewer.errorMessage": "現在データを取得できませんでした。タブを更新して、再試行してください。", - "unifiedDocViewer.sourceViewer.errorMessageTitle": "エラーが発生しました", - "unifiedDocViewer.sourceViewer.refresh": "更新", "discover.toggleSidebarAriaLabel": "サイドバーを切り替える", "discover.topNav.openSearchPanel.manageSearchesButtonLabel": "検索の管理", "discover.topNav.openSearchPanel.noSearchesFoundDescription": "一致する検索が見つかりませんでした。", @@ -2465,6 +2422,73 @@ "discover.viewAlert.searchSourceErrorTitle": "検索ソースの取得エラー", "discover.viewModes.document.label": "ドキュメント", "discover.viewModes.fieldStatistics.label": "フィールド統計情報", + "discover.fieldNameIcons.binaryAriaLabel": "バイナリー", + "discover.fieldNameIcons.booleanAriaLabel": "ブール", + "discover.fieldNameIcons.conflictFieldAriaLabel": "競合", + "discover.fieldNameIcons.counterFieldAriaLabel": "カウンターメトリック", + "discover.fieldNameIcons.dateFieldAriaLabel": "日付", + "discover.fieldNameIcons.dateRangeFieldAriaLabel": "日付範囲", + "discover.fieldNameIcons.denseVectorFieldAriaLabel": "密集ベクトル", + "discover.fieldNameIcons.flattenedFieldAriaLabel": "平坦化済み", + "discover.fieldNameIcons.gaugeFieldAriaLabel": "ゲージメトリック", + "discover.fieldNameIcons.geoPointFieldAriaLabel": "地理ポイント", + "discover.fieldNameIcons.geoShapeFieldAriaLabel": "地理情報図形", + "discover.fieldNameIcons.histogramFieldAriaLabel": "ヒストグラム", + "discover.fieldNameIcons.ipAddressFieldAriaLabel": "IP アドレス", + "discover.fieldNameIcons.ipRangeFieldAriaLabel": "IP範囲", + "discover.fieldNameIcons.keywordFieldAriaLabel": "キーワード", + "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", + "discover.fieldNameIcons.nestedFieldAriaLabel": "ネスト済み", + "discover.fieldNameIcons.numberFieldAriaLabel": "数字", + "discover.fieldNameIcons.pointFieldAriaLabel": "点", + "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "ランク特性", + "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "ランク特性", + "discover.fieldNameIcons.recordAriaLabel": "記録", + "discover.fieldNameIcons.shapeFieldAriaLabel": "形状", + "discover.fieldNameIcons.sourceFieldAriaLabel": "ソースフィールド", + "discover.fieldNameIcons.stringFieldAriaLabel": "文字列", + "discover.fieldNameIcons.textFieldAriaLabel": "テキスト", + "discover.fieldNameIcons.unknownFieldAriaLabel": "不明なフィールド", + "discover.fieldNameIcons.versionFieldAriaLabel": "バージョン", + "unifiedDocViewer.docView.table.actions.label": "アクション", + "unifiedDocViewer.docView.table.actions.open": "アクションを開く", + "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "このフィールドの1つ以上の値が長すぎるため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "このフィールドは、検索またはフィルタリングできない正しくない形式の値が1つ以上あります。", + "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "このフィールドの1つ以上の値がElasticsearchによって無視されたため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "このフィールドの値が長すぎるため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "このフィールドの値の形式が正しくないため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "このフィールドの値はElasticsearchによって無視されたため、検索またはフィルタリングできません。", + "unifiedDocViewer.docView.table.searchPlaceHolder": "検索フィールド名", + "unifiedDocViewer.docViews.json.jsonTitle": "JSON", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "フィールド表示のフィルター", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "フィールド表示のフィルター", + "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "値でフィルター", + "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "値でフィルター", + "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "値を除外", + "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "値を除外", + "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "無視された値を含む", + "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "無視された値", + "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "フィールドを固定", + "unifiedDocViewer.docViews.table.pinFieldLabel": "フィールドを固定", + "unifiedDocViewer.docViews.table.tableTitle": "表", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "表の列を切り替える", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "表の列を切り替える", + "unifiedDocViewer.fieldChooser.discoverField.name": "フィールド", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "メタフィールドの有無でフィルタリングできません", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "スクリプトフィールドの有無でフィルタリングできません", + "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "インデックスがないフィールドまたは無視された値は検索できません", + "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "フィールドを固定解除", + "unifiedDocViewer.docViews.table.unpinFieldLabel": "フィールドを固定解除", + "unifiedDocViewer.fieldChooser.discoverField.actions": "アクション", + "unifiedDocViewer.fieldChooser.discoverField.multiField": "複数フィールド", + "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "複数フィールドにはフィールドごとに複数の値を入力できます", + "unifiedDocViewer.fieldChooser.discoverField.value": "値", + "unifiedDocViewer.json.codeEditorAriaLabel": "Elasticsearch ドキュメントの JSON ビューのみを読み込む", + "unifiedDocViewer.json.copyToClipboardLabel": "クリップボードにコピー", + "unifiedDocViewer.loadingJSON": "JSONを読み込んでいます", + "unifiedDocViewer.sourceViewer.errorMessage": "現在データを取得できませんでした。タブを更新して、再試行してください。", + "unifiedDocViewer.sourceViewer.errorMessageTitle": "エラーが発生しました", + "unifiedDocViewer.sourceViewer.refresh": "更新", "unifiedDataTable.tableHeader.timeFieldIconTooltipAriaLabel": "{timeFieldName} - このフィールドはイベントの発生時刻を表します。", "unifiedDataTable.searchGenerationWithDescription": "検索{searchTitle}で生成されたテーブル", "unifiedDataTable.searchGenerationWithDescriptionGrid": "検索{searchTitle}で生成されたテーブル({searchDescription})", @@ -5701,34 +5725,6 @@ "unifiedFieldList.fieldNameDescription.textField": "電子メール本文や製品説明などの全文テキスト。", "unifiedFieldList.fieldNameDescription.unknownField": "不明なフィールド", "unifiedFieldList.fieldNameDescription.versionField": "ソフトウェアバージョン。「セマンティックバージョニング」優先度ルールをサポートします。", - "discover.fieldNameIcons.binaryAriaLabel": "バイナリー", - "discover.fieldNameIcons.booleanAriaLabel": "ブール", - "discover.fieldNameIcons.conflictFieldAriaLabel": "競合", - "discover.fieldNameIcons.counterFieldAriaLabel": "カウンターメトリック", - "discover.fieldNameIcons.dateFieldAriaLabel": "日付", - "discover.fieldNameIcons.dateRangeFieldAriaLabel": "日付範囲", - "discover.fieldNameIcons.denseVectorFieldAriaLabel": "密集ベクトル", - "discover.fieldNameIcons.flattenedFieldAriaLabel": "平坦化済み", - "discover.fieldNameIcons.gaugeFieldAriaLabel": "ゲージメトリック", - "discover.fieldNameIcons.geoPointFieldAriaLabel": "地理ポイント", - "discover.fieldNameIcons.geoShapeFieldAriaLabel": "地理情報図形", - "discover.fieldNameIcons.histogramFieldAriaLabel": "ヒストグラム", - "discover.fieldNameIcons.ipAddressFieldAriaLabel": "IP アドレス", - "discover.fieldNameIcons.ipRangeFieldAriaLabel": "IP範囲", - "discover.fieldNameIcons.keywordFieldAriaLabel": "キーワード", - "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", - "discover.fieldNameIcons.nestedFieldAriaLabel": "ネスト済み", - "discover.fieldNameIcons.numberFieldAriaLabel": "数字", - "discover.fieldNameIcons.pointFieldAriaLabel": "点", - "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "ランク特性", - "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "ランク特性", - "discover.fieldNameIcons.recordAriaLabel": "記録", - "discover.fieldNameIcons.shapeFieldAriaLabel": "形状", - "discover.fieldNameIcons.sourceFieldAriaLabel": "ソースフィールド", - "discover.fieldNameIcons.stringFieldAriaLabel": "文字列", - "discover.fieldNameIcons.textFieldAriaLabel": "テキスト", - "discover.fieldNameIcons.unknownFieldAriaLabel": "不明なフィールド", - "discover.fieldNameIcons.versionFieldAriaLabel": "バージョン", "unifiedFieldList.fieldNameSearch.filterByNameLabel": "検索フィールド名", "unifiedFieldList.fieldPopover.addExistsFilterLabel": "フィールド表示のフィルター", "unifiedFieldList.fieldPopover.deleteFieldLabel": "データビューフィールドを削除", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index e96481d6944855..1457d0a01a2146 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -1331,7 +1331,6 @@ "data.search.aggs.rareTerms.aggTypesLabel": "{fieldName} 的稀有词", "data.search.es_search.queryTimeValue": "{queryTime}ms", "data.search.functions.geoBoundingBox.arguments.error": "必须至少提供一个以下参数组:{parameters}。", - "data.search.searchSource.fetch.shardsFailedNotificationMessage": "{shardsTotal} 个分片有 {shardsFailed} 个失败", "data.search.searchSource.indexPatternIdDescription": "{kibanaIndexPattern} 索引中的 ID。", "data.search.searchSource.queryTimeValue": "{queryTime}ms", "data.search.searchSource.requestTimeValue": "{requestTime}ms", @@ -2078,7 +2077,6 @@ "data.search.searchSource.dataViewDescription": "被查询的数据视图。", "data.search.searchSource.dataViewIdLabel": "数据视图 ID", "data.search.searchSource.dataViewLabel": "数据视图", - "data.search.searchSource.fetch.requestTimedOutNotificationMessage": "由于您的请求超时,数据可能不完整", "data.search.searchSource.fetch.shardsFailedModal.close": "关闭", "data.search.searchSource.fetch.shardsFailedModal.copyToClipboard": "将响应复制到剪贴板", "data.search.searchSource.fetch.shardsFailedModal.showDetails": "显示详情", @@ -2086,7 +2084,6 @@ "data.search.searchSource.fetch.shardsFailedModal.tabHeaderResponse": "响应", "data.search.searchSource.fetch.shardsFailedModal.tabHeaderShardFailures": "分片错误", "data.search.searchSource.fetch.shardsFailedModal.tableColReason": "原因", - "data.search.searchSource.fetch.shardsFailedNotificationDescription": "数据可能不完整或有错误。", "data.search.searchSource.hitsDescription": "查询返回的文档数目。", "data.search.searchSource.hitsLabel": "命中数", "data.search.searchSource.hitsTotalDescription": "与查询匹配的文档数目。", @@ -2314,36 +2311,7 @@ "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "查看周围文档", "discover.documentsAriaLabel": "文档", "discover.documentsErrorTitle": "搜索错误", - "unifiedDocViewer.docView.table.actions.label": "操作", - "unifiedDocViewer.docView.table.actions.open": "打开操作", - "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "此字段中的一个或多个值过长,无法搜索或筛选。", - "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "此字段包含一个或多个格式错误的值,无法搜索或筛选。", - "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "此字段中的一个或多个值被 Elasticsearch 忽略,无法搜索或筛选。", - "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "此字段中的值过长,无法搜索或筛选。", - "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "此字段中的值格式错误,无法搜索或筛选。", - "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "此字段中的值被 Elasticsearch 忽略,无法搜索或筛选。", - "unifiedDocViewer.docView.table.searchPlaceHolder": "搜索字段名称", - "unifiedDocViewer.docViews.json.jsonTitle": "JSON", - "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "筛留存在的字段", - "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "字段是否存在筛选", - "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "筛留值", - "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "筛留值", - "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "筛除值", - "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "筛除值", - "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "包含被忽略的值", - "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "被忽略的值", - "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "固定字段", - "unifiedDocViewer.docViews.table.pinFieldLabel": "固定字段", "discover.docViews.table.scoreSortWarningTooltip": "要检索 _score 的值,必须按其筛选。", - "unifiedDocViewer.docViews.table.tableTitle": "表", - "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "在表中切换列", - "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "在表中切换列", - "unifiedDocViewer.fieldChooser.discoverField.name": "切换字段详细信息", - "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "无法筛选元数据字段是否存在", - "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "无法筛选脚本字段是否存在", - "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "无法搜索未编入索引的字段或被忽略的值", - "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "取消固定字段", - "unifiedDocViewer.docViews.table.unpinFieldLabel": "取消固定字段", "discover.dropZoneTableLabel": "放置区域以将字段作为列添加到表中", "discover.dscTour.stepAddFields.imageAltText": "在可用字段列表中,单击加号图标将字段切换为文档表。", "discover.dscTour.stepAddFields.title": "将字段添加到表中", @@ -2364,13 +2332,8 @@ "discover.embeddable.search.displayName": "搜索", "discover.errorCalloutShowErrorMessage": "显示详情", "discover.fieldChooser.availableFieldsTooltip": "适用于在表中显示的字段。", - "unifiedDocViewer.fieldChooser.discoverField.actions": "操作", "discover.fieldChooser.discoverField.addFieldTooltip": "将字段添加为列", - "unifiedDocViewer.fieldChooser.discoverField.multiField": "多字段", - "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "多字段的每个字段可以有多个值", - "unifiedDocViewer.fieldChooser.discoverField.name": "字段", "discover.fieldChooser.discoverField.removeFieldTooltip": "从表中移除字段", - "unifiedDocViewer.fieldChooser.discoverField.value": "值", "discover.goToDiscoverButtonText": "前往 Discover", "discover.grid.flyout.documentNavigation": "文档导航", "discover.grid.flyout.toastColumnAdded": "已添加列“{columnName}”", @@ -2386,10 +2349,7 @@ "discover.inspectorRequestDescriptionDocument": "此请求将查询 Elasticsearch 以获取文档。", "discover.invalidFiltersWarnToast.description": "某些应用的筛选中的数据视图 ID 引用与当前数据视图不同。", "discover.invalidFiltersWarnToast.title": "不同的索引引用", - "unifiedDocViewer.json.codeEditorAriaLabel": "Elasticsearch 文档的只读 JSON 视图", - "unifiedDocViewer.json.copyToClipboardLabel": "复制到剪贴板", "discover.loadingDocuments": "正在加载文档", - "unifiedDocViewer.loadingJSON": "正在加载 JSON", "discover.localMenu.alertsDescription": "告警", "discover.localMenu.fallbackReportTitle": "未命名 Discover 搜索", "discover.localMenu.inspectTitle": "检查", @@ -2446,9 +2406,6 @@ "discover.serverLocatorExtension.titleFromLocatorUnknown": "未知搜索", "discover.singleDocRoute.errorTitle": "发生错误", "discover.skipToBottomButtonLabel": "转到表尾", - "unifiedDocViewer.sourceViewer.errorMessage": "当前无法获取数据。请刷新选项卡以重试。", - "unifiedDocViewer.sourceViewer.errorMessageTitle": "发生错误", - "unifiedDocViewer.sourceViewer.refresh": "刷新", "discover.toggleSidebarAriaLabel": "切换侧边栏", "discover.topNav.openSearchPanel.manageSearchesButtonLabel": "管理搜索", "discover.topNav.openSearchPanel.noSearchesFoundDescription": "未找到匹配的搜索。", @@ -2465,6 +2422,73 @@ "discover.viewAlert.searchSourceErrorTitle": "提取搜索源时出错", "discover.viewModes.document.label": "文档", "discover.viewModes.fieldStatistics.label": "字段统计信息", + "discover.fieldNameIcons.binaryAriaLabel": "二进制", + "discover.fieldNameIcons.booleanAriaLabel": "布尔型", + "discover.fieldNameIcons.conflictFieldAriaLabel": "冲突", + "discover.fieldNameIcons.counterFieldAriaLabel": "计数器指标", + "discover.fieldNameIcons.dateFieldAriaLabel": "日期", + "discover.fieldNameIcons.dateRangeFieldAriaLabel": "日期范围", + "discover.fieldNameIcons.denseVectorFieldAriaLabel": "密集向量", + "discover.fieldNameIcons.flattenedFieldAriaLabel": "扁平", + "discover.fieldNameIcons.gaugeFieldAriaLabel": "仪表盘指标", + "discover.fieldNameIcons.geoPointFieldAriaLabel": "地理点", + "discover.fieldNameIcons.geoShapeFieldAriaLabel": "几何形状", + "discover.fieldNameIcons.histogramFieldAriaLabel": "直方图", + "discover.fieldNameIcons.ipAddressFieldAriaLabel": "IP 地址", + "discover.fieldNameIcons.ipRangeFieldAriaLabel": "IP 范围", + "discover.fieldNameIcons.keywordFieldAriaLabel": "关键字", + "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", + "discover.fieldNameIcons.nestedFieldAriaLabel": "嵌套", + "discover.fieldNameIcons.numberFieldAriaLabel": "数字", + "discover.fieldNameIcons.pointFieldAriaLabel": "点", + "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "排名特征", + "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "排名特征", + "discover.fieldNameIcons.recordAriaLabel": "记录", + "discover.fieldNameIcons.shapeFieldAriaLabel": "形状", + "discover.fieldNameIcons.sourceFieldAriaLabel": "源字段", + "discover.fieldNameIcons.stringFieldAriaLabel": "字符串", + "discover.fieldNameIcons.textFieldAriaLabel": "文本", + "discover.fieldNameIcons.unknownFieldAriaLabel": "未知字段", + "discover.fieldNameIcons.versionFieldAriaLabel": "版本", + "unifiedDocViewer.docView.table.actions.label": "操作", + "unifiedDocViewer.docView.table.actions.open": "打开操作", + "unifiedDocViewer.docView.table.ignored.multiAboveTooltip": "此字段中的一个或多个值过长,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.multiMalformedTooltip": "此字段包含一个或多个格式错误的值,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.multiUnknownTooltip": "此字段中的一个或多个值被 Elasticsearch 忽略,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.singleAboveTooltip": "此字段中的值过长,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.singleMalformedTooltip": "此字段中的值格式错误,无法搜索或筛选。", + "unifiedDocViewer.docView.table.ignored.singleUnknownTooltip": "此字段中的值被 Elasticsearch 忽略,无法搜索或筛选。", + "unifiedDocViewer.docView.table.searchPlaceHolder": "搜索字段名称", + "unifiedDocViewer.docViews.json.jsonTitle": "JSON", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonAriaLabel": "筛留存在的字段", + "unifiedDocViewer.docViews.table.filterForFieldPresentButtonTooltip": "字段是否存在筛选", + "unifiedDocViewer.docViews.table.filterForValueButtonAriaLabel": "筛留值", + "unifiedDocViewer.docViews.table.filterForValueButtonTooltip": "筛留值", + "unifiedDocViewer.docViews.table.filterOutValueButtonAriaLabel": "筛除值", + "unifiedDocViewer.docViews.table.filterOutValueButtonTooltip": "筛除值", + "unifiedDocViewer.docViews.table.ignored.multiValueLabel": "包含被忽略的值", + "unifiedDocViewer.docViews.table.ignored.singleValueLabel": "被忽略的值", + "unifiedDocViewer.docViews.table.pinFieldAriaLabel": "固定字段", + "unifiedDocViewer.docViews.table.pinFieldLabel": "固定字段", + "unifiedDocViewer.docViews.table.tableTitle": "表", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonAriaLabel": "在表中切换列", + "unifiedDocViewer.docViews.table.toggleColumnInTableButtonTooltip": "在表中切换列", + "unifiedDocViewer.fieldChooser.discoverField.name": "字段", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfMetaFieldsTooltip": "无法筛选元数据字段是否存在", + "unifiedDocViewer.docViews.table.unableToFilterForPresenceOfScriptedFieldsTooltip": "无法筛选脚本字段是否存在", + "unifiedDocViewer.docViews.table.unindexedFieldsCanNotBeSearchedTooltip": "无法搜索未编入索引的字段或被忽略的值", + "unifiedDocViewer.docViews.table.unpinFieldAriaLabel": "取消固定字段", + "unifiedDocViewer.docViews.table.unpinFieldLabel": "取消固定字段", + "unifiedDocViewer.fieldChooser.discoverField.actions": "操作", + "unifiedDocViewer.fieldChooser.discoverField.multiField": "多字段", + "unifiedDocViewer.fieldChooser.discoverField.multiFieldTooltipContent": "多字段的每个字段可以有多个值", + "unifiedDocViewer.fieldChooser.discoverField.value": "值", + "unifiedDocViewer.json.codeEditorAriaLabel": "Elasticsearch 文档的只读 JSON 视图", + "unifiedDocViewer.json.copyToClipboardLabel": "复制到剪贴板", + "unifiedDocViewer.loadingJSON": "正在加载 JSON", + "unifiedDocViewer.sourceViewer.errorMessage": "当前无法获取数据。请刷新选项卡以重试。", + "unifiedDocViewer.sourceViewer.errorMessageTitle": "发生错误", + "unifiedDocViewer.sourceViewer.refresh": "刷新", "unifiedDataTable.tableHeader.timeFieldIconTooltipAriaLabel": "{timeFieldName} - 此字段表示事件发生的时间。", "unifiedDataTable.searchGenerationWithDescription": "搜索 {searchTitle} 生成的表", "unifiedDataTable.searchGenerationWithDescriptionGrid": "搜索 {searchTitle} 生成的表({searchDescription})", @@ -5700,34 +5724,6 @@ "unifiedFieldList.fieldNameDescription.textField": "全文本,如电子邮件正文或产品描述。", "unifiedFieldList.fieldNameDescription.unknownField": "未知字段", "unifiedFieldList.fieldNameDescription.versionField": "软件版本。支持“语义版本控制”优先规则。", - "discover.fieldNameIcons.binaryAriaLabel": "二进制", - "discover.fieldNameIcons.booleanAriaLabel": "布尔型", - "discover.fieldNameIcons.conflictFieldAriaLabel": "冲突", - "discover.fieldNameIcons.counterFieldAriaLabel": "计数器指标", - "discover.fieldNameIcons.dateFieldAriaLabel": "日期", - "discover.fieldNameIcons.dateRangeFieldAriaLabel": "日期范围", - "discover.fieldNameIcons.denseVectorFieldAriaLabel": "密集向量", - "discover.fieldNameIcons.flattenedFieldAriaLabel": "扁平", - "discover.fieldNameIcons.gaugeFieldAriaLabel": "仪表盘指标", - "discover.fieldNameIcons.geoPointFieldAriaLabel": "地理点", - "discover.fieldNameIcons.geoShapeFieldAriaLabel": "几何形状", - "discover.fieldNameIcons.histogramFieldAriaLabel": "直方图", - "discover.fieldNameIcons.ipAddressFieldAriaLabel": "IP 地址", - "discover.fieldNameIcons.ipRangeFieldAriaLabel": "IP 范围", - "discover.fieldNameIcons.keywordFieldAriaLabel": "关键字", - "discover.fieldNameIcons.murmur3FieldAriaLabel": "Murmur3", - "discover.fieldNameIcons.nestedFieldAriaLabel": "嵌套", - "discover.fieldNameIcons.numberFieldAriaLabel": "数字", - "discover.fieldNameIcons.pointFieldAriaLabel": "点", - "discover.fieldNameIcons.rankFeatureFieldAriaLabel": "排名特征", - "discover.fieldNameIcons.rankFeaturesFieldAriaLabel": "排名特征", - "discover.fieldNameIcons.recordAriaLabel": "记录", - "discover.fieldNameIcons.shapeFieldAriaLabel": "形状", - "discover.fieldNameIcons.sourceFieldAriaLabel": "源字段", - "discover.fieldNameIcons.stringFieldAriaLabel": "字符串", - "discover.fieldNameIcons.textFieldAriaLabel": "文本", - "discover.fieldNameIcons.unknownFieldAriaLabel": "未知字段", - "discover.fieldNameIcons.versionFieldAriaLabel": "版本", "unifiedFieldList.fieldNameSearch.filterByNameLabel": "搜索字段名称", "unifiedFieldList.fieldPopover.addExistsFilterLabel": "筛留存在的字段", "unifiedFieldList.fieldPopover.deleteFieldLabel": "删除数据视图字段", From ee013d67994079704b9a4ebbd36bd54f0d64b386 Mon Sep 17 00:00:00 2001 From: nreese Date: Tue, 5 Sep 2023 15:56:39 -0600 Subject: [PATCH 18/43] round 1 of tslint discover --- .../public/application/context/context_app.tsx | 5 ++--- .../hooks/use_context_app_fetch.test.tsx | 18 +++++++++--------- .../application/context/services/context.ts | 7 ++----- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/plugins/discover/public/application/context/context_app.tsx b/src/plugins/discover/public/application/context/context_app.tsx index 19a50586383920..6320597593ac25 100644 --- a/src/plugins/discover/public/application/context/context_app.tsx +++ b/src/plugins/discover/public/application/context/context_app.tsx @@ -17,7 +17,6 @@ import { useExecutionContext } from '@kbn/kibana-react-plugin/public'; import { generateFilters } from '@kbn/data-plugin/public'; import { i18n } from '@kbn/i18n'; import { reportPerformanceMetricEvent } from '@kbn/ebt-tools'; -import { removeInterceptedWarningDuplicates } from '@kbn/search-response-warnings'; import { DOC_TABLE_LEGACY, SEARCH_FIELDS_FROM_SOURCE, @@ -177,11 +176,11 @@ export const ContextApp = ({ dataView, anchorId, referrer }: ContextAppProps) => const interceptedWarnings = useMemo( () => - removeInterceptedWarningDuplicates([ + [ ...(fetchedState.predecessorsInterceptedWarnings || []), ...(fetchedState.anchorInterceptedWarnings || []), ...(fetchedState.successorsInterceptedWarnings || []), - ]), + ], [ fetchedState.predecessorsInterceptedWarnings, fetchedState.anchorInterceptedWarnings, diff --git a/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx b/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx index 9ff64165f0f248..46e608f7061916 100644 --- a/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx +++ b/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx @@ -19,15 +19,15 @@ import { mockSuccessorHits, } from '../__mocks__/use_context_app_fetch'; import { dataViewWithTimefieldMock } from '../../../__mocks__/data_view_with_timefield'; -import { searchResponseWarningsMock } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; +import { searchResponseIncompleteWarningLocalCluster } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; import { createContextSearchSourceStub } from '../services/_stubs'; import { DataView } from '@kbn/data-views-plugin/public'; import { themeServiceMock } from '@kbn/core/public/mocks'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; -const mockInterceptedWarnings = searchResponseWarningsMock.map((originalWarning) => ({ - originalWarning, -})); +const mockInterceptedWarning = { + originalWarning: searchResponseIncompleteWarningLocalCluster +}; const mockFilterManager = createFilterManagerMock(); @@ -45,7 +45,7 @@ jest.mock('../services/context', () => { return { rows: type === 'predecessors' ? mockPredecessorHits : mockSuccessorHits, interceptedWarnings: mockOverrideInterceptedWarnings - ? [mockInterceptedWarnings[type === 'predecessors' ? 0 : 1]] + ? [mockInterceptedWarning] : undefined, }; }, @@ -60,7 +60,7 @@ jest.mock('../services/anchor', () => ({ return { anchorRow: mockAnchorHit, interceptedWarnings: mockOverrideInterceptedWarnings - ? [mockInterceptedWarnings[2]] + ? [mockInterceptedWarning] : undefined, }; }, @@ -228,13 +228,13 @@ describe('test useContextAppFetch', () => { expect(result.current.fetchedState.predecessors).toEqual(mockPredecessorHits); expect(result.current.fetchedState.successors).toEqual(mockSuccessorHits); expect(result.current.fetchedState.predecessorsInterceptedWarnings).toEqual([ - mockInterceptedWarnings[0], + mockInterceptedWarning ]); expect(result.current.fetchedState.successorsInterceptedWarnings).toEqual([ - mockInterceptedWarnings[1], + mockInterceptedWarning ]); expect(result.current.fetchedState.anchorInterceptedWarnings).toEqual([ - mockInterceptedWarnings[2], + mockInterceptedWarning ]); }); }); diff --git a/src/plugins/discover/public/application/context/services/context.ts b/src/plugins/discover/public/application/context/services/context.ts index df473563948215..67a477a8b9a03d 100644 --- a/src/plugins/discover/public/application/context/services/context.ts +++ b/src/plugins/discover/public/application/context/services/context.ts @@ -9,10 +9,7 @@ import type { Filter } from '@kbn/es-query'; import { DataView } from '@kbn/data-views-plugin/public'; import { DataPublicPluginStart, ISearchSource } from '@kbn/data-plugin/public'; import type { DataTableRecord } from '@kbn/discover-utils/types'; -import { - removeInterceptedWarningDuplicates, - type SearchResponseInterceptedWarning, -} from '@kbn/search-response-warnings'; +import type { SearchResponseInterceptedWarning } from '@kbn/search-response-warnings'; import { reverseSortDir, SortDirection } from '../utils/sorting'; import { convertIsoToMillis, extractNanos } from '../utils/date_conversion'; import { fetchHitsInInterval } from '../utils/fetch_hits_in_interval'; @@ -126,7 +123,7 @@ export async function fetchSurroundingDocs( return { rows, - interceptedWarnings: removeInterceptedWarningDuplicates(interceptedWarnings), + interceptedWarnings, }; } From 243464b3d66eef4bd9d9918f535f3b5d530a53df Mon Sep 17 00:00:00 2001 From: nreese Date: Tue, 5 Sep 2023 17:16:40 -0600 Subject: [PATCH 19/43] tslint discover --- .../context/services/anchor.test.ts | 18 ++++-------------- .../hooks/use_saved_search_messages.test.ts | 16 ++++++++-------- .../application/main/utils/fetch_all.test.ts | 8 ++++---- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/plugins/discover/public/application/context/services/anchor.test.ts b/src/plugins/discover/public/application/context/services/anchor.test.ts index 415b468f38afdd..3d05586dc59f56 100644 --- a/src/plugins/discover/public/application/context/services/anchor.test.ts +++ b/src/plugins/discover/public/application/context/services/anchor.test.ts @@ -10,7 +10,7 @@ import { SortDirection } from '@kbn/data-plugin/public'; import { createSearchSourceStub } from './_stubs'; import { fetchAnchor, updateSearchSource } from './anchor'; import { dataViewMock } from '@kbn/discover-utils/src/__mocks__'; -import { searchResponseTimeoutWarningMock } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; +import { searchResponseIncompleteWarningLocalCluster } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; import { savedSearchMock } from '../../../__mocks__/saved_search'; import { discoverServiceMock } from '../../../__mocks__/services'; @@ -206,7 +206,7 @@ describe('context app', function () { ).then(({ anchorRow, interceptedWarnings }) => { expect(anchorRow).toHaveProperty('raw._id', '1'); expect(anchorRow).toHaveProperty('isAnchor', true); - expect(interceptedWarnings).toBeUndefined(); + expect(interceptedWarnings).toEqual([]); }); }); @@ -216,20 +216,10 @@ describe('context app', function () { { _id: '3', _index: 't' }, ]); - const mockWarnings = [ - { - originalWarning: searchResponseTimeoutWarningMock, - }, - ]; - const services = discoverServiceMock; services.data.search.showWarnings = jest.fn((adapter, callback) => { // @ts-expect-error for empty meta - callback?.(mockWarnings[0].originalWarning, {}); - - // plus duplicates - // @ts-expect-error for empty meta - callback?.(mockWarnings[0].originalWarning, {}); + callback?.(searchResponseIncompleteWarningLocalCluster, {}); }); return fetchAnchor( @@ -242,7 +232,7 @@ describe('context app', function () { ).then(({ anchorRow, interceptedWarnings }) => { expect(anchorRow).toHaveProperty('raw._id', '1'); expect(anchorRow).toHaveProperty('isAnchor', true); - expect(interceptedWarnings).toEqual(mockWarnings); + expect(interceptedWarnings.length).toBe(1); }); }); }); diff --git a/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts b/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts index 7b96c2673f3eb0..6e7461151832cf 100644 --- a/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts +++ b/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts @@ -26,7 +26,7 @@ import { import { filter } from 'rxjs/operators'; import { dataViewMock, esHitsMockWithSort } from '@kbn/discover-utils/src/__mocks__'; import { buildDataTableRecord } from '@kbn/discover-utils'; -import { searchResponseWarningsMock } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; +import { searchResponseIncompleteWarningLocalCluster } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; describe('test useSavedSearch message generators', () => { test('sendCompleteMsg', (done) => { @@ -103,15 +103,15 @@ describe('test useSavedSearch message generators', () => { if (value.fetchStatus !== FetchStatus.LOADING_MORE) { expect(value.fetchStatus).toBe(FetchStatus.COMPLETE); expect(value.result).toStrictEqual([...initialRecords, ...moreRecords]); - expect(value.interceptedWarnings).toHaveLength(searchResponseWarningsMock.length); + expect(value.interceptedWarnings).toHaveLength(1); done(); } }); sendLoadingMoreFinishedMsg(documents$, { moreRecords, - interceptedWarnings: searchResponseWarningsMock.map((warning) => ({ - originalWarning: warning, - })), + interceptedWarnings: [ + { originalWarning: searchResponseIncompleteWarningLocalCluster } + ], }); }); test('sendLoadingMoreFinishedMsg after an exception', (done) => { @@ -121,9 +121,9 @@ describe('test useSavedSearch message generators', () => { const documents$ = new BehaviorSubject({ fetchStatus: FetchStatus.LOADING_MORE, result: initialRecords, - interceptedWarnings: searchResponseWarningsMock.map((warning) => ({ - originalWarning: warning, - })), + interceptedWarnings: [ + { originalWarning: searchResponseIncompleteWarningLocalCluster } + ], }); documents$.subscribe((value) => { if (value.fetchStatus !== FetchStatus.LOADING_MORE) { diff --git a/src/plugins/discover/public/application/main/utils/fetch_all.test.ts b/src/plugins/discover/public/application/main/utils/fetch_all.test.ts index ba8a09e17e3d1f..ec346e6abf3e24 100644 --- a/src/plugins/discover/public/application/main/utils/fetch_all.test.ts +++ b/src/plugins/discover/public/application/main/utils/fetch_all.test.ts @@ -25,7 +25,7 @@ import { fetchDocuments } from './fetch_documents'; import { fetchTextBased } from './fetch_text_based'; import { buildDataTableRecord } from '@kbn/discover-utils'; import { dataViewMock, esHitsMockWithSort } from '@kbn/discover-utils/src/__mocks__'; -import { searchResponseWarningsMock } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; +import { searchResponseIncompleteWarningLocalCluster } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; jest.mock('./fetch_documents', () => ({ fetchDocuments: jest.fn().mockResolvedValue([]), @@ -296,9 +296,9 @@ describe('test fetchAll', () => { const initialRecords = [records[0], records[1]]; const moreRecords = [records[2], records[3]]; - const interceptedWarnings = searchResponseWarningsMock.map((warning) => ({ - originalWarning: warning, - })); + const interceptedWarnings = [{ + originalWarning: searchResponseIncompleteWarningLocalCluster, + }]; test('should add more records', async () => { const collectDocuments = subjectCollector(subjects.documents$); From c3ce686c86fde4ed49144353e690d29b56451f14 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Sep 2023 23:21:11 +0000 Subject: [PATCH 20/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../main/hooks/use_saved_search_messages.test.ts | 8 ++------ .../public/application/main/utils/fetch_all.test.ts | 8 +++++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts b/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts index 6e7461151832cf..80fe8b99202276 100644 --- a/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts +++ b/src/plugins/discover/public/application/main/hooks/use_saved_search_messages.test.ts @@ -109,9 +109,7 @@ describe('test useSavedSearch message generators', () => { }); sendLoadingMoreFinishedMsg(documents$, { moreRecords, - interceptedWarnings: [ - { originalWarning: searchResponseIncompleteWarningLocalCluster } - ], + interceptedWarnings: [{ originalWarning: searchResponseIncompleteWarningLocalCluster }], }); }); test('sendLoadingMoreFinishedMsg after an exception', (done) => { @@ -121,9 +119,7 @@ describe('test useSavedSearch message generators', () => { const documents$ = new BehaviorSubject({ fetchStatus: FetchStatus.LOADING_MORE, result: initialRecords, - interceptedWarnings: [ - { originalWarning: searchResponseIncompleteWarningLocalCluster } - ], + interceptedWarnings: [{ originalWarning: searchResponseIncompleteWarningLocalCluster }], }); documents$.subscribe((value) => { if (value.fetchStatus !== FetchStatus.LOADING_MORE) { diff --git a/src/plugins/discover/public/application/main/utils/fetch_all.test.ts b/src/plugins/discover/public/application/main/utils/fetch_all.test.ts index ec346e6abf3e24..6de9781b0b58bd 100644 --- a/src/plugins/discover/public/application/main/utils/fetch_all.test.ts +++ b/src/plugins/discover/public/application/main/utils/fetch_all.test.ts @@ -296,9 +296,11 @@ describe('test fetchAll', () => { const initialRecords = [records[0], records[1]]; const moreRecords = [records[2], records[3]]; - const interceptedWarnings = [{ - originalWarning: searchResponseIncompleteWarningLocalCluster, - }]; + const interceptedWarnings = [ + { + originalWarning: searchResponseIncompleteWarningLocalCluster, + }, + ]; test('should add more records', async () => { const collectDocuments = subjectCollector(subjects.documents$); From 95dae5e55476d0647ea1c012970de8ade5d6a147 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Sep 2023 23:53:22 +0000 Subject: [PATCH 21/43] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../public/application/context/context_app.tsx | 11 +++++------ .../hooks/use_context_app_fetch.test.tsx | 18 ++++++------------ .../public/embeddable/visualize_embeddable.tsx | 10 ++++++---- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/plugins/discover/public/application/context/context_app.tsx b/src/plugins/discover/public/application/context/context_app.tsx index 6320597593ac25..2a50821f85081f 100644 --- a/src/plugins/discover/public/application/context/context_app.tsx +++ b/src/plugins/discover/public/application/context/context_app.tsx @@ -175,12 +175,11 @@ export const ContextApp = ({ dataView, anchorId, referrer }: ContextAppProps) => ); const interceptedWarnings = useMemo( - () => - [ - ...(fetchedState.predecessorsInterceptedWarnings || []), - ...(fetchedState.anchorInterceptedWarnings || []), - ...(fetchedState.successorsInterceptedWarnings || []), - ], + () => [ + ...(fetchedState.predecessorsInterceptedWarnings || []), + ...(fetchedState.anchorInterceptedWarnings || []), + ...(fetchedState.successorsInterceptedWarnings || []), + ], [ fetchedState.predecessorsInterceptedWarnings, fetchedState.anchorInterceptedWarnings, diff --git a/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx b/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx index 46e608f7061916..db0243e7f4ccf4 100644 --- a/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx +++ b/src/plugins/discover/public/application/context/hooks/use_context_app_fetch.test.tsx @@ -26,7 +26,7 @@ import { themeServiceMock } from '@kbn/core/public/mocks'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; const mockInterceptedWarning = { - originalWarning: searchResponseIncompleteWarningLocalCluster + originalWarning: searchResponseIncompleteWarningLocalCluster, }; const mockFilterManager = createFilterManagerMock(); @@ -44,9 +44,7 @@ jest.mock('../services/context', () => { } return { rows: type === 'predecessors' ? mockPredecessorHits : mockSuccessorHits, - interceptedWarnings: mockOverrideInterceptedWarnings - ? [mockInterceptedWarning] - : undefined, + interceptedWarnings: mockOverrideInterceptedWarnings ? [mockInterceptedWarning] : undefined, }; }, }; @@ -59,9 +57,7 @@ jest.mock('../services/anchor', () => ({ } return { anchorRow: mockAnchorHit, - interceptedWarnings: mockOverrideInterceptedWarnings - ? [mockInterceptedWarning] - : undefined, + interceptedWarnings: mockOverrideInterceptedWarnings ? [mockInterceptedWarning] : undefined, }; }, })); @@ -228,13 +224,11 @@ describe('test useContextAppFetch', () => { expect(result.current.fetchedState.predecessors).toEqual(mockPredecessorHits); expect(result.current.fetchedState.successors).toEqual(mockSuccessorHits); expect(result.current.fetchedState.predecessorsInterceptedWarnings).toEqual([ - mockInterceptedWarning + mockInterceptedWarning, ]); expect(result.current.fetchedState.successorsInterceptedWarnings).toEqual([ - mockInterceptedWarning - ]); - expect(result.current.fetchedState.anchorInterceptedWarnings).toEqual([ - mockInterceptedWarning + mockInterceptedWarning, ]); + expect(result.current.fetchedState.anchorInterceptedWarnings).toEqual([mockInterceptedWarning]); }); }); diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx b/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx index bd4be893689633..735c5e6572d43c 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable.tsx @@ -353,10 +353,12 @@ export class VisualizeEmbeddable .start() .plugins.data.search.showWarnings(this.getInspectorAdapters()!.requests!, (warning) => { if (hasUnsupportedDownsampledAggregationFailure(warning)) { - warnings.push(i18n.translate('visualizations.embeddable.tsdbRollupWarning', { - defaultMessage: - 'Visualization uses a function that is unsupported by rolled up data. Select a different function or change the time range.', - })); + warnings.push( + i18n.translate('visualizations.embeddable.tsdbRollupWarning', { + defaultMessage: + 'Visualization uses a function that is unsupported by rolled up data. Select a different function or change the time range.', + }) + ); return true; } if (this.vis.type.suppressWarnings?.()) { From a69611b0d1ddafa404c34ae9f546f28ea7e9379e Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 08:10:46 -0600 Subject: [PATCH 22/43] tslint --- examples/search_examples/public/search/app.tsx | 2 +- .../discover/public/application/context/services/anchor.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/search_examples/public/search/app.tsx b/examples/search_examples/public/search/app.tsx index 0fa13df35a4e96..803afb95d0e9f2 100644 --- a/examples/search_examples/public/search/app.tsx +++ b/examples/search_examples/public/search/app.tsx @@ -311,7 +311,7 @@ export const SearchExamplesApp = ({ const result = await lastValueFrom( searchSource.fetch$({ abortSignal: abortController.signal, - disableShardFailureWarning: !showWarningToastNotifications, + disableWarningToasts: !showWarningToastNotifications, inspector, }) ); diff --git a/src/plugins/discover/public/application/context/services/anchor.test.ts b/src/plugins/discover/public/application/context/services/anchor.test.ts index 3d05586dc59f56..deb5a0ed5ca7a2 100644 --- a/src/plugins/discover/public/application/context/services/anchor.test.ts +++ b/src/plugins/discover/public/application/context/services/anchor.test.ts @@ -232,7 +232,7 @@ describe('context app', function () { ).then(({ anchorRow, interceptedWarnings }) => { expect(anchorRow).toHaveProperty('raw._id', '1'); expect(anchorRow).toHaveProperty('isAnchor', true); - expect(interceptedWarnings.length).toBe(1); + expect(interceptedWarnings?.length).toBe(1); }); }); }); From 201681fd9beaf8fc5094f0ed8ee288e995dea07e Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 08:47:09 -0600 Subject: [PATCH 23/43] fix jest tests --- .../data/public/search/search_service.test.ts | 2 +- .../services/context.successors.test.ts | 26 +++---------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/plugins/data/public/search/search_service.test.ts b/src/plugins/data/public/search/search_service.test.ts index 3b82c140582bbf..784a41a2995037 100644 --- a/src/plugins/data/public/search/search_service.test.ts +++ b/src/plugins/data/public/search/search_service.test.ts @@ -142,7 +142,7 @@ describe('Search service', () => { expect(notifications.toasts.addWarning).toBeCalledTimes(1); expect(notifications.toasts.addWarning).toBeCalledWith({ - title: '2 of 4 shards failed', + title: 'The data might be incomplete or wrong.', text: expect.any(Function), }); }); diff --git a/src/plugins/discover/public/application/context/services/context.successors.test.ts b/src/plugins/discover/public/application/context/services/context.successors.test.ts index 9c2a0120c2a72a..54037a7071f069 100644 --- a/src/plugins/discover/public/application/context/services/context.successors.test.ts +++ b/src/plugins/discover/public/application/context/services/context.successors.test.ts @@ -16,6 +16,7 @@ import { Query } from '@kbn/es-query'; import { fetchSurroundingDocs, SurrDocType } from './context'; import { buildDataTableRecord, buildDataTableRecordList } from '@kbn/discover-utils'; import { discoverServiceMock } from '../../../__mocks__/services'; +import { searchResponseIncompleteWarningLocalCluster } from '@kbn/search-response-warnings/src/__mocks__/search_response_warnings'; const MS_PER_DAY = 24 * 60 * 60 * 1000; const ANCHOR_TIMESTAMP = new Date(MS_PER_DAY).toJSON(); @@ -257,28 +258,13 @@ describe('context successors', function () { const removeFieldsSpy = mockSearchSource.removeField.withArgs('fieldsFromSource'); expect(removeFieldsSpy.calledOnce).toBe(true); expect(setFieldsSpy.calledOnce).toBe(true); - expect(interceptedWarnings).toBeUndefined(); + expect(interceptedWarnings).toEqual([]); } ); }); }); describe('function fetchSuccessors with shard failures', function () { - const mockWarnings = [ - { - originalWarning: { - message: 'Data might be incomplete because your request timed out 1', - type: 'timed_out', - }, - }, - { - originalWarning: { - message: 'Data might be incomplete because your request timed out 2', - type: 'timed_out', - }, - }, - ]; - beforeEach(() => { mockSearchSource = createContextSearchSourceStub('@timestamp'); @@ -288,11 +274,7 @@ describe('context successors', function () { createEmpty: jest.fn().mockImplementation(() => mockSearchSource), }, showWarnings: jest.fn((adapter, callback) => { - callback(mockWarnings[0].originalWarning, {}); - callback(mockWarnings[1].originalWarning, {}); - // plus duplicates - callback(mockWarnings[0].originalWarning, {}); - callback(mockWarnings[1].originalWarning, {}); + callback(searchResponseIncompleteWarningLocalCluster, {}); }), }, } as unknown as DataPublicPluginStart; @@ -345,7 +327,7 @@ describe('context successors', function () { buildDataTableRecordList(mockSearchSource._stubHits.slice(-3), dataView) ); expect(dataPluginMock.search.showWarnings).toHaveBeenCalledTimes(1); - expect(interceptedWarnings).toEqual(mockWarnings); + expect(interceptedWarnings?.length).toBe(1); } ); }); From 10765c4db800ef2d79efe295c2134878b0f3f661 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 09:05:02 -0600 Subject: [PATCH 24/43] display shard failures --- .../_incomplete_results_modal.scss | 21 +++++++++++++++++++ .../incomplete_results_modal.tsx | 8 ++++--- .../open_incomplete_results_modal_button.tsx | 1 + 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/plugins/data/public/incomplete_results_modal/_incomplete_results_modal.scss diff --git a/src/plugins/data/public/incomplete_results_modal/_incomplete_results_modal.scss b/src/plugins/data/public/incomplete_results_modal/_incomplete_results_modal.scss new file mode 100644 index 00000000000000..142065fb39953e --- /dev/null +++ b/src/plugins/data/public/incomplete_results_modal/_incomplete_results_modal.scss @@ -0,0 +1,21 @@ +// set width and height to fixed values to prevent resizing when you switch tabs +.incompleteResultsModal { + min-height: 75vh; + width: 768px; + + // show buttons at the bottom of the modal + .kbnOverlayMountWrapper { + flex-grow: 1; + } + + // smaller gap between the modal title and body + .euiModalHeader { + padding-bottom: 0; + } +} + +.shardFailureModal__desc { + // set for IE11, since without it depending on the content the width of the list + // could be much higher than the available screenspace + max-width: 686px; +} diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index 4dec1f6f984c0f..7bcb32208d2ec6 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -23,6 +23,7 @@ import { import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SearchRequest } from '..'; import type { SearchResponseIncompleteWarning } from '../search'; +import { ShardFailureTable } from '../shard_failure_modal/shard_failure_table'; export interface Props { onClose: () => void; @@ -32,6 +33,7 @@ export interface Props { } export function IncompleteResultsModal({ request, response, warning, onClose }: Props) { + const failures = response._shards.failures ?? []; const requestJSON = JSON.stringify(request, null, 2); const responseJSON = JSON.stringify(response, null, 2); @@ -41,11 +43,11 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: name: i18n.translate( 'data.search.searchSource.fetch.incompleteResultsModal.tabHeaderClusterDetails', { - defaultMessage: 'Cluster details', + defaultMessage: 'Shard failures', description: 'Name of the tab displaying cluster details', } ), - content:
    cluster details
    , + content: , ['data-test-subj']: 'showClusterDetailsButton', }, { @@ -96,7 +98,7 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: diff --git a/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx b/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx index ddc9d94442971f..db09188529baea 100644 --- a/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx +++ b/src/plugins/data/public/incomplete_results_modal/open_incomplete_results_modal_button.tsx @@ -16,6 +16,7 @@ import { getOverlays } from '../services'; import type { SearchRequest } from '..'; import { IncompleteResultsModal } from './incomplete_results_modal'; import type { SearchResponseIncompleteWarning } from '../search'; +import './_incomplete_results_modal.scss'; // @internal export interface OpenIncompleteResultsModalButtonProps { From 4542867dda89e13e5da30c777891e31dcc64e940 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 09:19:30 -0600 Subject: [PATCH 25/43] remove replaced components --- .../incomplete_results_modal.tsx | 3 +- src/plugins/data/public/index.ts | 2 - .../shard_failure_modal.test.tsx.snap | 201 ------------------ .../data/public/shard_failure_modal/index.tsx | 23 -- .../shard_failure_modal.test.tsx | 28 --- .../shard_failure_modal.tsx | 125 ----------- ...d_failure_open_modal_button.test.mocks.tsx | 16 -- .../shard_failure_open_modal_button.test.tsx | 35 --- .../shard_failure_open_modal_button.tsx | 77 ------- 9 files changed, 1 insertion(+), 509 deletions(-) delete mode 100644 src/plugins/data/public/shard_failure_modal/__snapshots__/shard_failure_modal.test.tsx.snap delete mode 100644 src/plugins/data/public/shard_failure_modal/index.tsx delete mode 100644 src/plugins/data/public/shard_failure_modal/shard_failure_modal.test.tsx delete mode 100644 src/plugins/data/public/shard_failure_modal/shard_failure_modal.tsx delete mode 100644 src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.mocks.tsx delete mode 100644 src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.tsx delete mode 100644 src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.tsx diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index 7bcb32208d2ec6..8643071a555b91 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -33,7 +33,6 @@ export interface Props { } export function IncompleteResultsModal({ request, response, warning, onClose }: Props) { - const failures = response._shards.failures ?? []; const requestJSON = JSON.stringify(request, null, 2); const responseJSON = JSON.stringify(response, null, 2); @@ -47,7 +46,7 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: description: 'Name of the tab displaying cluster details', } ), - content: , + content: , ['data-test-subj']: 'showClusterDetailsButton', }, { diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index cba87c99bf9ae5..48a2d9c10b71c5 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -274,8 +274,6 @@ export type { } from './query'; // TODO: move to @kbn/search-response-warnings -export type { ShardFailureRequest } from './shard_failure_modal'; -export { ShardFailureOpenModalButton } from './shard_failure_modal'; export { OpenIncompleteResultsModalButton } from './incomplete_results_modal'; export type { AggsStart } from './search/aggs'; diff --git a/src/plugins/data/public/shard_failure_modal/__snapshots__/shard_failure_modal.test.tsx.snap b/src/plugins/data/public/shard_failure_modal/__snapshots__/shard_failure_modal.test.tsx.snap deleted file mode 100644 index d9a1affafd9bdd..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/__snapshots__/shard_failure_modal.test.tsx.snap +++ /dev/null @@ -1,201 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ShardFailureModal renders matching snapshot given valid properties 1`] = ` - - - - test - - - - , - "data-test-subj": "shardFailuresModalShardButton", - "id": "table", - "name": "Shard failures", - } - } - tabs={ - Array [ - Object { - "content": , - "data-test-subj": "shardFailuresModalShardButton", - "id": "table", - "name": "Shard failures", - }, - Object { - "content": - { - "version": true, - "size": 500, - "sort": [], - "_source": { - "excludes": [] - }, - "stored_fields": [ - "*" - ], - "script_fields": {}, - "docvalue_fields": [], - "query": {}, - "highlight": {} -} - , - "data-test-subj": "shardFailuresModalRequestButton", - "id": "json-request", - "name": "Request", - }, - Object { - "content": - { - "_shards": { - "total": 2, - "successful": 1, - "skipped": 0, - "failed": 1, - "failures": [ - { - "shard": 0, - "index": "repro2", - "node": "itsmeyournode", - "reason": { - "type": "script_exception", - "reason": "runtime error", - "script_stack": [ - "return doc['targetfield'].value;", - " ^---- HERE" - ], - "script": "return doc['targetfield'].value;", - "lang": "painless", - "caused_by": { - "type": "illegal_argument_exception", - "reason": "Gimme reason" - } - } - } - ] - } -} - , - "data-test-subj": "shardFailuresModalResponseButton", - "id": "json-response", - "name": "Response", - }, - ] - } - /> - - - - - - - - - - -`; diff --git a/src/plugins/data/public/shard_failure_modal/index.tsx b/src/plugins/data/public/shard_failure_modal/index.tsx deleted file mode 100644 index f600ca4368e488..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import type { ShardFailureOpenModalButtonProps } from './shard_failure_open_modal_button'; - -const Fallback = () =>
    ; - -const LazyShardFailureOpenModalButton = React.lazy( - () => import('./shard_failure_open_modal_button') -); -export const ShardFailureOpenModalButton = (props: ShardFailureOpenModalButtonProps) => ( - }> - - -); - -export type { ShardFailureRequest } from './shard_failure_types'; diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_modal.test.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_modal.test.tsx deleted file mode 100644 index d4b30d5a1923bf..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_modal.test.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { shallowWithIntl } from '@kbn/test-jest-helpers'; -import { ShardFailureModal } from './shard_failure_modal'; -import { shardFailureRequest } from './__mocks__/shard_failure_request'; -import { shardFailureResponse } from './__mocks__/shard_failure_response'; - -describe('ShardFailureModal', () => { - it('renders matching snapshot given valid properties', () => { - const component = shallowWithIntl( - - ); - - expect(component).toMatchSnapshot(); - }); -}); diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_modal.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_modal.tsx deleted file mode 100644 index 5dd7bebc2b77e0..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_modal.tsx +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React from 'react'; -import { FormattedMessage } from '@kbn/i18n-react'; -import { i18n } from '@kbn/i18n'; -import { - EuiCodeBlock, - EuiTabbedContent, - EuiCopy, - EuiButton, - EuiModalBody, - EuiModalHeader, - EuiModalHeaderTitle, - EuiModalFooter, - EuiButtonEmpty, - EuiCallOut, -} from '@elastic/eui'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { ShardFailureTable } from './shard_failure_table'; -import { ShardFailureRequest } from './shard_failure_types'; - -export interface Props { - onClose: () => void; - request: ShardFailureRequest; - response: estypes.SearchResponse; - title: string; -} - -export function ShardFailureModal({ request, response, title, onClose }: Props) { - if ( - !response || - !response._shards || - !Array.isArray((response._shards as any).failures) || - !request - ) { - // this should never ever happen, but just in case - return ( - - The ShardFailureModal component received invalid properties - - ); - } - const failures = (response._shards as any).failures; - const requestJSON = JSON.stringify(request, null, 2); - const responseJSON = JSON.stringify(response, null, 2); - - const tabs = [ - { - id: 'table', - name: i18n.translate( - 'data.search.searchSource.fetch.shardsFailedModal.tabHeaderShardFailures', - { - defaultMessage: 'Shard failures', - description: 'Name of the tab displaying shard failures', - } - ), - content: , - ['data-test-subj']: 'shardFailuresModalShardButton', - }, - { - id: 'json-request', - name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tabHeaderRequest', { - defaultMessage: 'Request', - description: 'Name of the tab displaying the JSON request', - }), - content: ( - - {requestJSON} - - ), - ['data-test-subj']: 'shardFailuresModalRequestButton', - }, - { - id: 'json-response', - name: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.tabHeaderResponse', { - defaultMessage: 'Response', - description: 'Name of the tab displaying the JSON response', - }), - content: ( - - {responseJSON} - - ), - ['data-test-subj']: 'shardFailuresModalResponseButton', - }, - ]; - - return ( - - - - {title} - - - - - - - - {(copy) => ( - - - - )} - - onClose()} fill data-test-subj="closeShardFailureModal"> - - - - - ); -} diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.mocks.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.mocks.tsx deleted file mode 100644 index 948905cf1ce900..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.mocks.tsx +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { setOverlays } from '../services'; -import { OverlayStart } from '@kbn/core/public'; - -export const openModal = jest.fn(); - -setOverlays({ - openModal, -} as unknown as OverlayStart); diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.tsx deleted file mode 100644 index 00f0315e69275c..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.test.tsx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { openModal } from './shard_failure_open_modal_button.test.mocks'; -import React from 'react'; -import { themeServiceMock } from '@kbn/core/public/mocks'; -import { mountWithIntl } from '@kbn/test-jest-helpers'; -import ShardFailureOpenModalButton from './shard_failure_open_modal_button'; -import { shardFailureRequest } from './__mocks__/shard_failure_request'; -import { shardFailureResponse } from './__mocks__/shard_failure_response'; -import { findTestSubject } from '@elastic/eui/lib/test'; - -const theme = themeServiceMock.createStartContract(); - -describe('ShardFailureOpenModalButton', () => { - it('triggers the openModal function when "Show details" button is clicked', () => { - const component = mountWithIntl( - ({ - request: shardFailureRequest, - response: shardFailureResponse, - })} - theme={theme} - title="test" - /> - ); - findTestSubject(component, 'openShardFailureModalBtn').simulate('click'); - expect(openModal).toHaveBeenCalled(); - }); -}); diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.tsx deleted file mode 100644 index 922aee3f49483e..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_open_modal_button.tsx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import React, { useCallback } from 'react'; -import { FormattedMessage } from '@kbn/i18n-react'; -import { EuiLink, EuiButton, EuiButtonProps } from '@elastic/eui'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { ThemeServiceStart } from '@kbn/core/public'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; -import { getOverlays } from '../services'; -import { ShardFailureModal } from './shard_failure_modal'; -import type { ShardFailureRequest } from './shard_failure_types'; -import './_shard_failure_modal.scss'; - -// @internal -export interface ShardFailureOpenModalButtonProps { - theme: ThemeServiceStart; - title: string; - size?: EuiButtonProps['size']; - color?: EuiButtonProps['color']; - getRequestMeta: () => { - request: ShardFailureRequest; - response: estypes.SearchResponse; - }; - isButtonEmpty?: boolean; -} - -// Needed for React.lazy -// eslint-disable-next-line import/no-default-export -export default function ShardFailureOpenModalButton({ - getRequestMeta, - theme, - title, - size = 's', - color = 'warning', - isButtonEmpty = false, -}: ShardFailureOpenModalButtonProps) { - const onClick = useCallback(() => { - const { request, response } = getRequestMeta(); - const modal = getOverlays().openModal( - toMountPoint( - modal.close()} - />, - { theme$: theme.theme$ } - ), - { - className: 'shardFailureModal', - } - ); - }, [getRequestMeta, theme.theme$, title]); - - const Component = isButtonEmpty ? EuiLink : EuiButton; - - return ( - - - - ); -} From ef0e760517b2d451d0e1fc7fd5c9dd5b6a45bf0d Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 09:34:05 -0600 Subject: [PATCH 26/43] clean up types --- .../incomplete_results_modal.tsx | 2 +- .../__mocks__/shard_failure_request.ts | 22 ------------- .../__mocks__/shard_failure_response.ts | 4 +-- .../shard_failure_description.test.tsx | 4 +-- .../shard_failure_description.tsx | 8 ++--- .../shard_failure_table.test.tsx | 4 +-- .../shard_failure_table.tsx | 6 ++-- .../shard_failure_types.ts | 33 ------------------- 8 files changed, 13 insertions(+), 70 deletions(-) delete mode 100644 src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_request.ts delete mode 100644 src/plugins/data/public/shard_failure_modal/shard_failure_types.ts diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index 8643071a555b91..94499d8f07313d 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -46,7 +46,7 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: description: 'Name of the tab displaying cluster details', } ), - content: , + content: , ['data-test-subj']: 'showClusterDetailsButton', }, { diff --git a/src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_request.ts b/src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_request.ts deleted file mode 100644 index c13ca9e71f48f6..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_request.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { ShardFailureRequest } from '../shard_failure_types'; -export const shardFailureRequest = { - version: true, - size: 500, - sort: [], - _source: { - excludes: [], - }, - stored_fields: ['*'], - script_fields: {}, - docvalue_fields: [], - query: {}, - highlight: {}, -} as ShardFailureRequest; diff --git a/src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_response.ts b/src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_response.ts index 50355a933ec5dd..b45caefd5fe268 100644 --- a/src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_response.ts +++ b/src/plugins/data/public/shard_failure_modal/__mocks__/shard_failure_response.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { estypes } from '@elastic/elasticsearch'; export const shardFailureResponse: estypes.SearchResponse = { _shards: { @@ -33,4 +33,4 @@ export const shardFailureResponse: estypes.SearchResponse = { }, ], }, -} as any; +} as unknown as estypes.SearchResponse; diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_description.test.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_description.test.tsx index 9664ca1f9f9974..23a455ac04c3cd 100644 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_description.test.tsx +++ b/src/plugins/data/public/shard_failure_modal/shard_failure_description.test.tsx @@ -14,13 +14,13 @@ import { shardFailureResponse } from './__mocks__/shard_failure_response'; describe('ShardFailureDescription', () => { it('renders matching snapshot given valid properties', () => { - const failure = (shardFailureResponse._shards as any).failures[0]; + const failure = shardFailureResponse._shards.failures![0]; const component = shallowWithIntl(); expect(component).toMatchSnapshot(); }); it('should show more details when button is pressed', async () => { - const failure = (shardFailureResponse._shards as any).failures[0]; + const failure = shardFailureResponse._shards.failures![0]; const component = shallowWithIntl(); await component.find(EuiButtonEmpty).simulate('click'); expect(component).toMatchSnapshot(); diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_description.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_description.tsx index 9d78b0adf9a894..2efad1fe7e220e 100644 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_description.tsx +++ b/src/plugins/data/public/shard_failure_modal/shard_failure_description.tsx @@ -7,6 +7,7 @@ */ import React, { useState } from 'react'; +import { estypes } from '@elastic/elasticsearch'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; import { getFlattenedObject } from '@kbn/std'; @@ -17,7 +18,6 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; -import { ShardFailure } from './shard_failure_types'; /** * Provides pretty formatting of a given key string @@ -47,7 +47,7 @@ export function formatValueByKey(value: unknown, key: string): string | JSX.Elem } } -export function ShardFailureDescription(props: ShardFailure) { +export function ShardFailureDescription(props: estypes.ShardFailure) { const [showDetails, setShowDetails] = useState(false); const flattendReason = getFlattenedObject(props.reason); @@ -70,7 +70,7 @@ export function ShardFailureDescription(props: ShardFailure) { title: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.indexTitle', { defaultMessage: 'Index', }), - description: props.index, + description: props.index ?? '', }, { title: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.reasonTypeTitle', { @@ -84,7 +84,7 @@ export function ShardFailureDescription(props: ShardFailure) { title: i18n.translate('data.search.searchSource.fetch.shardsFailedModal.nodeTitle', { defaultMessage: 'Node', }), - description: props.node, + description: props.node ?? '', }, ...reasonItems, ] diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx index c4a53f850ab6a6..a964f43d9719b6 100644 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx +++ b/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx @@ -10,12 +10,10 @@ import React from 'react'; import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ShardFailureTable } from './shard_failure_table'; import { shardFailureResponse } from './__mocks__/shard_failure_response'; -import { ShardFailure } from './shard_failure_types'; describe('ShardFailureTable', () => { it('renders matching snapshot given valid properties', () => { - const failures = (shardFailureResponse._shards as any).failures as ShardFailure[]; - const component = shallowWithIntl(); + const component = shallowWithIntl(); expect(component).toMatchSnapshot(); }); }); diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_table.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_table.tsx index ab9c376157100d..cb4fed32f11ebf 100644 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_table.tsx +++ b/src/plugins/data/public/shard_failure_modal/shard_failure_table.tsx @@ -7,13 +7,13 @@ */ import React from 'react'; +import { estypes } from '@elastic/elasticsearch'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; import { EuiInMemoryTable, EuiInMemoryTableProps, euiScreenReaderOnly } from '@elastic/eui'; import { ShardFailureDescription } from './shard_failure_description'; -import { ShardFailure } from './shard_failure_types'; -export interface ListItem extends ShardFailure { +export interface ListItem extends estypes.ShardFailure { id: string; } @@ -24,7 +24,7 @@ const SORTING: EuiInMemoryTableProps['sorting'] = { }, }; -export function ShardFailureTable({ failures }: { failures: ShardFailure[] }) { +export function ShardFailureTable({ failures }: { failures: estypes.ShardFailure[] }) { const itemList = failures.map((failure, idx) => ({ ...{ id: String(idx) }, ...failure })); const columns = [ diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_types.ts b/src/plugins/data/public/shard_failure_modal/shard_failure_types.ts deleted file mode 100644 index c6533f9f0a8505..00000000000000 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_types.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -export interface ShardFailureRequest { - docvalue_fields: string[]; - _source: unknown; - query: unknown; - script_fields: unknown; - sort: unknown; - stored_fields: string[]; -} - -export interface ShardFailure { - index: string; - node: string; - reason: { - caused_by: { - reason: string; - type: string; - }; - reason: string; - lang?: estypes.ScriptLanguage; - script?: string; - script_stack?: string[]; - type: string; - }; - shard: number; -} From 89b8ba65b6d5953fc69e8e1283087fa1e52f9306 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 6 Sep 2023 15:40:08 +0000 Subject: [PATCH 27/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../public/shard_failure_modal/shard_failure_table.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx b/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx index a964f43d9719b6..567ad8ff80ac28 100644 --- a/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx +++ b/src/plugins/data/public/shard_failure_modal/shard_failure_table.test.tsx @@ -13,7 +13,9 @@ import { shardFailureResponse } from './__mocks__/shard_failure_response'; describe('ShardFailureTable', () => { it('renders matching snapshot given valid properties', () => { - const component = shallowWithIntl(); + const component = shallowWithIntl( + + ); expect(component).toMatchSnapshot(); }); }); From 1baa4f45a5452e79891a5c613201776b52cc3f1b Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 12:44:59 -0600 Subject: [PATCH 28/43] fix functional test --- .../functional/apps/discover/async_scripted_fields.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/test/functional/apps/discover/async_scripted_fields.js b/x-pack/test/functional/apps/discover/async_scripted_fields.js index 0d48f42c5ba1e9..1eb3fa4f1b2705 100644 --- a/x-pack/test/functional/apps/discover/async_scripted_fields.js +++ b/x-pack/test/functional/apps/discover/async_scripted_fields.js @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }) { const security = getService('security'); const dashboardAddPanel = getService('dashboardAddPanel'); - describe('async search with scripted fields', function () { + describe.only('search with scripted fields', function () { this.tags(['skipFirefox']); before(async function () { @@ -51,7 +51,7 @@ export default function ({ getService, getPageObjects }) { await security.testUser.restoreDefaults(); }); - it('query should show failed shards callout', async function () { + it('query should show incomplete results callout', async function () { if (false) { /* If you had to modify the scripted fields, you could un-comment all this, run it, use es_archiver to update 'kibana_scripted_fields_on_logstash' */ @@ -81,11 +81,11 @@ export default function ({ getService, getPageObjects }) { 'dscNoResultsInterceptedWarningsCallout_warningTitle' ); log.debug(shardMessage); - expect(shardMessage).to.be('1 of 3 shards failed'); + expect(shardMessage).to.be('The data might be incomplete or wrong.'); }); }); - it('query should show failed shards badge on dashboard', async function () { + it('query should show incomplete results badge on dashboard', async function () { await security.testUser.setRoles([ 'test_logstash_reader', 'global_discover_all', From 278aab6eb954a1bf5e92c909b39d7acbd25aa651 Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 12:54:00 -0600 Subject: [PATCH 29/43] remove only --- x-pack/test/functional/apps/discover/async_scripted_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/discover/async_scripted_fields.js b/x-pack/test/functional/apps/discover/async_scripted_fields.js index 1eb3fa4f1b2705..d86298405b72d4 100644 --- a/x-pack/test/functional/apps/discover/async_scripted_fields.js +++ b/x-pack/test/functional/apps/discover/async_scripted_fields.js @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }) { const security = getService('security'); const dashboardAddPanel = getService('dashboardAddPanel'); - describe.only('search with scripted fields', function () { + describe('search with scripted fields', function () { this.tags(['skipFirefox']); before(async function () { From 6bf085efb23936509ecdd6c8890595211aab08db Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 6 Sep 2023 13:02:46 -0600 Subject: [PATCH 30/43] fix jest test --- .../main/utils/fetch_documents.test.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/discover/public/application/main/utils/fetch_documents.test.ts b/src/plugins/discover/public/application/main/utils/fetch_documents.test.ts index f850b283b3491a..cbc62a3cd6068a 100644 --- a/src/plugins/discover/public/application/main/utils/fetch_documents.test.ts +++ b/src/plugins/discover/public/application/main/utils/fetch_documents.test.ts @@ -37,17 +37,20 @@ describe('test fetchDocuments', () => { const documents = hits.map((hit) => buildDataTableRecord(hit, dataViewMock)); savedSearchMock.searchSource.fetch$ = () => of({ rawResponse: { hits: { hits } } } as IKibanaSearchResponse>); - expect(fetchDocuments(savedSearchMock.searchSource, getDeps())).resolves.toEqual({ + expect(await fetchDocuments(savedSearchMock.searchSource, getDeps())).toEqual({ + interceptedWarnings: [], records: documents, }); }); - test('rejects on query failure', () => { + test('rejects on query failure', async () => { savedSearchMock.searchSource.fetch$ = () => throwErrorRx(() => new Error('Oh noes!')); - expect(fetchDocuments(savedSearchMock.searchSource, getDeps())).rejects.toEqual( - new Error('Oh noes!') - ); + try { + await fetchDocuments(savedSearchMock.searchSource, getDeps()); + } catch (e) { + expect(e).toEqual(new Error('Oh noes!')); + } }); test('passes a correct session id', async () => { @@ -66,7 +69,8 @@ describe('test fetchDocuments', () => { jest.spyOn(searchSourceRegular, 'fetch$'); - expect(fetchDocuments(searchSourceRegular, deps)).resolves.toEqual({ + expect(await fetchDocuments(searchSourceRegular, deps)).toEqual({ + interceptedWarnings: [], records: documents, }); @@ -84,7 +88,8 @@ describe('test fetchDocuments', () => { jest.spyOn(searchSourceForLoadMore, 'fetch$'); - expect(fetchDocuments(searchSourceForLoadMore, deps)).resolves.toEqual({ + expect(await fetchDocuments(searchSourceForLoadMore, deps)).toEqual({ + interceptedWarnings: [], records: documents, }); From 5cf79b0e311f6ef95193899322153443ddf5def8 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 7 Sep 2023 10:42:47 -0600 Subject: [PATCH 31/43] Update src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx Co-authored-by: Julia Rechkunova --- .../incomplete_results_modal/incomplete_results_modal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index 94499d8f07313d..ee754ae268c40e 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -115,7 +115,7 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: )} - onClose()} fill data-test-subj="closeincompleteResultsModal"> + onClose()} fill data-test-subj="closeIncompleteResultsModal"> Date: Thu, 7 Sep 2023 10:46:01 -0600 Subject: [PATCH 32/43] remove translations added in merge conflict resolution --- .../translations/translations/fr-FR.json | 19 ------------------- .../translations/translations/ja-JP.json | 19 ------------------- .../translations/translations/zh-CN.json | 19 ------------------- 3 files changed, 57 deletions(-) diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 727960d6905271..4b2052d4c547aa 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -2469,25 +2469,6 @@ "unifiedDocViewer.sourceViewer.errorMessage": "Impossible de récupérer les données pour le moment. Actualisez l'onglet et réessayez.", "unifiedDocViewer.sourceViewer.errorMessageTitle": "Une erreur s'est produite.", "unifiedDocViewer.sourceViewer.refresh": "Actualiser", - "unifiedDataTable.tableHeader.timeFieldIconTooltipAriaLabel": "{timeFieldName} – Ce champ représente l'heure à laquelle les événements se sont produits.", - "unifiedDataTable.searchGenerationWithDescription": "Tableau généré par la recherche {searchTitle}", - "unifiedDataTable.searchGenerationWithDescriptionGrid": "Tableau généré par la recherche {searchTitle} ({searchDescription})", - "unifiedDataTable.selectedDocumentsNumber": "{nr} documents sélectionnés", - "unifiedDataTable.clearSelection": "Effacer la sélection", - "unifiedDataTable.controlColumnHeader": "Colonne de commande", - "unifiedDataTable.copyToClipboardJSON": "Copier les documents dans le presse-papiers (JSON)", - "unifiedDataTable.tableHeader.timeFieldIconTooltip": "Ce champ représente l'heure à laquelle les événements se sont produits.", - "unifiedDataTable.grid.copyColumnNameToClipBoardButton": "Copier le nom", - "unifiedDataTable.grid.copyColumnValuesToClipBoardButton": "Copier la colonne", - "unifiedDataTable.grid.documentHeader": "Document", - "unifiedDataTable.grid.editFieldButton": "Modifier le champ de la vue de données", - "unifiedDataTable.grid.selectDoc": "Sélectionner le document \"{rowNumber}\"", - "unifiedDataTable.loadingResults": "Chargement des résultats", - "unifiedDataTable.noResultsFound": "Résultat introuvable", - "unifiedDataTable.removeColumnLabel": "Supprimer la colonne", - "unifiedDataTable.selectColumnHeader": "Sélectionner la colonne", - "unifiedDataTable.showAllDocuments": "Afficher tous les documents", - "unifiedDataTable.showSelectedDocumentsOnly": "Afficher uniquement les documents sélectionnés", "domDragDrop.announce.cancelled": "Mouvement annulé. {label} revenu à sa position initiale", "domDragDrop.announce.cancelledItem": "Mouvement annulé. {label} revenu au groupe {groupLabel} à la position {position}", "domDragDrop.announce.dropped.combineCompatible": "{label} combiné dans le groupe {groupLabel} en {dropLabel} dans le groupe {dropGroupLabel} à la position {dropPosition} dans le calque {dropLayerNumber}", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 3505eb18cf6d28..3b3f5f9a02c333 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2484,25 +2484,6 @@ "unifiedDocViewer.sourceViewer.errorMessage": "現在データを取得できませんでした。タブを更新して、再試行してください。", "unifiedDocViewer.sourceViewer.errorMessageTitle": "エラーが発生しました", "unifiedDocViewer.sourceViewer.refresh": "更新", - "unifiedDataTable.tableHeader.timeFieldIconTooltipAriaLabel": "{timeFieldName} - このフィールドはイベントの発生時刻を表します。", - "unifiedDataTable.searchGenerationWithDescription": "検索{searchTitle}で生成されたテーブル", - "unifiedDataTable.searchGenerationWithDescriptionGrid": "検索{searchTitle}で生成されたテーブル({searchDescription})", - "unifiedDataTable.selectedDocumentsNumber": "{nr}個のドキュメントが選択されました", - "unifiedDataTable.clearSelection": "選択した項目をクリア", - "unifiedDataTable.controlColumnHeader": "列の制御", - "unifiedDataTable.copyToClipboardJSON": "ドキュメントをクリップボードにコピー(JSON)", - "unifiedDataTable.tableHeader.timeFieldIconTooltip": "このフィールドはイベントの発生時刻を表します。", - "unifiedDataTable.grid.copyColumnNameToClipBoardButton": "名前をコピー", - "unifiedDataTable.grid.copyColumnValuesToClipBoardButton": "列をコピー", - "unifiedDataTable.grid.documentHeader": "ドキュメント", - "unifiedDataTable.grid.editFieldButton": "データビューフィールドを編集", - "unifiedDataTable.grid.selectDoc": "ドキュメント'{rowNumber}'を選択", - "unifiedDataTable.loadingResults": "結果を読み込み中", - "unifiedDataTable.noResultsFound": "結果が見つかりませんでした", - "unifiedDataTable.removeColumnLabel": "列を削除", - "unifiedDataTable.selectColumnHeader": "列を選択", - "unifiedDataTable.showAllDocuments": "すべてのドキュメントを表示", - "unifiedDataTable.showSelectedDocumentsOnly": "選択したドキュメントのみを表示", "domDragDrop.announce.cancelled": "移動がキャンセルされました。{label}は初期位置に戻りました", "domDragDrop.announce.cancelledItem": "移動がキャンセルされました。{label}は位置{position}の{groupLabel}グループに戻りました", "domDragDrop.announce.dropped.combineCompatible": "レイヤー{dropLayerNumber}の位置{dropPosition}でグループ{dropGroupLabel}の{dropLabel}にグループ{groupLabel}の{label}を結合しました。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index fc553a85fc40f5..24f4159ba47bec 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2484,25 +2484,6 @@ "unifiedDocViewer.sourceViewer.errorMessage": "当前无法获取数据。请刷新选项卡以重试。", "unifiedDocViewer.sourceViewer.errorMessageTitle": "发生错误", "unifiedDocViewer.sourceViewer.refresh": "刷新", - "unifiedDataTable.tableHeader.timeFieldIconTooltipAriaLabel": "{timeFieldName} - 此字段表示事件发生的时间。", - "unifiedDataTable.searchGenerationWithDescription": "搜索 {searchTitle} 生成的表", - "unifiedDataTable.searchGenerationWithDescriptionGrid": "搜索 {searchTitle} 生成的表({searchDescription})", - "unifiedDataTable.selectedDocumentsNumber": "{nr} 个文档已选择", - "unifiedDataTable.clearSelection": "清除所选内容", - "unifiedDataTable.controlColumnHeader": "控制列", - "unifiedDataTable.copyToClipboardJSON": "将文档复制到剪贴板 (JSON)", - "unifiedDataTable.tableHeader.timeFieldIconTooltip": "此字段表示事件发生的时间。", - "unifiedDataTable.grid.copyColumnNameToClipBoardButton": "复制名称", - "unifiedDataTable.grid.copyColumnValuesToClipBoardButton": "复制列", - "unifiedDataTable.grid.documentHeader": "文档", - "unifiedDataTable.grid.editFieldButton": "编辑数据视图字段", - "unifiedDataTable.grid.selectDoc": "选择文档“{rowNumber}”", - "unifiedDataTable.loadingResults": "正在加载结果", - "unifiedDataTable.noResultsFound": "找不到结果", - "unifiedDataTable.removeColumnLabel": "移除列", - "unifiedDataTable.selectColumnHeader": "选择列", - "unifiedDataTable.showAllDocuments": "显示所有文档", - "unifiedDataTable.showSelectedDocumentsOnly": "仅显示选定的文档", "domDragDrop.announce.cancelled": "移动已取消。{label} 已返回至其初始位置", "domDragDrop.announce.cancelledItem": "移动已取消。{label} 返回至 {groupLabel} 组中的位置 {position}", "domDragDrop.announce.dropped.combineCompatible": "已将组 {groupLabel} 中的 {label} 组合到图层 {dropLayerNumber} 的组 {dropGroupLabel} 中的位置 {dropPosition} 上的 {dropLabel}", From 8f9c6e6f27d511b83692197e8b529315c1deb39a Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 7 Sep 2023 10:54:08 -0600 Subject: [PATCH 33/43] wrap hasUnsupportedDownsampledAggregationFailure tests in describe block --- ...ed_downsampled_aggregation_failure.test.ts | 126 +++++++++--------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts index f7c06017d16d84..e8d722feb131a1 100644 --- a/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts +++ b/packages/kbn-search-response-warnings/src/utils/has_unsupported_downsampled_aggregation_failure.test.ts @@ -8,71 +8,73 @@ import { hasUnsupportedDownsampledAggregationFailure } from './has_unsupported_downsampled_aggregation_failure'; -test('should return false when unsupported_aggregation_on_downsampled_index shard failure does not exist', () => { - expect( - hasUnsupportedDownsampledAggregationFailure({ - type: 'incomplete', - message: 'The data might be incomplete or wrong.', - clusters: { - '(local)': { - status: 'partial', - indices: '', - took: 25, - timed_out: false, - _shards: { - total: 4, - successful: 3, - skipped: 0, - failed: 1, - }, - failures: [ - { - shard: 0, - index: 'sample-01-rollup', - node: 'VFTFJxpHSdaoiGxJFLSExQ', - reason: { - type: 'illegal_argument_exception', - reason: - 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', - }, +describe('hasUnsupportedDownsampledAggregationFailure', () => { + test('should return false when unsupported_aggregation_on_downsampled_index shard failure does not exist', () => { + expect( + hasUnsupportedDownsampledAggregationFailure({ + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, }, - ], + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'illegal_argument_exception', + reason: + 'Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]', + }, + }, + ], + }, }, - }, - }) - ).toBe(false); -}); + }) + ).toBe(false); + }); -test('should return true when unsupported_aggregation_on_downsampled_index shard failure exists', () => { - expect( - hasUnsupportedDownsampledAggregationFailure({ - type: 'incomplete', - message: 'The data might be incomplete or wrong.', - clusters: { - '(local)': { - status: 'partial', - indices: '', - took: 25, - timed_out: false, - _shards: { - total: 4, - successful: 3, - skipped: 0, - failed: 1, - }, - failures: [ - { - shard: 0, - index: 'sample-01-rollup', - node: 'VFTFJxpHSdaoiGxJFLSExQ', - reason: { - type: 'unsupported_aggregation_on_downsampled_index', - reason: 'blah blah blah timeseries data', - }, + test('should return true when unsupported_aggregation_on_downsampled_index shard failure exists', () => { + expect( + hasUnsupportedDownsampledAggregationFailure({ + type: 'incomplete', + message: 'The data might be incomplete or wrong.', + clusters: { + '(local)': { + status: 'partial', + indices: '', + took: 25, + timed_out: false, + _shards: { + total: 4, + successful: 3, + skipped: 0, + failed: 1, }, - ], + failures: [ + { + shard: 0, + index: 'sample-01-rollup', + node: 'VFTFJxpHSdaoiGxJFLSExQ', + reason: { + type: 'unsupported_aggregation_on_downsampled_index', + reason: 'blah blah blah timeseries data', + }, + }, + ], + }, }, - }, - }) - ).toBe(true); + }) + ).toBe(true); + }); }); From 21c17d9070bbfc8ce0945b04d9fa08cfdfcc3605 Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 7 Sep 2023 11:14:03 -0600 Subject: [PATCH 34/43] show time out warning in IncompleteResultsModal --- .../incomplete_results_modal.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index ee754ae268c40e..d67e88e30e7621 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -10,6 +10,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { + EuiCallOut, EuiCodeBlock, EuiTabbedContent, EuiCopy, @@ -42,11 +43,28 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: name: i18n.translate( 'data.search.searchSource.fetch.incompleteResultsModal.tabHeaderClusterDetails', { - defaultMessage: 'Shard failures', + defaultMessage: 'Cluster details', description: 'Name of the tab displaying cluster details', } ), - content: , + content: ( + <> + {response.timed_out + ? +

    + {i18n.translate('data.search.searchSource.fetch.incompleteResultsModal.requestTimedOutMessage', { + defaultMessage: 'Request timed out', + })} +

    +
    + : null + } + + {response._shards.failures.length + ? + : null + } + ), ['data-test-subj']: 'showClusterDetailsButton', }, { From bb4c71d61b84f92b3dd6fe5c8b0f5b0e08f63b81 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:19:05 +0000 Subject: [PATCH 35/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../incomplete_results_modal.tsx | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index d67e88e30e7621..b5941903595bac 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -49,22 +49,24 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: ), content: ( <> - {response.timed_out - ? -

    - {i18n.translate('data.search.searchSource.fetch.incompleteResultsModal.requestTimedOutMessage', { + {response.timed_out ? ( + +

    + {i18n.translate( + 'data.search.searchSource.fetch.incompleteResultsModal.requestTimedOutMessage', + { defaultMessage: 'Request timed out', - })} -

    -
    - : null - } - - {response._shards.failures.length - ? - : null - } - ), + } + )} +

    + + ) : null} + + {response._shards.failures.length ? ( + + ) : null} + + ), ['data-test-subj']: 'showClusterDetailsButton', }, { From b724b9265230727c3f22568a9900d4b74caa4152 Mon Sep 17 00:00:00 2001 From: nreese Date: Thu, 7 Sep 2023 11:44:05 -0600 Subject: [PATCH 36/43] add jest test for IncompleteResultsModal component --- .../incomplete_results_modal.test.tsx.snap | 271 ++++++++++++++++++ .../incomplete_results_modal.test.tsx | 68 +++++ .../incomplete_results_modal.tsx | 2 +- 3 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 src/plugins/data/public/incomplete_results_modal/__snapshots__/incomplete_results_modal.test.tsx.snap create mode 100644 src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx diff --git a/src/plugins/data/public/incomplete_results_modal/__snapshots__/incomplete_results_modal.test.tsx.snap b/src/plugins/data/public/incomplete_results_modal/__snapshots__/incomplete_results_modal.test.tsx.snap new file mode 100644 index 00000000000000..666b87f998c3ed --- /dev/null +++ b/src/plugins/data/public/incomplete_results_modal/__snapshots__/incomplete_results_modal.test.tsx.snap @@ -0,0 +1,271 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`IncompleteResultsModal should render shard failures 1`] = ` + + + + + + + + + + , + "data-test-subj": "showClusterDetailsButton", + "id": "table", + "name": "Cluster details", + } + } + tabs={ + Array [ + Object { + "content": + + , + "data-test-subj": "showClusterDetailsButton", + "id": "table", + "name": "Cluster details", + }, + Object { + "content": + {} + , + "data-test-subj": "showRequestButton", + "id": "json-request", + "name": "Request", + }, + Object { + "content": + { + "_shards": { + "total": 4, + "successful": 3, + "skipped": 0, + "failed": 1, + "failures": [ + { + "shard": 0, + "index": "sample-01-rollup", + "node": "VFTFJxpHSdaoiGxJFLSExQ", + "reason": { + "type": "illegal_argument_exception", + "reason": "Field [kubernetes.container.memory.available.bytes] of type [aggregate_metric_double] is not supported for aggregation [percentiles]" + } + } + ] + } +} + , + "data-test-subj": "showResponseButton", + "id": "json-response", + "name": "Response", + }, + ] + } + /> + + + + + + + + + + +`; + +exports[`IncompleteResultsModal should render time out 1`] = ` + + + + + + + + + +

    + Request timed out +

    +
    + , + "data-test-subj": "showClusterDetailsButton", + "id": "table", + "name": "Cluster details", + } + } + tabs={ + Array [ + Object { + "content": + +

    + Request timed out +

    +
    +
    , + "data-test-subj": "showClusterDetailsButton", + "id": "table", + "name": "Cluster details", + }, + Object { + "content": + {} + , + "data-test-subj": "showRequestButton", + "id": "json-request", + "name": "Request", + }, + Object { + "content": + { + "timed_out": true, + "_shards": { + "total": 4, + "successful": 4, + "skipped": 0, + "failed": 0 + } +} + , + "data-test-subj": "showResponseButton", + "id": "json-response", + "name": "Response", + }, + ] + } + /> +
    + + + + + + + + +
    +`; diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx new file mode 100644 index 00000000000000..9ca4ab3e21fa14 --- /dev/null +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx @@ -0,0 +1,68 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { shallow } from 'enzyme'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { SearchResponseIncompleteWarning } from '../search'; +import { IncompleteResultsModal } from './incomplete_results_modal'; + +describe('IncompleteResultsModal', () => { + test('should render shard failures', () => { + const component = shallow( + } + onClose={jest.fn()} + /> + ); + + expect(component).toMatchSnapshot(); + }); + + test('should render time out', () => { + const component = shallow( + } + onClose={jest.fn()} + /> + ); + + expect(component).toMatchSnapshot(); + }); +}); \ No newline at end of file diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx index b5941903595bac..eb07d8d60e517f 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.tsx @@ -62,7 +62,7 @@ export function IncompleteResultsModal({ request, response, warning, onClose }: ) : null} - {response._shards.failures.length ? ( + {response._shards.failures?.length ? ( ) : null} From 0a4e19dd1df4ebf67ce8a85fbaa777357b2ddfe7 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:49:27 +0000 Subject: [PATCH 37/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- .../incomplete_results_modal.test.tsx | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx index 9ca4ab3e21fa14..6e90740cf98887 100644 --- a/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx +++ b/src/plugins/data/public/incomplete_results_modal/incomplete_results_modal.test.tsx @@ -18,26 +18,28 @@ describe('IncompleteResultsModal', () => { } + ], + }, + } as unknown as estypes.SearchResponse + } onClose={jest.fn()} /> ); @@ -50,19 +52,21 @@ describe('IncompleteResultsModal', () => { } + response={ + { + timed_out: true, + _shards: { + total: 4, + successful: 4, + skipped: 0, + failed: 0, + }, + } as unknown as estypes.SearchResponse + } onClose={jest.fn()} /> ); expect(component).toMatchSnapshot(); }); -}); \ No newline at end of file +}); From 6939dd5db98060091e9001fd2e21dd5b12655796 Mon Sep 17 00:00:00 2001 From: nreese Date: Tue, 12 Sep 2023 12:47:41 -0600 Subject: [PATCH 38/43] fix search source example functional tests --- .../search_examples/public/search/app.tsx | 10 ++- .../public/search/fetch/handle_warnings.tsx | 32 ++------- test/examples/search/warnings.ts | 67 ++++--------------- 3 files changed, 20 insertions(+), 89 deletions(-) diff --git a/examples/search_examples/public/search/app.tsx b/examples/search_examples/public/search/app.tsx index 803afb95d0e9f2..5b79b84eb2370a 100644 --- a/examples/search_examples/public/search/app.tsx +++ b/examples/search_examples/public/search/app.tsx @@ -317,11 +317,9 @@ export const SearchExamplesApp = ({ ); setRawResponse(result.rawResponse); - /* Here is an example of using showWarnings on the search service, using an optional callback to - * intercept the warnings before notification warnings are shown. - * - * Suppressing the shard failure warning notification from appearing by default requires setting - * { disableShardFailureWarning: true } in the SearchSourceSearchOptions passed to $fetch + /* + * Set disableWarningToasts to true to disable warning toasts and customize warning display. + * Then use showWarnings to customize warning notification. */ if (showWarningToastNotifications) { setWarningContents([]); @@ -498,7 +496,7 @@ export const SearchExamplesApp = ({ {' '} {' '} {' '} {' '} diff --git a/src/plugins/data/public/search/fetch/handle_warnings.tsx b/src/plugins/data/public/search/fetch/handle_warnings.tsx index a95c5235f83122..aaf43c0e3cd750 100644 --- a/src/plugins/data/public/search/fetch/handle_warnings.tsx +++ b/src/plugins/data/public/search/fetch/handle_warnings.tsx @@ -7,12 +7,10 @@ */ import { estypes } from '@elastic/elasticsearch'; -import { debounce } from 'lodash'; import { EuiTextAlign } from '@elastic/eui'; import { ThemeServiceStart } from '@kbn/core/public'; import { toMountPoint } from '@kbn/kibana-react-plugin/public'; import React from 'react'; -import type { MountPoint } from '@kbn/core/public'; import { SearchRequest } from '..'; import { getNotifications } from '../../services'; import { OpenIncompleteResultsModalButton } from '../../incomplete_results_modal'; @@ -23,27 +21,6 @@ import { } from '../types'; import { extractWarnings } from './extract_warnings'; -const getDebouncedWarning = () => { - const addWarning = () => { - const { toasts } = getNotifications(); - return debounce(toasts.addWarning.bind(toasts), 30000, { - leading: true, - }); - }; - const memory: Record> = {}; - - return ( - debounceKey: string, - title: string, - text?: string | MountPoint | undefined - ) => { - memory[debounceKey] = memory[debounceKey] || addWarning(); - return memory[debounceKey]({ title, text }); - }; -}; - -const debouncedIncompleteWarning = getDebouncedWarning(); - /** * @internal * All warnings are expected to come from the same response. @@ -82,10 +59,9 @@ export function handleWarnings({ } const [incompleteWarning] = incompleteWarnings as SearchResponseIncompleteWarning[]; - debouncedIncompleteWarning( - sessionId + incompleteWarning.type, - incompleteWarning.message, - toMountPoint( + getNotifications().toasts.addWarning({ + title: incompleteWarning.message, + text: toMountPoint( , { theme$: theme.theme$ } ) - ); + }); } /** diff --git a/test/examples/search/warnings.ts b/test/examples/search/warnings.ts index 5ec4f59586a13d..dee941b63ef5f4 100644 --- a/test/examples/search/warnings.ts +++ b/test/examples/search/warnings.ts @@ -100,7 +100,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.clearAllToasts(); }); - it('shows shard failure warning notifications by default', async () => { + it('should show search warnings as toasts', async () => { await testSubjects.click('searchSourceWithOther'); // wait for response - toasts appear before the response is rendered @@ -113,30 +113,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // toasts const toasts = await find.allByCssSelector(toastsSelector); expect(toasts.length).to.be(2); - const expects = ['2 of 4 shards failed', 'Query result']; + const expects = ['The data might be incomplete or wrong.', 'Query result']; await asyncForEach(toasts, async (t, index) => { expect(await t.getVisibleText()).to.eql(expects[index]); }); // click "see full error" button in the toast - const [openShardModalButton] = await testSubjects.findAll('openShardFailureModalBtn'); + const [openShardModalButton] = await testSubjects.findAll('openIncompleteResultsModalBtn'); await openShardModalButton.click(); - await retry.waitFor('modal title visible', async () => { - const modalHeader = await testSubjects.find('shardFailureModalTitle'); - return (await modalHeader.getVisibleText()) === '2 of 4 shards failed'; - }); - // request - await testSubjects.click('shardFailuresModalRequestButton'); - const requestBlock = await testSubjects.find('shardsFailedModalRequestBlock'); + await testSubjects.click('showRequestButton'); + const requestBlock = await testSubjects.find('incompleteResultsModalRequestBlock'); expect(await requestBlock.getVisibleText()).to.contain(testRollupField); // response - await testSubjects.click('shardFailuresModalResponseButton'); - const responseBlock = await testSubjects.find('shardsFailedModalResponseBlock'); + await testSubjects.click('showResponseButton'); + const responseBlock = await testSubjects.find('incompleteResultsModalResponseBlock'); expect(await responseBlock.getVisibleText()).to.contain(shardFailureReason); - await testSubjects.click('closeShardFailureModal'); + await testSubjects.click('closeIncompleteResultsModal'); // response tab assert(response && response._shards.failures); @@ -154,7 +149,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(warnings).to.eql([]); }); - it('able to handle shard failure warnings and prevent default notifications', async () => { + it('should show search warnings in results tab', async () => { await testSubjects.click('searchSourceWithoutOther'); // wait for toasts - toasts appear after the response is rendered @@ -163,53 +158,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { toasts = await find.allByCssSelector(toastsSelector); expect(toasts.length).to.be(2); }); - const expects = ['Query result', '2 of 4 shards failed']; + const expects = ['The data might be incomplete or wrong.', 'Query result']; await asyncForEach(toasts, async (t, index) => { expect(await t.getVisibleText()).to.eql(expects[index]); }); - // click "see full error" button in the toast - const [openShardModalButton] = await testSubjects.findAll('openShardFailureModalBtn'); - await openShardModalButton.click(); - await testSubjects.exists('shardFailureModalTitle'); - - await retry.waitFor('modal title visible', async () => { - const modalHeader = await testSubjects.find('shardFailureModalTitle'); - return (await modalHeader.getVisibleText()) === '2 of 4 shards failed'; - }); - - // request - await testSubjects.click('shardFailuresModalRequestButton'); - const requestBlock = await testSubjects.find('shardsFailedModalRequestBlock'); - expect(await requestBlock.getVisibleText()).to.contain(testRollupField); - // response - await testSubjects.click('shardFailuresModalResponseButton'); - const responseBlock = await testSubjects.find('shardsFailedModalResponseBlock'); - expect(await responseBlock.getVisibleText()).to.contain(shardFailureReason); - - await testSubjects.click('closeShardFailureModal'); - - // response tab - const response = await getTestJson('responseTab', 'responseCodeBlock'); - expect(response._shards.total).to.be(4); - expect(response._shards.successful).to.be(2); - expect(response._shards.skipped).to.be(0); - expect(response._shards.failed).to.be(2); - expect(response._shards.failures.length).to.equal(1); - expect(response._shards.failures[0].index).to.equal(testRollupIndex); - expect(response._shards.failures[0].reason.type).to.equal(shardFailureType); - expect(response._shards.failures[0].reason.reason).to.equal(shardFailureReason); - // warnings tab const warnings = await getTestJson('warningsTab', 'warningsCodeBlock'); - expect(warnings).to.eql([ - { - type: 'shard_failure', - message: '2 of 4 shards failed', - reason: { reason: shardFailureReason, type: shardFailureType }, - text: 'The data might be incomplete or wrong.', - }, - ]); + expect(warnings.length).to.be(1); + expect(warnings[0].type).to.be('incomplete'); }); }); } From eb54f573644ca5bf63ff5ab4dc32ded4d584d8aa Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 12 Sep 2023 18:51:55 +0000 Subject: [PATCH 39/43] [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' --- examples/search_examples/public/search/app.tsx | 2 +- src/plugins/data/public/search/fetch/handle_warnings.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/search_examples/public/search/app.tsx b/examples/search_examples/public/search/app.tsx index 5b79b84eb2370a..84bc3e1cd79bea 100644 --- a/examples/search_examples/public/search/app.tsx +++ b/examples/search_examples/public/search/app.tsx @@ -317,7 +317,7 @@ export const SearchExamplesApp = ({ ); setRawResponse(result.rawResponse); - /* + /* * Set disableWarningToasts to true to disable warning toasts and customize warning display. * Then use showWarnings to customize warning notification. */ diff --git a/src/plugins/data/public/search/fetch/handle_warnings.tsx b/src/plugins/data/public/search/fetch/handle_warnings.tsx index aaf43c0e3cd750..3380ffe0c8c99d 100644 --- a/src/plugins/data/public/search/fetch/handle_warnings.tsx +++ b/src/plugins/data/public/search/fetch/handle_warnings.tsx @@ -73,7 +73,7 @@ export function handleWarnings({ /> , { theme$: theme.theme$ } - ) + ), }); } From 8f4f8cfa0ae5db6ca96e6e4c21843793e650532c Mon Sep 17 00:00:00 2001 From: nreese Date: Wed, 13 Sep 2023 12:09:21 -0600 Subject: [PATCH 40/43] change callout close button color to warning to match callout --- .../__snapshots__/search_response_warnings.test.tsx.snap | 2 +- .../search_response_warnings/search_response_warnings.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap b/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap index 6c5ac2eac1ceb2..079d3d9b90b069 100644 --- a/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap +++ b/packages/kbn-search-response-warnings/src/components/search_response_warnings/__snapshots__/search_response_warnings.test.tsx.snap @@ -85,7 +85,7 @@ exports[`SearchResponseWarnings renders "callout" correctly 1`] = ` >