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 component #129323

Merged
merged 51 commits into from
Apr 11, 2022

Conversation

majagrubic
Copy link
Contributor

@majagrubic majagrubic commented Apr 4, 2022

Summary

This is the last PR in the series of migrating PageTemplate components. It migrates the actual PageTemplate component from kibana_react, adds more tests and storybook files. There are no major changes in the functionality.

Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

  • Unit or functional tests were updated or added to match the most common scenarios
  • Any UI touched in this PR is usable by keyboard only (learn more about keyboard accessibility)
  • Any UI touched in this PR does not create any new axe failures (run axe in browser: FF, Chrome)
    - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
    - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this in your browser)
  • This was checked for cross-browser compatibility

For maintainers

@majagrubic majagrubic added v8.3.0 Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) release_note:skip Skip the PR/issue when compiling release notes and removed v7.3.0 labels Apr 4, 2022
@majagrubic majagrubic marked this pull request as ready for review April 4, 2022 13:10
@majagrubic majagrubic requested a review from a team as a code owner April 4, 2022 13:10
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.

To be honest, all these configurations still feel more complicated than they need to be. But since this is just a complete copy over from the kibana_react version, we can optimize later once I've finished all my work on EuiPageTemplate (still working through smaller PR's; gonna be a while). But I don't want to block getting the NoDataPage into Analytics.

Pushed a small design fixes commit

tags: ['shared-ux', 'component']
date: 2022-04-04
---
This component is a thin wrapper around `EuiTemplate`, providing Kibana-specific additions. It can be configured to display solution navigation bar, empty page and no data config page.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're mostly copying right now, can we copy/paste the existing doc for KibanaPageTemplate into this file and update any references/screenshots?

https://github.com/elastic/kibana/blob/c4815d319ecc4894315d7b82a3af9066aa3e5dbb/dev_docs/tutorials/kibana_page_template.mdx

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 have updated the .mdx file and made corresponding changes where needed (omitting "recommended" and changing the actions to action). We might want to update that last screenshot though, as it still shows 2 cards.

Copy link
Contributor

Choose a reason for hiding this comment

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

🙏 Thank you! Here's an updated image:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Images are loaded from dev_docs, so I opened a separate PR for that (the URL remains the same).

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

import { shallow } from 'enzyme';
import { KibanaPageTemplateInner } from './page_template_inner';
import React from 'react';
import { EuiEmptyPrompt, EuiPageTemplate } from '@elastic/eui';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we need to get into the habit of sorting imports, with newlines between classifications. My preference is as follows, but yours may be different:

// imports from npm packages
import React from 'react';
import { shallow } from 'enzyme';

// imports from elastic packages
import { EuiEmptyPrompt, EuiPageTemplate } from '@elastic/eui';

// imports from relative directories
import { FooBar} from '../../../components/foo/bar';

// imports from immediate files
import { KibanaPageTemplateInner } from './page_template_inner';

*/
const emptyStateDefaultTemplate = 'centeredBody';
let header = pageHeader;
if (isEmptyState) {
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
if (isEmptyState) {
if (isEmptyState) {

children = (
<EuiEmptyPrompt
iconType={iconType}
iconColor={''} // This is likely a solution or app logo, so keep it multi-color
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
iconColor={''} // This is likely a solution or app logo, so keep it multi-color
iconColor="" // This is likely a solution or app logo, so keep it multi-color

<EuiEmptyPrompt
iconType={iconType}
iconColor={''} // This is likely a solution or app logo, so keep it multi-color
title={pageTitle ? <h1>{pageTitle}</h1> : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't do this inline. Object and function creation in a prop leads to recreation on every render cycle.

const title = pageTitle ? <h1>{pageTitle}</h1> : undefined;
const body = description ? <p>{description}</p> : undefined;

children = (
        <EuiEmptyPrompt
          iconColor={''}
          actions={rightSideItems}
          {...{ iconType, title, body }}
        />
);

paddingSize: 'none',
...props.pageSideBarProps,
className: sideBarClasses,
} as EuiPageSideBarProps; // needed because for some reason 'none' is not recognized as a valid value for paddingSize
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll look into this.

<WrappedComponent
{...propagatedProps}
pageSideBar={pageSideBar}
pageSideBarProps={pageSideBarProps}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: foo={foo} always strikes me as repetitive and noisy, especially when there are several and you already have a spread.

</WrappedComponent>
);
};
WithSolutionNav.displayName = `WithSolutionNavBar(${getDisplayName(WrappedComponent)})`;
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
WithSolutionNav.displayName = `WithSolutionNavBar(${getDisplayName(WrappedComponent)})`;
WithSolutionNav.displayName = `WithSolutionNavBar(${getDisplayName(WrappedComponent)})`;

@majagrubic majagrubic requested a review from cchaos April 7, 2022 21:36
@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dataViewEditor 153 175 +22
maps 863 885 +22
spaces 264 286 +22
total +66

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dataViewEditor 154.0KB 175.3KB +21.4KB
maps 2.7MB 2.7MB +20.8KB
spaces 268.6KB 289.9KB +21.3KB
total +63.5KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/shared-ux-components 4 6 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
dataViewEditor 10.6KB 10.6KB +1.0B
maps 70.1KB 70.1KB +1.0B
total +2.0B
Unknown metric groups

API count

id before after diff
@kbn/shared-ux-components 32 36 +4

async chunk count

id before after diff
dataViewEditor 7 8 +1
maps 16 17 +1
spaces 17 18 +1
total +3

miscellaneous assets size

id before after diff
dataViewEditor 68.4KB 161.8KB +93.4KB
maps 598.0KB 691.3KB +93.4KB
spaces 68.4KB 161.8KB +93.4KB
total +280.1KB

History

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

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.

Thank you for the combined storybook and toggles. It's so much easier that way to see how all those prop configurations affect each other.

@majagrubic majagrubic merged commit 1c3aa7a into elastic:main Apr 11, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 11, 2022
@majagrubic majagrubic deleted the page-template-6 branch April 11, 2022 18:28
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.

5 participants