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

Update incomplete data messaging #169578

Merged
merged 55 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e97f27a
Update incomplete data messaging
nreese Oct 23, 2023
3fe0b3c
fix console log errors by having div elements in callout title
nreese Oct 23, 2023
1c480e9
replace first 'results' with 'data'
nreese Oct 23, 2023
e07554c
toggle popover on button click
nreese Oct 23, 2023
b0d0340
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 23, 2023
67a6ae5
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 23, 2023
417af98
pass request name extractWarnings
nreese Oct 23, 2023
1ab8ac4
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 23, 2023
7f9316a
empty_prompt
nreese Oct 24, 2023
68ae8cb
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 24, 2023
95add46
move button to actions
nreese Oct 24, 2023
0872c80
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 24, 2023
852594e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 24, 2023
32c212b
bagde
nreese Oct 24, 2023
819588f
clean up
nreese Oct 24, 2023
b0d06b4
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 24, 2023
17d2f1b
update lens to use SearchResponseWarningsBadgePopoverContent
nreese Oct 24, 2023
f9a8a38
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 24, 2023
8e1530e
toast
nreese Oct 24, 2023
6e9c091
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 24, 2023
af40b7a
remove message field from warning
nreese Oct 24, 2023
e204e90
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 24, 2023
331ca61
tslint
nreese Oct 24, 2023
8410a96
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 24, 2023
ca293fc
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 24, 2023
df755a4
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 24, 2023
ed11c2d
tslint
nreese Oct 25, 2023
3d3d0f5
add unit test for ViewDetailsPopover
nreese Oct 25, 2023
77b3255
fix context_app_content.test
nreese Oct 25, 2023
e7fe760
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 25, 2023
1772e72
tslint
nreese Oct 25, 2023
17642a6
fix functional test
nreese Oct 25, 2023
2bfd4b1
more test clean up
nreese Oct 25, 2023
b1f7280
badge_popover_content unit test
nreese Oct 25, 2023
a84131b
clean up
nreese Oct 25, 2023
4fbb267
move hooks to top of component
nreese Oct 25, 2023
fbca5eb
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 25, 2023
9d06be9
Merge branch 'main' into issue_167906
kibanamachine Oct 25, 2023
163a1ab
fix search source examples functional test
nreese Oct 25, 2023
a8bca8c
fix search source example serverless tests
nreese Oct 25, 2023
adb8894
remove extra click
nreese Oct 25, 2023
1abff15
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 25, 2023
72066e0
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 25, 2023
b0d9515
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 25, 2023
ea2a25c
review feedback
nreese Oct 26, 2023
d6aaece
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 26, 2023
95e0c96
Merge branch 'main' into issue_167906
kibanamachine Oct 26, 2023
e15b99b
copy update
nreese Oct 26, 2023
ed41860
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 26, 2023
d03388a
display 'View details' action as button in empty prompt
nreese Oct 26, 2023
f0a6f43
refactor ViewDetailsPopover
nreese Oct 26, 2023
8e751f5
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 26, 2023
a081be4
esnure unique request name
nreese Oct 26, 2023
dca5845
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 26, 2023
18d8b08
tslint
nreese Oct 26, 2023
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
7 changes: 4 additions & 3 deletions packages/kbn-search-response-warnings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
export type { SearchResponseWarning, WarningHandlerCallback } from './src/types';

export {
SearchResponseWarnings,
type SearchResponseWarningsProps,
SearchResponseWarningsBadge,
SearchResponseWarningsBadgePopoverContent,
SearchResponseWarningsCallout,
SearchResponseWarningsEmptyPrompt,
} from './src/components/search_response_warnings';
export { ViewWarningButton } from './src/components/view_warning_button';

export { handleWarnings } from './src/handle_warnings';
export { hasUnsupportedDownsampledAggregationFailure } from './src/has_unsupported_downsampled_aggregation_failure';
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { SearchResponseWarning } from '../types';

