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: [FC-0070] support SPA functionality #542

Merged

Conversation

PKulkoRaccoonGang
Copy link
Contributor

@PKulkoRaccoonGang PKulkoRaccoonGang commented Oct 7, 2024

🚨 Dependencies:

Description

This PR introduces several changes to the studio-header components to integrate react-router-dom for client-side routing, along with corresponding updates to tests.

Testing:

  1. Install this version of the header in the associated version of MFE Authoring and switch to the current branch
  2. If the waffle flags for links in the header navigation are enabled, navigation is performed without reloading the page

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 7, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 7, 2024

Thanks for the pull request, @PKulkoRaccoonGang!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently unmaintained.

To get help with finding a technical reviewer, tag the community contributions project manager for this PR in a comment and let them know that your changes are ready for review:

  1. On the right-hand side of the PR, find the Contributions project, click the caret in the top right corner to expand it, and check the "Primary PM" field for the name of your PM.
  2. Find their GitHub handle here.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.75%. Comparing base (ae5253c) to head (6e4945b).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #542      +/-   ##
==========================================
- Coverage   70.55%   68.75%   -1.81%     
==========================================
  Files          25       48      +23     
  Lines         360      432      +72     
  Branches       95       97       +2     
==========================================
+ Hits          254      297      +43     
- Misses        104      132      +28     
- Partials        2        3       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@itsjeyd
Copy link

itsjeyd commented Oct 11, 2024

Hey @PKulkoRaccoonGang, thank you for this contribution!

It looks like the changes are ready for review (?), but let me know if you were planning to work on them some more.

@itsjeyd itsjeyd added core contributor PR author is a Core Contributor (who may or may not have write access to this repo). waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Oct 11, 2024
@PKulkoRaccoonGang PKulkoRaccoonGang marked this pull request as draft October 11, 2024 10:07
@PKulkoRaccoonGang
Copy link
Contributor Author

PKulkoRaccoonGang commented Oct 11, 2024

Hi @itsjeyd
The PR is currently in draft, but I plan to submit it for review soon.
I'll let you know, thanks!

@itsjeyd itsjeyd removed the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Oct 17, 2024
@itsjeyd
Copy link

itsjeyd commented Oct 17, 2024

Sounds good @PKulkoRaccoonGang, thanks for the update.

@PKulkoRaccoonGang PKulkoRaccoonGang changed the title chore: improved SPA routes chore: [FC-0070] improved SPA routes Oct 22, 2024
@PKulkoRaccoonGang PKulkoRaccoonGang changed the title chore: [FC-0070] improved SPA routes chore: [FC-0070] support SPA functionality Oct 22, 2024
@PKulkoRaccoonGang PKulkoRaccoonGang marked this pull request as ready for review October 24, 2024 12:03
Copy link

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

I'm missing an explanation of why we're doing this complicated onNavigate prop injection and duplicating logic from react-router instead of simply using <Link>.

}) => (
<a href={studioBaseUrl}>
<Hyperlink destination={studioBaseUrl} onClick={(e) => navigateToUrl(e, studioBaseUrl, onNavigate)}>

Choose a reason for hiding this comment

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

This is OK, but isn't it much simpler and nicer to just use the <Link> component from react-router-dom?

Copy link
Contributor Author

@PKulkoRaccoonGang PKulkoRaccoonGang Oct 29, 2024

Choose a reason for hiding this comment

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

I'm missing an explanation of why we're doing this complicated onNavigate prop injection and duplicating logic from react-router instead of simply using .

The reason why it is not possible to use the react-router-dom functionality is the lack of a react-router-dom context, in the Authoring MFE the Header is outside the react-router context of the app. If you have any workarounds, I will be happy to implement them

Copy link

@bradenmacdonald bradenmacdonald Oct 29, 2024

Choose a reason for hiding this comment

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

Are you sure? I thought the root app always provides RouterProvider. And in that page you linked to, I can see the use of useLocation from react-router which means the router context is available.

https://github.com/openedx/frontend-app-authoring/blob/ecfe27b043965941d752541e7b3e512847d94169/src/CourseAuthoringPage.jsx#L38

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 to this PR, I realized that I wasn't the only one with the router context problem. Before adding react-router-dom to peerDependencies, the following error was displayed when using Link. I don't understand why it works like that, but it does :)

image

src/studio-header/CourseLockUp.jsx Outdated Show resolved Hide resolved
src/studio-header/utils.js Outdated Show resolved Hide resolved
src/studio-header/NavDropdownMenu.test.jsx Show resolved Hide resolved
Copy link

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Glad you figured that out! Thanks, this seems to be working well, and it makes everything feel much faster :)

src/studio-header/HeaderBody.jsx Outdated Show resolved Hide resolved
@itsjeyd itsjeyd added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Oct 31, 2024
@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/use-SPA-functionality branch from 5ead432 to 0f9014b Compare October 31, 2024 19:55
Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

The code itself is great. I tested it and everything works beautifully. No more page refreshes, yay!

However, can you please make the commit a feat:? It may not be a breaking change, but it does offer a new isNewHomePage prop for the StudioHeader.

@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/use-SPA-functionality branch from 0f9014b to 6e4945b Compare November 1, 2024 15:05
@PKulkoRaccoonGang PKulkoRaccoonGang changed the title chore: [FC-0070] support SPA functionality feat: [FC-0070] support SPA functionality Nov 1, 2024
Copy link
Contributor

@arbrandes arbrandes 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!

@arbrandes arbrandes merged commit cb7774b into openedx:master Nov 1, 2024
6 checks passed
@itsjeyd itsjeyd removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants