Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.16] [data.search] Remove warning toast (#117252) #118246

Merged
merged 3 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}