Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Adding Page component and related files #216

Merged
merged 10 commits into from
May 24, 2021

Conversation

tbiethman
Copy link
Contributor

@tbiethman tbiethman commented May 21, 2021

Summary

Adding the Page component, the main UI component intended for usage in the provided PageContainers.

Closes #193

Deployment Link

https://terra-applic-.herokuapp.com/

Testing

Additional Details

Theme values are not yet defined in total. A separate issue has been logged to get those implemented when the values are known: #218

Thank you for contributing to Terra.
@cerner/terra

@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--0dpsd1 May 21, 2021 16:05 Inactive
Page.propTypes = propTypes;
Page.Actions = PageActions;
Page.Action = PageAction;
Page.Toolbar = PageToolbar;
Copy link
Contributor Author

@tbiethman tbiethman May 21, 2021

Choose a reason for hiding this comment

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

These might be a little controversial. As we have moved away from needing HOCs all over the place, the usage of static exports from some of our "umbrella" components becomes a little more straightforward and less error prone. The components themselves are documented separately so we can document prop tables and all that jazz.

I feel like this simplifies the consumer's implementation code and keeps these components (that are required for usage with the Page) bundled together nicely. Take a look at the example implementations and let me know your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the explicit bundling of the page and it's sub components. My only concern is introducing inconsistency regarding how we present other API's in the package, such as workspace. It may be worth our time to go back and implement this style of api for those other areas at least in the terra-application package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I can log an investigative story for that as part of our v2 release. We could remain passive by keeping any existing explicit exports in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logged issue: #219

@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--ibrkfr May 21, 2021 17:30 Inactive
@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--ibrkfr May 21, 2021 18:20 Inactive
@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--ibrkfr May 21, 2021 21:49 Inactive
*
* The PageActions component should not be rendered directly.
*/
const PageActions = () => <div />;
Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't matter, but could this be an empty fragment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. It needs to be non-null so that the props table parsing will recognize it as a component, but I imagine a fragment would work too? I'll try it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works!

/**
* Identifier for use during tests
*/
testId: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

testId? Should we make this private or just be a regular id?

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 think this is being used at the moment, so I'll remove. Should be able to query in tests based on role/display just fine.

@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--ibrkfr May 24, 2021 14:06 Inactive
<PageHeader
id={pageId}
onSelectBack={onRequestClose ? () => {
if (dangerouslyDisableUnsavedChangesPromptHandling) {
Copy link
Contributor

Choose a reason for hiding this comment

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

(small and not a big deal) - we could convert this into a handleOnSelectBack function and pass it here to make the ternary slightly more readable

));
}

function renderMenuButton() {
Copy link
Contributor

Choose a reason for hiding this comment

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

what are your thoughts on further abstracting these render functions into their own components? Looks like we have ActionButtons, MenuButton, Menu, Toolbar, StartActions, EndActions. Extracting these out will remove nested rendering and make this component easier to follow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separate components would result in a lot of props being passed around and seems like overkill (for what would amount to a single-use component). But I might be able to make this more straightforward, I'll play with it a bit.

<Popup
isOpen={showMenu}
targetRef={() => moreActionsButtonRef.current}
onRequestClose={() => { setShowMenu(false); }}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick haha

Suggested change
onRequestClose={() => { setShowMenu(false); }}
onRequestClose={() => setShowMenu(false)}

label={intl.formatMessage({
id: 'terraApplication.pageHeader.actionsMenu',
}, { label })}
onRequestClose={() => { setShowMenu(false); }}
Copy link
Contributor

Choose a reason for hiding this comment

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

if you update above, let's do the same here for consistency

Suggested change
onRequestClose={() => { setShowMenu(false); }}
onRequestClose={() => setShowMenu(false)}

* Use this prop to customize UnsavedChangesPrompt handling prior to Page
* closure.
*/
dangerouslyDisableUnsavedChangesPromptHandling: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

remind me, in what situations does this get used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the "I'm handling my Page's unsaved changes differently and don't want two prompts to pop up" prop. I'd anticipate something similar on the new Modal.

@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--ibrkfr May 24, 2021 18:39 Inactive
@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--ibrkfr May 24, 2021 19:30 Inactive
@mjhenkes mjhenkes temporarily deployed to terra-applic-story-193--ibrkfr May 24, 2021 20:18 Inactive
@tbiethman tbiethman merged commit c081c7a into terra-application-v2 May 24, 2021
@tbiethman tbiethman deleted the story-193-page-rebase branch May 24, 2021 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants