Skip to content

Commit

Permalink
Do not render descriptionless actions within an EuiCard (#73611)
Browse files Browse the repository at this point in the history
This updates the logic of EmptyPage to better handle these cases. Adds
snapshot tests to verify.
  • Loading branch information
rylnd committed Jul 29, 2020
1 parent 36d5391 commit 4cc87e3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ import React from 'react';

import { EmptyPage } from './index';

test('renders correctly', () => {
const actions = {
actions: {
label: 'Do Something',
url: 'my/url/from/nowwhere',
},
};
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
expect(EmptyComponent).toMatchSnapshot();
describe('EmptyPage component', () => {
it('renders actions without descriptions', () => {
const actions = {
actions: {
label: 'Do Something',
url: 'my/url/from/nowwhere',
},
};
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
expect(EmptyComponent).toMatchSnapshot();
});

it('renders actions with descriptions', () => {
const actions = {
actions: {
description: 'My Description',
label: 'Do Something',
url: 'my/url/from/nowwhere',
},
};
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
expect(EmptyComponent).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,7 @@ const EmptyPageComponent = React.memo<EmptyPageProps>(({ actions, message, title
.filter((a) => a.label && a.url)
.map(
(
{
icon,
label,
target,
url,
descriptionTitle = false,
description = false,
onClick,
fill = true,
},
{ icon, label, target, url, descriptionTitle, description, onClick, fill = true },
idx
) =>
descriptionTitle != null || description != null ? (
Expand All @@ -70,8 +61,8 @@ const EmptyPageComponent = React.memo<EmptyPageProps>(({ actions, message, title
key={`empty-page-${titles[idx]}-action`}
>
<EuiCard
title={descriptionTitle}
description={description}
title={descriptionTitle ?? false}
description={description ?? false}
footer={
/* eslint-disable-next-line @elastic/eui/href-or-on-click */
<EuiButton
Expand Down

0 comments on commit 4cc87e3

Please sign in to comment.