export const searchResponseIncompleteWarningLocalCluster: SearchResponseWarning = {
type: 'incomplete',
message: 'The data might be incomplete or wrong.',
requestName: 'My request',
clusters: {
'(local)': {
status: 'partial',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { css } from '@emotion/react';
import { EuiButton, EuiIcon, EuiPopover, useEuiTheme, useEuiFontSize } from '@elastic/eui';
import { SearchResponseWarningsBadgePopoverContent } from './badge_popover_content';
import type { SearchResponseWarning } from '../../types';

interface Props {
warnings: SearchResponseWarning[];
}

export const SearchResponseWarningsBadge = (props: Props) => {
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
const { euiTheme } = useEuiTheme();
const xsFontSize = useEuiFontSize('xs').fontSize;

if (!props.warnings.length) {
return null;
}

return (
<EuiPopover
nreese marked this conversation as resolved.
Show resolved Hide resolved
panelPaddingSize="none"
button={
<EuiButton
minWidth={0}
size="s"
color="warning"
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
data-test-subj="searchResponseWarningsBadgeToogleButton"
title={i18n.translate('searchResponseWarnings.badgeButtonLabel', {
defaultMessage: '{warningCount} {warningCount, plural, one {warning} other {warnings}}',
values: {
warningCount: props.warnings.length,
},
})}
css={css`
block-size: ${euiTheme.size.l};
font-size: ${xsFontSize};
padding: 0 ${euiTheme.size.xs};
& > * {
gap: ${euiTheme.size.xs};
}
`}
>
<EuiIcon
type="warning"
css={css`
margin-left: ${euiTheme.size.xxs};
`}
/>
{props.warnings.length}
</EuiButton>
}
isOpen={isPopoverOpen}
closePopover={() => setIsPopoverOpen(false)}
>
<SearchResponseWarningsBadgePopoverContent
onViewDetailsClick={() => {
setIsPopoverOpen(false);
}}
warnings={props.warnings}
/>
</EuiPopover>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* 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 { render, screen, fireEvent } from '@testing-library/react';
import { SearchResponseWarningsBadgePopoverContent } from './badge_popover_content';
import type { SearchResponseWarning } from '../../types';

describe('SearchResponseWarningsBadgePopoverContent', () => {
describe('single warning', () => {
test('Clicking "view details" should open warning details', () => {
const mockOpenInInspector = jest.fn();
const mockOnViewDetailsClick = jest.fn();
const warnings = [
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
indices: '',
timed_out: false,
},
},
openInInspector: mockOpenInInspector,
} as SearchResponseWarning,
];
render(
<SearchResponseWarningsBadgePopoverContent
onViewDetailsClick={mockOnViewDetailsClick}
warnings={warnings}
/>
);
const viewDetailsButton = screen.getByRole('button');
fireEvent.click(viewDetailsButton);
expect(mockOpenInInspector).toHaveBeenCalled();
expect(mockOnViewDetailsClick).toHaveBeenCalled();
});
});

describe('multiple warnings', () => {
const request1MockOpenInInspector = jest.fn();
const request2MockOpenInInspector = jest.fn();
const warnings = [
{
type: 'incomplete',
requestName: 'My first request',
clusters: {
remote1: {
status: 'partial',
indices: '',
timed_out: false,
},
},
openInInspector: request1MockOpenInInspector,
} as SearchResponseWarning,
{
type: 'incomplete',
requestName: 'My second request',
clusters: {
remote1: {
status: 'partial',
indices: '',
timed_out: false,
},
},
openInInspector: request2MockOpenInInspector,
} as SearchResponseWarning,
];

beforeEach(() => {
request1MockOpenInInspector.mockReset();
request2MockOpenInInspector.mockReset();
});

test('Clicking "view details" should open content panel with button to view details for each warning', () => {
const mockOnViewDetailsClick = jest.fn();
render(
<SearchResponseWarningsBadgePopoverContent
onViewDetailsClick={mockOnViewDetailsClick}
warnings={warnings}
/>
);
const viewDetailsButton = screen.getByRole('button');
fireEvent.click(viewDetailsButton);
expect(request1MockOpenInInspector).not.toHaveBeenCalled();
expect(request2MockOpenInInspector).not.toHaveBeenCalled();
expect(mockOnViewDetailsClick).not.toHaveBeenCalled();

const openRequest1Button = screen.getByRole('button', { name: 'My first request' });
fireEvent.click(openRequest1Button);
expect(request1MockOpenInInspector).toHaveBeenCalled();
expect(mockOnViewDetailsClick).toHaveBeenCalled();
expect(request2MockOpenInInspector).not.toHaveBeenCalled();
});

test('Should ensure unique request names by numbering duplicate request names', () => {
const warningsWithDuplicateRequestNames = warnings.map((warning) => {
return {
...warning,
requestName: 'Request',
};
});
render(
<SearchResponseWarningsBadgePopoverContent warnings={warningsWithDuplicateRequestNames} />
);
const viewDetailsButton = screen.getByRole('button');
fireEvent.click(viewDetailsButton);

screen.getByRole('button', { name: 'Request' });
screen.getByRole('button', { name: 'Request (2)' });
});
});
});
Loading
Loading