Skip to content

Commit

Permalink
[Cases] Show a tooltip with all tags when tags are hovered in the cas…
Browse files Browse the repository at this point in the history
…es list (#132023)
  • Loading branch information
academo authored May 12, 2022
1 parent cb83c9a commit ba96eef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,24 @@ describe('AllCasesListGeneric', () => {
});
});

it('should show a tooltip with all tags when hovered', async () => {
useGetCasesMock.mockReturnValue({
...defaultGetCases,
filterOptions: { ...defaultGetCases.filterOptions, status: CaseStatuses.open },
});
const result = render(
<TestProviders>
<AllCasesList />
</TestProviders>
);

userEvent.hover(result.queryAllByTestId('case-table-column-tags')[0]);

await waitFor(() => {
expect(result.getByTestId('case-table-column-tags-tooltip')).toBeTruthy();
});
});

it('should render empty fields', async () => {
useGetCasesMock.mockReturnValue({
...defaultGetCases,
Expand Down
21 changes: 14 additions & 7 deletions x-pack/plugins/cases/public/components/all_cases/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
EuiFlexItem,
EuiIcon,
EuiHealth,
EuiToolTip,
} from '@elastic/eui';
import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services';
import styled from 'styled-components';
Expand Down Expand Up @@ -56,10 +57,6 @@ const Spacer = styled.span`
margin-left: ${({ theme }) => theme.eui.paddingSizes.s};
`;

const TagWrapper = styled(EuiBadgeGroup)`
width: 100%;
`;

const renderStringField = (field: string, dataTestSubj: string) =>
field != null ? <span data-test-subj={dataTestSubj}>{field}</span> : getEmptyTagValue();

Expand Down Expand Up @@ -205,8 +202,8 @@ export const useCasesColumns = ({
name: i18n.TAGS,
render: (tags: Case['tags']) => {
if (tags != null && tags.length > 0) {
return (
<TagWrapper>
const badges = (
<EuiBadgeGroup data-test-subj="case-table-column-tags">
{tags.map((tag: string, i: number) => (
<EuiBadge
color="hollow"
Expand All @@ -216,7 +213,17 @@ export const useCasesColumns = ({
{tag}
</EuiBadge>
))}
</TagWrapper>
</EuiBadgeGroup>
);

return (
<EuiToolTip
data-test-subj="case-table-column-tags-tooltip"
position="left"
content={badges}
>
{badges}
</EuiToolTip>
);
}
return getEmptyTagValue();
Expand Down

0 comments on commit ba96eef

Please sign in to comment.