Skip to content

Commit

Permalink
[data.search] Remove warning toast (#117252) (#118246)
Browse files Browse the repository at this point in the history
* [data.search] Remove toast notification for warnings

* Update docs

* Review feedback

Co-authored-by: Kibana Machine <[email protected]>
# Conflicts:
#	src/plugins/data/public/search/fetch/handle_response.tsx

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
lukasolson and kibanamachine authored Nov 12, 2021
1 parent 35eb5ba commit 0f94dc9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/plugins/data/common/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export interface IKibanaSearchResponse<RawResponse = any> {
isRestored?: boolean;

/**
* Optional warnings that should be surfaced to the end user
* Optional warnings returned from Elasticsearch (for example, deprecation warnings)
*/
warning?: string;

Expand Down
25 changes: 0 additions & 25 deletions src/plugins/data/public/search/fetch/handle_response.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>;
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<any>;
const result = handleResponse(request, response);
expect(result).toBe(response);
expect(notifications.toasts.addWarning).not.toBeCalled();
});
});
19 changes: 1 addition & 18 deletions src/plugins/data/public/search/fetch/handle_response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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;
}

0 comments on commit 0f94dc9

Please sign in to comment.