-
Notifications
You must be signed in to change notification settings - Fork 699
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
Improved router handlers architecture in Coach - part 1 #11570
Conversation
Signed-off-by: shivangrawat30 <rawatshivang30@gmail.com>
Build Artifacts
|
Added @nucleogenesis as a reviewer just because I think there are some concurrent changes to coach routing in develop for Enhanced Quiz Management |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ShivangRawat30, in the light of we discussed, this makes sense to me. Thank you for following the suggestion to refactor the global beforeRoute hook into two separate sections - the first with other logic that will stay, and the latter with what will be eventually removed. I am leaving a few comments related to code. I will also test it for regressions.
I will update the PR description since this doesn't close the whole #11570. It's rather a first step. There are plenty of other page handlers that we need to add to the ignore list we now have thanks to this work in the global beforeRoute, and move promises to those page handlers. And after that's done, we will remove the second section of the global beforeRoute finally. Then, the issue will be closed. Would you like to continue working on it? The approach will be the same.
@nucleogenesis this approach is based on #11219 (comment), #11219 (comment), and https://gist.github.com/MisRob/fe3d75e27883308272089dcfe02356ee to help @ShivangRawat30 to start this work gradually (just to make sure we're on the same board before refactoring all handlers). If he decides to continue, we will talk about in how large chunks this will get addressed. If you haven't changed the core workings of the global beforeRoute hook, I don't think there should be many significant conflicts, right? Perhaps some in individual page handlers, but that's something that shouldn't be difficult to deal with. Please let me know how things are in the Enhanced Quiz Management. |
The approach looks good but it does seem likely that the changes should all happen in one PR (I'm assuming the changes in the router guard will cause regressions in handlers.js's that haven't had the same update as examsRoot?). In any case -- we are no longer using the handlers for exam creation in the routes and I'm not sure if the changes would need to be applied there anyway. (thanks for your work on this @ShivangRawat30 ! <3) |
Signed-off-by: shivangrawat30 <rawatshivang30@gmail.com>
@MisRob I've implemented the suggested changes for the review. and I am eager to continue working on this issue. |
No, the main idea here is actually to prepare ground for rather gradual refactor (for more reasons). Here, you can see that the promises we want to eventually remove are now ignored only for a page in which the first handler that Shivang refactored, while still being run for all other pages. We will keep adding to this "ignore" while refactoring other handlers. After all handlers are done, the ignore condition will be removed together with all promises fetching data from the global router handler:
The rest of this PR is only reordering the global handler to allow for a cleaner separation and a bit more readable structure during this temporary phase. |
This is a bigger concern. If you still rely on the global handler (I assume you do?) then I would say that probably you rely on those data being fetched in the global router being available and used somehow. So I think it's be best to left |
@nucleogenesis if this plan of attack makes sense to you too, is |
Only the examCreation :) |
@ShivangRawat30 Thank you! I will re-review and also test in detail that the global |
Good news! Alright, thank you, that's good to know in advance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good progress @ShivangRawat30, thank you. I re-reviewed and am leaving some new notes.
Signed-off-by: shivangrawat30 <rawatshivang30@gmail.com>
@MisRob I've implemented the required modifications, kindly review them. Once this pull request receives approval and is merged, I'll proceed to work on additional handlers. |
Signed-off-by: shivangrawat30 <rawatshivang30@gmail.com>
@MisRob Apologies for earlier. I've now made the adjustments. Please review and let me know if the approach need some changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @ShivangRawat30. It's looking good to me. I also manually tested the page and haven't observed any issues.
Just for your information, I pushed a commit disabling Jest tests for this handler. I will describe what's the problem with updating the current test suite here #11615 later on.
As I pushed my own update, I'd welcome a second pair of eyes on this PR before merging. cc @rtibbles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes make sense - we can gradually move the global behaviour for each handler out of this!
Summary
This pull request enhances route handling by restricting the responsibility of route handling to local handlers rather than relying on a global route handler.
References
This work is part of #11219 (it doesn't close it though)
Reviewer guidance
Testing checklist
PR process
Reviewer checklist
yarn
andpip
)