Skip to content

Commit

Permalink
[SharedUX] Migrate PageTemplate > NoData Page (#128372)
Browse files Browse the repository at this point in the history
* [SharedUX] Migrate PageTemplate > NoDataPage > ActionCards

* [SharedUX] Migrate PageTemplate > NoDataPage > SolutionNav

* Updating snapshot

* [SharedUX] Migrate PageTemplate > NoDataPage

* Removing actionCards

* [SharedUX] Migrate PageTemplate > SolutionNavAvatar

* Fix comment

* Renaming component

* Fix folder structure

* Fix storybook

* Style fix

* Update so the component now uses the SolutionAvatar

* Fix props

* Remove unnecessary types files

* Fix failing test

* Updating failed test

* Fix obsolete snapshot

* Applying PR comments

* Update failing snapshot

* Update failing snapshot

* Add logo as an argtype

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Maja Grubic and kibanamachine authored Mar 31, 2022
1 parent a2b9070 commit 79069d8
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*/

export { NoDataCard, ElasticAgentCard } from './no_data_page';
export { NoDataPage } from './no_data_page';

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 @@ -7,3 +7,5 @@
*/

export { NoDataCard, ElasticAgentCard } from './no_data_card';
export { NoDataPage } from './no_data_page';
export type { NoDataPageProps } from './types';

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

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

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 @@ -40,19 +40,6 @@ describe('ElasticAgentCardComponent', () => {
});

describe('props', () => {
test('recommended', () => {
const component = shallow(
<ElasticAgentCardComponent
recommended
canAccessFleet={true}
navigateToUrl={navigateToUrl}
currentAppId$={currentAppId$}
/>
);
expect(component.find(NoDataCard).props().recommended).toBe(true);
expect(component).toMatchSnapshot();
});

test('button', () => {
const component = shallow(
<ElasticAgentCardComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from './elastic_agent_card.component';

export default {
title: 'Elastic Agent Data Card',
title: 'Page Template/No Data Page/Elastic Agent Data Card',
description: 'A solution-specific wrapper around NoDataCard, to be used on NoData page',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*/
export { NoDataCard } from './no_data_card';
export { ElasticAgentCard } from './elastic_agent_card';
export type { NoDataCardProps, ElasticAgentCardProps } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ import { NoDataCard } from './no_data_card';
import type { NoDataCardProps } from './types';

export default {
title: 'No Data Card',
title: 'Page Template/No Data Page/No Data Card',
description: 'A wrapper around EuiCard, to be used on NoData page',
};

type Params = Pick<NoDataCardProps, 'recommended' | 'button' | 'description'>;
type Params = Pick<NoDataCardProps, 'button' | 'description'>;

export const PureComponent = (params: Params) => {
return <NoDataCard title={'Add data'} {...params} />;
};

PureComponent.argTypes = {
recommended: {
control: 'boolean',
defaultValue: false,
},
button: {
control: {
type: 'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const NO_DATA_CARD_MAX_WIDTH = 400;
export const NoDataCardStyles = () => {
return {
maxWidth: NO_DATA_CARD_MAX_WIDTH,
marginInline: 'auto',
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ describe('NoDataCard', () => {
});

describe('props', () => {
test('recommended', () => {
const component = render(
<NoDataCard recommended title="Card title" description="Description" />
);
expect(component).toMatchSnapshot();
});

test('button', () => {
const component = render(
<NoDataCard button="Button" title="Card title" description="Description" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ import { EuiButton, EuiCard } from '@elastic/eui';
import type { NoDataCardProps } from './types';
import { NoDataCardStyles } from './no_data_card.styles';

const recommendedLabel = i18n.translate(
'sharedUXComponents.pageTemplate.noDataPage.recommendedLabel',
{
defaultMessage: 'Recommended',
}
);

const defaultDescription = i18n.translate(
'sharedUXComponents.pageTemplate.noDataCard.description',
{
Expand All @@ -28,7 +21,6 @@ const defaultDescription = i18n.translate(
);

export const NoDataCard: FunctionComponent<NoDataCardProps> = ({
recommended,
title,
button,
description,
Expand All @@ -49,7 +41,6 @@ export const NoDataCard: FunctionComponent<NoDataCardProps> = ({
// Default footer action is a button with the provided or default string
return <EuiButton fill>{button || title}</EuiButton>;
};
const label = recommended ? recommendedLabel : undefined;
const cardDescription = description || defaultDescription;

return (
Expand All @@ -58,7 +49,6 @@ export const NoDataCard: FunctionComponent<NoDataCardProps> = ({
paddingSize="l"
title={title!}
description={cardDescription}
betaBadgeProps={{ label }}
footer={footer()}
isDisabled={isDisabled}
{...cardRest}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { EuiCardProps } from '@elastic/eui';
import { MouseEventHandler, ReactNode } from 'react';

export type NoDataCardProps = Partial<Omit<EuiCardProps, 'layout'>> & {
/**
* Applies the `Recommended` beta badge and makes the button `fill`
*/
recommended?: boolean;
/**
* Provide just a string for the button's label, or a whole component;
* The button will be hidden completely if `isDisabled=true`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 { servicesFactory } from '@kbn/shared-ux-storybook';
import { NoDataPageProps } from './types';
import { NoDataPage } from './no_data_page';

const services = servicesFactory({});

export default {
title: 'Page Template/No Data Page/No Data Page',
description: 'No Data Page of PageTemplate',
};
const action = {
elasticAgent: {},
};
type Params = Pick<NoDataPageProps, 'solution' | 'logo'>;

export const PureComponent = (params: Params) => {
return <NoDataPage docsLink={services.docLinks.dataViewsDocLink} action={action} {...params} />;
};

PureComponent.argTypes = {
solution: {
control: 'text',
defaultValue: 'Observability',
},
logo: {
control: { type: 'radio' },
options: ['logoElastic', 'logoKibana', 'logoCloud', undefined],
defaultValue: undefined,
},
};
Loading

0 comments on commit 79069d8

Please sign in to comment.