Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SharedUX] Migrate PageTemplate > NoData Page #128372

Merged
merged 28 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 } 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 @@ -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,34 @@
/*
* 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'>;

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

PureComponent.argTypes = {
solution: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Can we add a logo control that is blank by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

control: 'text',
defaultValue: 'Observability',
},
};
Loading