openedx / frontend-app-discussions

A React-based micro frontend for the Open edX discussion forums.
GNU Affero General Public License v3.0
6 stars 61 forks source link

fix: null error at useRouteMatch when running on tutor #613

Closed xitij2000 closed 8 months ago

xitij2000 commented 8 months ago

Description

tutor sets the PUBLIC_PATH to '/discussions' which causes frontend-platform to treat all URLs for matching etc to be relative to this path. Since many places include '/discussions' in the match it causes those matches to break.

This change makes the default PUBLIC_PATH in .env.development to match the one set by tutor and removes it from the base path of the router letting frontend platform handle the prefix.

This also allows for deployments to customise this path to be something other then 'discussions'.

Fixes #584

How Has This Been Tested?

Tested using the tutor master devstack and running using npm start

Merge Checklist

Post-merge Checklist

openedx-webhooks commented 8 months ago

Thanks for the pull request, @xitij2000! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

mphilbrick211 commented 8 months ago

Hi @openedx/2u-infinity @openedx/edx-infinity! Is this something you can review / merge for us?

Also, which is the correct tag for your team (from the ones above)? I want to make sure I'm using the correct one.

awais-ansari commented 8 months ago

Hi @openedx/2u-infinity @openedx/edx-infinity! Is this something you can review / merge for us?

Also, which is the correct tag for your team (from the ones above)? I want to make sure I'm using the correct one.

Hello, @mphilbrick211 @openedx/2u-infinity is the correct tag for the team. I'm reviewing this PR.

awais-ansari commented 8 months ago

@xitij2000 This change will break other functionality for tutor such as copy link. Check more details in this PR. I also discussed this issue in detail in this thread.. Let me know about your thoughts. cc: @dyudyunov @arbrandes

xitij2000 commented 8 months ago

@xitij2000 This change will break other functionality for tutor such as copy link. Check more details in this PR. I also discussed this issue in detail in this thread.. Let me know about your thoughts. cc: @dyudyunov @arbrandes

I don't think it will break. The copy link feature is prepending the public path to the URL so it will get the full URL.

awais-ansari commented 8 months ago

@xitij2000 This change will break other functionality for tutors such as copy link. Check more details in this PR. I also discussed this issue in detail in this thread.. Let me know about your thoughts. cc: @dyudyunov @arbrandes

I don't think it will break. The copy link feature is prepending the public path to the URL so it will get the full URL.

I think I'll break the copy link feature. The current issue is raised because of the Tutor PUBLIC_PATH value. Quince Demo is returning PUBLIC_PATH to /discussions which should be /discussions/.

If we use the same tutor PUBLIC_PATH in the copy link functionality and also keep the inContextSidebar in mind. The copy link would be
new URL(${getConfig().PUBLIC_PATH}${courseId}/posts/${post.id}, window.location.origin); OR new URL('/discussions:courseId/posts/:postId', window.location.origin); This link is still invalid and will break the functionality. In my opinion, We should update the Tutuor PUBLIC_PATH path instead of updating this common pattern that is also used in other MFE by openEdx community.

xitij2000 commented 8 months ago

@xitij2000 This change will break other functionality for tutors such as copy link. Check more details in this PR. I also discussed this issue in detail in this thread.. Let me know about your thoughts. cc: @dyudyunov @arbrandes

I don't think it will break. The copy link feature is prepending the public path to the URL so it will get the full URL.

I think I'll break the copy link feature. The current issue is raised because of the Tutor PUBLIC_PATH value. Quince Demo is returning PUBLIC_PATH to /discussions which should be /discussions/.

If we use the same tutor PUBLIC_PATH in the copy link functionality and also keep the inContextSidebar in mind. The copy link would be new URL(${getConfig().PUBLIC_PATH}${courseId}/posts/${post.id}, window.location.origin); OR new URL('/discussions:courseId/posts/:postId', window.location.origin); This link is still invalid and will break the functionality. In my opinion, We should update the Tutuor PUBLIC_PATH path instead of updating this common pattern that is also used in other MFE by openEdx community.

Since the trailing slash was removed on purpose (see https://github.com/overhangio/tutor-mfe/pull/154) I think we can update the MFE instead. I'll update this PR to fix it.

xitij2000 commented 8 months ago

I've fixed the path issue.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (0d5df18) 92.36% compared to head (3b2d831) 92.42%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #613 +/- ## ========================================== + Coverage 92.36% 92.42% +0.06% ========================================== Files 169 169 Lines 3445 3446 +1 Branches 897 897 ========================================== + Hits 3182 3185 +3 + Misses 243 241 -2 Partials 20 20 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

awais-ansari commented 8 months ago

@xitij2000 Can we add a test case for this change?

xitij2000 commented 8 months ago

@xitij2000 Can we add a test case for this change?

Will apply your changes and add a test on monday.

awais-ansari commented 8 months ago

@xitij2000 Can we add a test case for this change?

Will apply your changes and add a test on monday.

@xitij2000 Just a follow-up. Did you get time to work on this?

xitij2000 commented 8 months ago

@xitij2000 Can we add a test case for this change?

Will apply your changes and add a test on monday.

@xitij2000 Just a follow-up. Did you get time to work on this?

I've updated the PR as requested and added a test.

awais-ansari commented 8 months ago

@xitij2000 Please create a backport PR for the Quince branch.

xitij2000 commented 8 months ago

@xitij2000 Please create a backport PR for the Quince branch.

I've created https://github.com/openedx/frontend-app-discussions/pull/623

openedx-webhooks commented 8 months ago

@xitij2000 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.