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

feat: expose containerProps in StudioHeader [FC-0062] #529

22 changes: 7 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@edx/frontend-platform": "8.1.1",
"@edx/reactifex": "^2.1.1",
"@openedx/frontend-build": "14.1.2",
"@openedx/paragon": "22.7.0",
"@openedx/paragon": "22.8.0",

Choose a reason for hiding this comment

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

Should this mirror StudioFooter's dependency?

Suggested change
"@openedx/paragon": "22.8.0",
"@openedx/paragon": ">= 21.11.3 < 23.0.0",

Copy link
Contributor Author

@rpenido rpenido Sep 20, 2024

Choose a reason for hiding this comment

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

Good catch @pomegranited!
The version was wrong in both!
We need paragon 22.8.0 or upper here, so it should be ^22.8.0. We don't need the < 23.0.0 part because the ^ would not allow updates to major versions.

Fixed here: 35c2040

"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "5.17.0",
"@testing-library/react": "10.4.9",
Expand Down Expand Up @@ -68,7 +68,8 @@
},
"peerDependencies": {
"@edx/frontend-platform": "^7.0.0 || ^8.0.0",
"@openedx/paragon": ">= 21.5.7 < 23.0.0",
"@openedx/paragon": "^22.8.0",
Copy link
Member

Choose a reason for hiding this comment

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

Is dropping the previously supported range intentional? As is, this is a breaking change since it drops support for >= 21.5.7.

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 was intentional as it was built on top of Paragon 22.8.0, but it will be backward compatible, so I reverted it here: ccee347

But I still think we should update the version here, and I can't see how this could impact someone, as the current package-lock.json is already pointing to 22.8.1.

"node_modules/@openedx/paragon": {
"version": "22.8.1",

Could you help me to understand?

Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I'm not sure if we should have @openedx/paragon (and some other packages such as react, react-dom, etc..) in the devDependencias, but I think this is an issue for another PR. 😃

Copy link
Member

Choose a reason for hiding this comment

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

The package-lock.json is pointing to 22.8.1 due to @openedx/paragon getting installed as a devDependency, which is intentional. Because this library relies on consumers to provide their own copy of @openedx/paragon (per the peerDependencies), the devDependencies copy of @openedx/paragon is what allows for local development of the library. Without Paragon in the devDependencies, the example app within this repo couldn't run due to the missing installed node_modules/@openedx/paragon.

The devDependencies are not included in the production bundle published to NPM, as confirmed by noting that @openedx/paragon is included only in the npm list --include=dev command, but not npm list --omit=dev as seen below:

❯ npm list --omit=dev --depth=0
@edx/[email protected] /Users/astankiewicz/Desktop/edx/frontend-component-header
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @openedx/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

❯ npm list --include=dev --depth=0
@edx/[email protected] /Users/astankiewicz/Desktop/edx/frontend-component-header
├── @edx/brand@npm:@openedx/[email protected]
├── @edx/[email protected]
├── @edx/[email protected]
├── @edx/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @fortawesome/[email protected]
├── @openedx/[email protected]
├── @openedx/[email protected]
├── @openedx/[email protected]
├── @testing-library/[email protected]
├── @testing-library/[email protected]
├── @testing-library/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I got it! Thank you for the explanation!

"classnames": "^2.5.1",
Copy link
Member

Choose a reason for hiding this comment

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

I believe we may want to make this a regular dependency under dependencies so consumers don't need to explicitly install classnames themselves. Otherwise, any consuming MFE that doesn't use classnames@^2.5.1 already will need to install it (also technically a breaking change).

classNames is different from packages that should be peerDependencies, which are either large (e.g., @openedx/paragon) and/or should only have a single copy within the consuming application (e.g., @edx/frontend-platform).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the explanation! Fixed here: 61243f4

"prop-types": "^15.5.10",
"react": "^16.9.0 || ^17.0.0",
"react-dom": "^16.9.0 || ^17.0.0"
Expand Down
12 changes: 11 additions & 1 deletion src/studio-header/HeaderBody.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useIntl } from '@edx/frontend-platform/i18n';
import classNames from 'classnames';
import {
ActionRow,
Button,
Expand Down Expand Up @@ -37,6 +38,7 @@ const HeaderBody = ({
mainMenuDropdowns,
outlineLink,
searchButtonAction,
containerProps,
}) => {
const intl = useIntl();

Expand All @@ -50,8 +52,14 @@ const HeaderBody = ({
/>
);

const { className: containerClassName, ...restContainerProps } = containerProps || {};

return (
<Container size="xl" className="px-2.5">
<Container
size="xl"
className={classNames('px-2.5', containerClassName)}
{...restContainerProps}
>
<ActionRow as="header">
{isHiddenMainMenu ? (
<Row className="flex-nowrap ml-4">
Expand Down Expand Up @@ -110,6 +118,7 @@ const HeaderBody = ({
iconAs={Icon}
onClick={searchButtonAction}
aria-label={intl.formatMessage(messages['header.label.search.nav'])}
alt={intl.formatMessage(messages['header.label.search.nav'])}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not related to this feature. This is a fly-by fix of a console warning. Let me know if I should create a different PR for this.

Choose a reason for hiding this comment

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

Thanks for fixing these! Fewer warnings is always good.

/>
</Nav>
)}
Expand Down Expand Up @@ -155,6 +164,7 @@ HeaderBody.propTypes = {
})),
outlineLink: PropTypes.string,
searchButtonAction: PropTypes.func,
containerProps: Container.propTypes,
};

HeaderBody.defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/studio-header/NavDropdownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const NavDropdownMenu = ({

NavDropdownMenu.propTypes = {
id: PropTypes.string.isRequired,
buttonTitle: PropTypes.string.isRequired,
buttonTitle: PropTypes.node.isRequired,
Copy link
Contributor Author

@rpenido rpenido Sep 5, 2024

Choose a reason for hiding this comment

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

Not related to this feature. This is a fly-by fix of a console warning. Let me know if I should create a different PR for this.

Copy link
Member

Choose a reason for hiding this comment

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

[clarification/suggestion] If we make the change here, should we also ensure all other prop type definitions for buttonTitle reflect PropTypes.node, too?

For example, here and here.

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 other places here: 06bfcc7

items: PropTypes.arrayOf(PropTypes.shape({
href: PropTypes.string,
title: PropTypes.string,
Expand Down
4 changes: 3 additions & 1 deletion src/studio-header/StudioHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ensureConfig([
], 'Studio Header component');

const StudioHeader = ({
number, org, title, isHiddenMainMenu, mainMenuDropdowns, outlineLink, searchButtonAction,
number, org, title, containerProps, isHiddenMainMenu, mainMenuDropdowns, outlineLink, searchButtonAction,
}) => {
const { authenticatedUser, config } = useContext(AppContext);
const props = {
Expand All @@ -25,6 +25,7 @@ const StudioHeader = ({
number,
org,
title,
containerProps,
username: authenticatedUser?.username,
isAdmin: authenticatedUser?.administrator,
authenticatedUserAvatar: authenticatedUser?.avatar,
Expand Down Expand Up @@ -53,6 +54,7 @@ StudioHeader.propTypes = {
number: PropTypes.string,
org: PropTypes.string,
title: PropTypes.string.isRequired,
containerProps: HeaderBody.propTypes.containerProps,

Choose a reason for hiding this comment

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

containerProps should be optional, and/or populated with a default value below?

Copy link
Contributor Author

@rpenido rpenido Sep 19, 2024

Choose a reason for hiding this comment

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

Fixed here: e2249b2

isHiddenMainMenu: PropTypes.bool,
mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
Expand Down