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

fix(lib-user): use next/link for internal app routes #6379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Oct 13, 2024

Use next/link for the home page link to user stats, the link to your stats certificate, and the Back link at the top of each page.

Also fix the lib-user peer dependencies, which were still requiring Next.js 13.5.

Please request review from @zooniverse/frontend team or an individual member of that team.

Package

  • lib-user

Linked Issue and/or Talk Post

How to Review

'More stats', on the home page, and 'View certificate', on the user stats page, and the Back link on each of those pages, should now use client-side routing in the root Next.js app.

Build the user library with these changes, then build and run the root app with yarn build && yarn start, to verify that those links are now using client-side routing (ie. the page doesn't reload, and app-root doesn't unmount and remount in the browser, when moving between views.)

This should also lower the load on the Next.js app server, since it doesn't have to serve the whole app on every page transition. Locally, you'll probably see that as faster page transitions with a production build.

NB. Next.js development mode disables client-side routing, so I don't think this PR can be checked with yarn dev.

Checklist

PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can yarn panic && yarn bootstrap or docker-compose up --build and FEM works as expected
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

General UX

Example Staging Project: i-fancy-cats

  • All pages of a FEM project load: Home Page, Classify Page, and About Pages
  • Can submit a classification
  • Can sign-in and sign-out
  • The component is accessible

Bug Fix

  • The PR creator has listed user actions to use when testing if bug is fixed
  • The bug is fixed
  • Unit tests are added or updated

@coveralls
Copy link

coveralls commented Oct 13, 2024

Coverage Status

coverage: 77.802% (+0.01%) from 77.79%
when pulling 4ff419a on eatyourgreens:fix-next-links
into 1d5dc0a on zooniverse:master.

@@ -291,7 +292,7 @@ function MainContent({
margin={{ top: 'small' }}
>
<StyledCertificateButton
forwardedAs='a'
forwardedAs={Link}
Copy link
Contributor Author

@eatyourgreens eatyourgreens Oct 13, 2024

Choose a reason for hiding this comment

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

Noting here that forwardedAs='a' does nothing on a Grommet Button. Grommet automatically renders Button as a link, if it has a href attribute.

@goplayoutside3
Copy link
Contributor

I agree with these changes, but just a heads up that full review won't take place until next week. There are changes to AFD cache rules and actions to purge AFD going into place during FEM deploy tomorrow, so I just want to isolate the changes to prefetching in this PR for deploy the next time instead.

I included the bump in lib-user's peer dependency for Next.js in #6367.

Use `next/link` for the home page link to user stats, and the link to your stats certificate.

Also fix the `lib-user` peer dependencies, which were still requiring Next.js 13.5.
@eatyourgreens
Copy link
Contributor Author

Sounds good. Here's a quick screen recording to show the instantaneous transitions between page views on this branch, once the initial data load is complete.

Screen.Recording.2024-10-17.at.09.10.29.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Full page refresh when following links in the new root app
3 participants