From 0f94dc9f6a67c8c77a91ae2bd69b7cdaee23e8eb Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Thu, 11 Nov 2021 18:25:35 -0700 Subject: [PATCH] [data.search] Remove warning toast (#117252) (#118246) * [data.search] Remove toast notification for warnings * Update docs * Review feedback Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # src/plugins/data/public/search/fetch/handle_response.tsx Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- src/plugins/data/common/search/types.ts | 2 +- .../search/fetch/handle_response.test.ts | 25 ------------------- .../public/search/fetch/handle_response.tsx | 19 +------------- 3 files changed, 2 insertions(+), 44 deletions(-) diff --git a/src/plugins/data/common/search/types.ts b/src/plugins/data/common/search/types.ts index 68a25d4c4d69d..e9b6160c4a75a 100644 --- a/src/plugins/data/common/search/types.ts +++ b/src/plugins/data/common/search/types.ts @@ -71,7 +71,7 @@ export interface IKibanaSearchResponse { isRestored?: boolean; /** - * Optional warnings that should be surfaced to the end user + * Optional warnings returned from Elasticsearch (for example, deprecation warnings) */ warning?: string; diff --git a/src/plugins/data/public/search/fetch/handle_response.test.ts b/src/plugins/data/public/search/fetch/handle_response.test.ts index aca3d3e35073c..b405f3d62b492 100644 --- a/src/plugins/data/public/search/fetch/handle_response.test.ts +++ b/src/plugins/data/public/search/fetch/handle_response.test.ts @@ -65,29 +65,4 @@ describe('handleResponse', () => { const result = handleResponse(request, response); expect(result).toBe(response); }); - - test('should notify if has warning', () => { - const request = { body: {} }; - const response = { - rawResponse: {}, - warning: 'a warning', - } as IKibanaSearchResponse; - const result = handleResponse(request, response); - expect(result).toBe(response); - expect(notifications.toasts.addWarning).toBeCalledWith( - expect.objectContaining({ title: expect.stringContaining(response.warning!) }) - ); - }); - - test("shouldn't notify on warning about disabled security", () => { - const request = { body: {} }; - const response = { - rawResponse: {}, - warning: - '299 Elasticsearch-7.16.0-SNAPSHOT-3e6393bc4ec8f0000b1bcd4371b2e607eb02a1d7 "Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.16/security-minimal-setup.html to enable security."', - } as IKibanaSearchResponse; - const result = handleResponse(request, response); - expect(result).toBe(response); - expect(notifications.toasts.addWarning).not.toBeCalled(); - }); }); diff --git a/src/plugins/data/public/search/fetch/handle_response.tsx b/src/plugins/data/public/search/fetch/handle_response.tsx index c82479bcbfea9..9e68209af2b92 100644 --- a/src/plugins/data/public/search/fetch/handle_response.tsx +++ b/src/plugins/data/public/search/fetch/handle_response.tsx @@ -16,17 +16,7 @@ import { getNotifications } from '../../services'; import { SearchRequest } from '..'; export function handleResponse(request: SearchRequest, response: IKibanaSearchResponse) { - const { rawResponse, warning } = response; - if (warning && !shouldIgnoreWarning(warning)) { - getNotifications().toasts.addWarning({ - title: i18n.translate('data.search.searchSource.fetch.warningMessage', { - defaultMessage: 'Warning: {warning}', - values: { - warning, - }, - }), - }); - } + const { rawResponse } = response; if (rawResponse.timed_out) { getNotifications().toasts.addWarning({ @@ -64,10 +54,3 @@ export function handleResponse(request: SearchRequest, response: IKibanaSearchRe return response; } - -function shouldIgnoreWarning(warning: string): boolean { - // https://github.com/elastic/kibana/issues/115632 - if (warning.includes('Elasticsearch built-in security features are not enabled')) return true; - - return false; -}