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

Conversation

majagrubic
Copy link
Contributor

@majagrubic majagrubic commented Mar 23, 2022

Summary

This PR migrates NoDataPage from kibana_react to shared_ux. After an offline sync with @cchaos, there are a few notable changes:

  1. The page is intended to only render one card, not an array of cards as previously; all the props and logic have been updated to follow this
  2. The card is going to exclusively be ElasticAgentCard, not NoDataCard as previously. This has also been updated in props definition (but leaving NoData card now in the repo for now, will be removed in a subsequent PR)
  3. recommended prop on the card is not needed and it won't be used

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@majagrubic majagrubic added Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.2.0 labels Mar 29, 2022
@majagrubic majagrubic marked this pull request as ready for review March 29, 2022 07:56
@majagrubic majagrubic requested review from cchaos and a team March 29, 2022 07:56
@majagrubic majagrubic added the release_note:skip Skip the PR/issue when compiling release notes label Mar 29, 2022
@majagrubic majagrubic added v8.3.0 and removed v8.2.0 labels Mar 29, 2022
Comment on lines 12 to 25
export type NoDataPageActions = Partial<EuiCardProps> & {
/**
* Provide just a string for the button's label, or a whole component
*/
button?: string | ReactNode;
/**
* Remapping `onClick` to any element
*/
onClick?: MouseEventHandler<HTMLElement>;
/**
* Category to auto-select within Fleet
*/
category?: string;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

These are actually extending ElasticAgentCardProps without the description. Maybe we can just extend otherwise we'll need to keep the props and descriptions in sync?

Suggested change
export type NoDataPageActions = Partial<EuiCardProps> & {
/**
* Provide just a string for the button's label, or a whole component
*/
button?: string | ReactNode;
/**
* Remapping `onClick` to any element
*/
onClick?: MouseEventHandler<HTMLElement>;
/**
* Category to auto-select within Fleet
*/
category?: string;
};
export type NoDataPageActions = Omit<ElasticAgentCardProps, 'description'>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

const actionCard = <div key={'action'}>{el}</div>;
test('render', () => {
const component = shallowWithIntl(
<NoDataPageBody solution="Elastic" docsLink="test" actionCard={actionCard} logo={'elastic'} />
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
<NoDataPageBody solution="Elastic" docsLink="test" actionCard={actionCard} logo={'elastic'} />
<NoDataPageBody solution="Analytics" docsLink="test" actionCard={actionCard} logo={'logoKibana'} />

<EuiSpacer
size="l"
/>
<h1 />
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, looks like we should either be requiring a pageTitle in NoDataPageBody or ensuring an empty h1 is not rendered if there is no pageTitle.

Comment on lines 44 to 52
<div {...rest}>
<NoDataPageBody
pageTitle={title}
actionCard={actionCard}
logo={logo}
solution={solution}
docsLink={docsLink}
/>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest, do we really need this component? All it's doing is some string creation and passing it along to the NoDataPageBody component that needs them to render properly anyway. Seems like it's an extra wrapper that is no longer necessary and we can just move all the title stuff directly into NoDataPageBody.

Copy link
Contributor Author

@majagrubic majagrubic Mar 31, 2022

Choose a reason for hiding this comment

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

I hope you meant the other way around 😅 I removed the NoDataPageBody component, making it all part of NoDataPage component. This also fixed the issue with the title, as it turns out we were already setting a default title in there in case none was provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah either way really. The NoDataPage at this time didn't have much in it

</EuiTextColor>
</EuiText>
<EuiSpacer size="xxl" />
{actionCard}
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to add margin-inline: auto to the card itself to ensure it gets centered horizontally.

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@majagrubic majagrubic requested a review from cchaos March 31, 2022 13:20
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.

LGTM. I did notice we have some issues in Storybook with custom styles and dark mode which I mentioned in the storybook slack channel.

I just had one extra suggestion for another control, but mergeable either way.

};

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!

@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 79069d8 into elastic:main Mar 31, 2022
@majagrubic majagrubic deleted the page-template-4 branch March 31, 2022 17:09
@kibanamachine
Copy link
Contributor

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

@kibanamachine kibanamachine added backport missing Added to PRs automatically when the are determined to be missing a backport. backport:skip This commit does not require backporting and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Apr 4, 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.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants