Skip to content

Commit e36bbd5

Browse files
committed
Do not render descriptionless actions within an EuiCard
This updates the logic of EmptyPage to better handle these cases. Adds snapshot tests to verify.
1 parent 774d359 commit e36bbd5

3 files changed

Lines changed: 60 additions & 23 deletions

File tree

x-pack/plugins/security_solution/public/common/components/empty_page/__snapshots__/index.test.tsx.snap

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/security_solution/public/common/components/empty_page/index.test.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@ import React from 'react';
99

1010
import { EmptyPage } from './index';
1111

12-
test('renders correctly', () => {
13-
const actions = {
14-
actions: {
15-
label: 'Do Something',
16-
url: 'my/url/from/nowwhere',
17-
},
18-
};
19-
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
20-
expect(EmptyComponent).toMatchSnapshot();
12+
describe('EmptyPage component', () => {
13+
it('renders actions without descriptions', () => {
14+
const actions = {
15+
actions: {
16+
label: 'Do Something',
17+
url: 'my/url/from/nowwhere',
18+
},
19+
};
20+
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
21+
expect(EmptyComponent).toMatchSnapshot();
22+
});
23+
24+
it('renders actions with descriptions', () => {
25+
const actions = {
26+
actions: {
27+
description: 'My Description',
28+
label: 'Do Something',
29+
url: 'my/url/from/nowwhere',
30+
},
31+
};
32+
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
33+
expect(EmptyComponent).toMatchSnapshot();
34+
});
2135
});

x-pack/plugins/security_solution/public/common/components/empty_page/index.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,7 @@ const EmptyPageComponent = React.memo<EmptyPageProps>(({ actions, message, title
5151
.filter((a) => a.label && a.url)
5252
.map(
5353
(
54-
{
55-
icon,
56-
label,
57-
target,
58-
url,
59-
descriptionTitle = false,
60-
description = false,
61-
onClick,
62-
fill = true,
63-
},
54+
{ icon, label, target, url, descriptionTitle, description, onClick, fill = true },
6455
idx
6556
) =>
6657
descriptionTitle != null || description != null ? (
@@ -70,8 +61,8 @@ const EmptyPageComponent = React.memo<EmptyPageProps>(({ actions, message, title
7061
key={`empty-page-${titles[idx]}-action`}
7162
>
7263
<EuiCard
73-
title={descriptionTitle}
74-
description={description}
64+
title={descriptionTitle ?? false}
65+
description={description ?? false}
7566
footer={
7667
/* eslint-disable-next-line @elastic/eui/href-or-on-click */
7768
<EuiButton

0 commit comments

Comments
 (0)