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 > NoDataPage > NoDataCard #127025

Merged
merged 10 commits into from
Mar 9, 2022

Conversation

majagrubic
Copy link
Contributor

@majagrubic majagrubic commented Mar 7, 2022

Summary

This is a first PR in migrating PageTemplate from kibana_react to shared_ux plugin. This PR tackles NoDataCard component. It is not exported from the plugin, as it's not used outside of PageTemplate.

Part of #122961

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@majagrubic majagrubic changed the title [SharedUX] Migrate PageTemplate > NoData > NoDataCard [SharedUX] Migrate PageTemplate > NoDataPage > NoDataCard Mar 7, 2022
@majagrubic majagrubic added Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) release_note:skip Skip the PR/issue when compiling release notes v8.2.0 labels Mar 7, 2022
@majagrubic majagrubic marked this pull request as ready for review March 7, 2022 16:47
@majagrubic majagrubic requested a review from a team March 7, 2022 16:47
@majagrubic majagrubic requested a review from a team as a code owner March 7, 2022 16:47
@majagrubic majagrubic requested a review from rshen91 March 7, 2022 16:47
Copy link
Contributor

@rshen91 rshen91 left a comment

Choose a reason for hiding this comment

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

Tested locally - great storybook addition! LGTM

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Just a couple quick comments, but in general should there also be Markdown docs pages being created next to these components?

import { EuiCardProps } from '@elastic/eui';
import { MouseEventHandler, ReactNode } from 'react';

export type NoDataPageActions = Partial<EuiCardProps> & {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why separate the component type into a separate file?

Also since it's the direct props of NoDataCard, let's name it consistently:

Suggested change
export type NoDataPageActions = Partial<EuiCardProps> & {
export type NoDataCardProps = Partial<EuiCardProps> & {

Copy link
Contributor Author

@majagrubic majagrubic Mar 7, 2022

Choose a reason for hiding this comment

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

Because this type will be reused for ElasticAgentCard once I migrate it over, so that component can read from types file as well.

/**
* Applies the `Recommended` beta badge and makes the button `fill`
*/
recommended?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
recommended?: boolean;
isRecommended?: boolean;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to be changing prop names at this time, as I don't know where down the line in PageTemplate is this component used, and renaming them all will add additional work.

/**
* Provide just a string for the button's label, or a whole component
*/
button?: string | ReactNode;
Copy link
Contributor

Choose a reason for hiding this comment

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

@cchaos How does EUI handle this kind of flexibility? Is there a pattern?

@majagrubic Be sure this is the TS type you want to use.

https://dev.to/fromaline/jsxelement-vs-reactelement-vs-reactnode-2mh2
https://github.com/typescript-cheatsheets/react#useful-react-prop-type-examples

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure there's a specific pattern, but the idea here is that the consumer can supply just the button label (string) or replace the whole button their own (in case they don't want to use the same medium, filled button). I guess technically string is included in ReactNode, so maybe that's duplicative. But I think the explicitness here is helpful because an element would replace the whole default EuiButton where the string is just the label. Up to you all if you think there's a better pattern.

Copy link
Contributor

@clintandrewhall clintandrewhall Mar 7, 2022

Choose a reason for hiding this comment

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

I guess I was thinking maybe string | EuiButtonProps.

<Card button="Click Me" />
<Card button={{ label: 'Click Me', onClick: () => {}, fill: true }} />

Then we'd have some control over precisely what component we rendered there, and could force a fill or color to keep the usage consistent, now or in the future.

It's probably minor, but I'm one who leans toward keeping the contract strict at the start, and then expanding outward as necessary, to avoid large-scale refactors later.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could do that. But specifically EuiButton doesn't have a label prop, it's label is just the children, so you'd likely need to append this prop type or rely on consumers to pass children as a key.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, I think the problem with that, that I'm now remembering, is that you can't go from say an EuiButton to EuiEmptyButton by props alone since they're completely different components. So an example is if the footer button is actually not a CTA we want to promote, or say we need to provide 2 actions instead of just one, there's no way to remove the default button without replacing it completely with a ReactNode.

@majagrubic
Copy link
Contributor Author

@clintandrewhall do you know how and why app-services got automatically tagged for a review of this?

@majagrubic majagrubic force-pushed the shared-ux/no-data-card branch from c55c35b to ba87e76 Compare March 8, 2022 11:07
@majagrubic majagrubic force-pushed the shared-ux/no-data-card branch from ba87e76 to 112e6d9 Compare March 8, 2022 11:08
@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@majagrubic majagrubic requested a review from cchaos March 9, 2022 06:34
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Thanks @majagrubic !

…page/no_data_card/no_data_card.stories.tsx

Co-authored-by: Caroline Horn <[email protected]>
@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@majagrubic majagrubic merged commit 8782ced into elastic:main Mar 9, 2022
@majagrubic majagrubic deleted the shared-ux/no-data-card branch March 9, 2022 19:46
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 127025 or prevent reminders by adding the backport:skip label.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 11, 2022
@clintandrewhall clintandrewhall added the backport:skip This commit does not require backporting label Mar 11, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants