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

fix: page routes wildcard which breaks tutor #322

Conversation

connorhaugh
Copy link
Contributor

In f62d0aa
we upgraded react router. That change also added the following

<Route path={`${ROUTES.Detail.HOME}`} element={<StudioHeaderWrapper />} />

became

<Route path={`${ROUTES.Detail.HOME}/*`} element={<StudioHeaderWrapper />} />

That broke tutor, as tutor uses /<MFE_TYPE>/.

We know this fix works on tutor and devstack. We want to ensure, however, @Syed-Ali-Abbas-Zaidi that this change was not made for a reason, as we don't want to break an unexpected feature. Can you tell us why you made that change Syed?

@ormsbee
Copy link

ormsbee commented Sep 26, 2023

I see the test failures, but don't understand them. Does it shed light on why the wildcard was added?

@jesperhodge jesperhodge force-pushed the fix--tutor-page-routes-broken-after-react-router-upgrade branch from 18ac379 to 44195fb Compare September 26, 2023 16:58
@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4423a3f) 52.41% compared to head (0952f2b) 52.41%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #322   +/-   ##
=======================================
  Coverage   52.41%   52.41%           
=======================================
  Files          75       75           
  Lines        1986     1986           
  Branches      359      359           
=======================================
  Hits         1041     1041           
  Misses        912      912           
  Partials       33       33           

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

@abdullahwaheed
Copy link
Contributor

Hi @connorhaugh, @Syed-Ali-Abbas-Zaidi is on leaves this week. Actually this route wasn't using exact previously and react-router-v6 have all the exact routes by default, so we have append * in this route so if it has any child routes, they can also work. If its causing issue, we can remove it

@@ -52,7 +52,7 @@ subscribe(APP_READY, () => {
<Route path={ROUTES.Detail.EDIT} element={<LibraryEditPage />} />
<Route path={ROUTES.Detail.ACCESS} element={<LibraryAccessPage />} />
<Route path={ROUTES.Detail.IMPORT} element={<CourseImportPage />} />
<Route path={`${ROUTES.Block.HOME}/*`} element={<LibraryBlockPage />} />
<Route path={`${ROUTES.Block.HOME}`} element={<LibraryBlockPage />} />
Copy link
Contributor

Choose a reason for hiding this comment

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

don't revert this one, this route has child routes

Copy link
Contributor

Choose a reason for hiding this comment

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

@ormsbee any chance you could test this out on Tutor with the wildcard in this route?

Copy link

Choose a reason for hiding this comment

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

Sure.

Copy link

Choose a reason for hiding this comment

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

I actually get the same error either way. Not sure if I'm doing something wrong. 😦

react.development.js:220 Warning: Failed prop type: The prop `library` is marked as required in `StudioHeaderWrapperBase`, but its value is `null`.
    at StudioHeaderWrapperBase (webpack-internal:///./src/library-authoring/studio-header-wrapper/StudioHeaderWrapper.jsx:53:7)
    at ShimmedIntlComponent (webpack-internal:///./node_modules/@edx/frontend-platform/i18n/injectIntlWithShim.js:151:7)
    at injectIntl(ShimmedIntlComponent)
    at ConnectFunction (webpack-internal:///./node_modules/react-redux/es/components/connectAdvanced.js:233:68)
    at RenderedRoute (webpack-internal:///./node_modules/react-router/dist/index.js:554:5)
    at Routes (webpack-internal:///./node_modules/react-router/dist/index.js:1185:5)
    at Router (webpack-internal:///./node_modules/react-router/dist/index.js:1123:15)
    at BrowserRouter (webpack-internal:///./node_modules/react-router-dom/dist/index.js:399:5)
    at Provider (webpack-internal:///./node_modules/react-redux/es/components/Provider.js:18:20)
    at OptionalReduxProvider (webpack-internal:///./node_modules/@edx/frontend-platform/react/OptionalReduxProvider.js:18:20)
    at ErrorBoundary (webpack-internal:///./node_modules/@edx/frontend-platform/react/ErrorBoundary.js:139:5)
    at IntlProvider (webpack-internal:///./node_modules/react-intl/lib/src/components/provider.js:92:47)
    at AppProvider (webpack-internal:///./node_modules/@edx/frontend-platform/react/AppProvider.js:108:20)

Copy link

@ormsbee ormsbee Sep 26, 2023

Choose a reason for hiding this comment

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

Okay, so that is a warning, and if I hardcode the path for LibraryListPage to be "library-authoring", it does render–even though that warning still spills out in the console.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure. It just seems very odd that react-router would overwrite that instead of appending.

Based on the change in how links are handled I thought it might be in https://github.com/openedx/frontend-app-library-authoring/blob/master/src/library-authoring/utils/hoc.jsx but nothing there stood out to me.

Maybe @arbrandes has some insight?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't, but perhaps @Syed-Ali-Abbas-Zaidi has sufficient context. The router-v6 changes were pretty extensive!

Copy link
Contributor

Choose a reason for hiding this comment

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

That they were! To add context, I was specifically looking into why the link Dave mentioned was behaving differently after changing from

  goToCreateLibraryPage = () => {
    this.props.history.push(ROUTES.List.CREATE);
  };

to

  goToCreateLibraryPage = () => {
    this.props.navigate(ROUTES.List.CREATE);
  };

which is what got me looking into hoc.jsx

Copy link
Contributor Author

@connorhaugh connorhaugh Sep 27, 2023

Choose a reason for hiding this comment

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

Questions:
Did you restart/rebuild after making the changes?
Just to confirm, we never tested the problem as fixed on your local tutor?

Copy link

Choose a reason for hiding this comment

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

I did restart/rebuild between changes. Going back to the commit before the react-router upgrade (so commit 16414ff) works. Grabbing the latest master fails. Grabbing this branch also fails in the same way master is failing.

src/index.jsx Outdated Show resolved Hide resolved
@@ -52,7 +52,7 @@ subscribe(APP_READY, () => {
<Route path={ROUTES.Detail.EDIT} element={<LibraryEditPage />} />
<Route path={ROUTES.Detail.ACCESS} element={<LibraryAccessPage />} />
<Route path={ROUTES.Detail.IMPORT} element={<CourseImportPage />} />
<Route path={`${ROUTES.Block.HOME}/*`} element={<LibraryBlockPage />} />
<Route path={`${ROUTES.Block.HOME}`} element={<LibraryBlockPage />} />
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
<Route path={`${ROUTES.Block.HOME}`} element={<LibraryBlockPage />} />
<Route path={ROUTES.Block.HOME} element={<LibraryBlockPage />} />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair. Going to wait for Dave's test then I'll put up an amended version.

@@ -52,7 +52,7 @@ subscribe(APP_READY, () => {
<Route path={ROUTES.Detail.EDIT} element={<LibraryEditPage />} />
<Route path={ROUTES.Detail.ACCESS} element={<LibraryAccessPage />} />
<Route path={ROUTES.Detail.IMPORT} element={<CourseImportPage />} />
<Route path={`${ROUTES.Block.HOME}/*`} element={<LibraryBlockPage />} />
Copy link

@ormsbee ormsbee Oct 30, 2023

Choose a reason for hiding this comment

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

@kdmccormick: I lost track of this when openedx/frontend-platform#574 seemed to make things work on tutor. But I'm wondering if this could be the cause of the component edit page still being broken on Tutor dev?

kdmccormick and others added 2 commits February 2, 2024 11:24
Co-authored-by: Brian Smith <112954497+brian-smith-tcril@users.noreply.github.com>
@navinkarkera
Copy link
Contributor

@connorhaugh Gentle reminder.

@brian-smith-tcril
Copy link
Contributor

@kdmccormick
Copy link
Contributor

Closing per #439

@kdmccormick kdmccormick deleted the fix--tutor-page-routes-broken-after-react-router-upgrade branch July 17, 2024 19:50
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.

7 participants