Skip to content

Commit

Permalink
Do not render descriptionless actions within an EuiCard (elastic#73611)…
Browse files Browse the repository at this point in the history
… (elastic#73624)

This updates the logic of EmptyPage to better handle these cases. Adds
snapshot tests to verify.
  • Loading branch information
rylnd authored Jul 29, 2020
1 parent 3594da6 commit 62e8e98
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 62e8e98

Please sign in to comment.