feat: Add plugin slot for login page - #1354
Conversation
|
Thanks for the pull request, @xitij2000! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
e19d19d to
8dfabed
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1354 +/- ##
==========================================
- Coverage 87.58% 87.57% -0.02%
==========================================
Files 124 125 +1
Lines 2304 2309 +5
Branches 648 644 -4
==========================================
+ Hits 2018 2022 +4
- Misses 277 278 +1
Partials 9 9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8dfabed to
e0b12b2
Compare
| const renderHook = (hookCallback) => { | ||
| const result = { | ||
| current: null, | ||
| }; | ||
|
|
||
| const Component = () => { | ||
| const val = hookCallback(); | ||
| React.useEffect(() => { | ||
| result.current = val; | ||
| }); | ||
| return null; | ||
| }; | ||
|
|
||
| render(<Component />); | ||
| return { result }; | ||
| }; | ||
|
|
There was a problem hiding this comment.
I had to remove @testing-library/react-hooks due to package conflicts, so I've replaced it with this simplified hook testing code. In later versions this hook is part of the react testing library so we can pull it from there and remove this.
| const LoginPageSlot = ({ | ||
| institutionLogin, | ||
| handleInstitutionLogin, | ||
| }) => ( |
There was a problem hiding this comment.
I don't know how valid this is. The original component needs these values, however they are not included in plugin props since they seem pretty specific to the implementation of the login page.
There was a problem hiding this comment.
Basing on many similar code examples here, I think it's valid, @xitij2000?
| clearThirdPartyAuthContextErrorMessage, | ||
| }, | ||
| )(Logistration); | ||
| export default Logistration; |
There was a problem hiding this comment.
Most of the changes here are to move from old style redux code to more modern react hooks based code.
| <h3 className="mb-4.5">{formatMessage(messages['logistration.sign.in'])}</h3> | ||
| )} | ||
| <LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} /> | ||
| <LoginPageSlot institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} /> |
There was a problem hiding this comment.
I'm using the LoginPageSlot in two places but perhaps these should be two slots that both render the LoginPage by default?
There was a problem hiding this comment.
I agree, because that would be clearer
I'm using the LoginPageSlot in two places but perhaps these should be two slots that both render the LoginPage by default?
| thirdPartyAuthApiStatus: PENDING_STATE, | ||
| thirdPartyAuthContext: { | ||
| currentProvider: null, | ||
| errorMessage: null, |
There was a problem hiding this comment.
The changes to this file are to move to hooks from the older pattern of mapStateToProps etc.
| const mapStateToProps = state => ({ | ||
| thirdPartyAuthContext: thirdPartyAuthContextSelector(state), | ||
| }); |
There was a problem hiding this comment.
Aren't we fetching thirdPartyAuthContext with useSelector above? If so, can't we get rid of mapStateToProps completely?
There was a problem hiding this comment.
I started moving to the new hooks-based approach but ran out of time. I've now fully migrated.
| const LoginPageSlot = ({ | ||
| institutionLogin, | ||
| handleInstitutionLogin, | ||
| }) => ( |
There was a problem hiding this comment.
Basing on many similar code examples here, I think it's valid, @xitij2000?
e0b12b2 to
df9184b
Compare
c999936 to
f1a8f7b
Compare
|
@xitij2000 Do we need to backport this PR to Sumac? |
I'm doing this as part of theming maintainability so I won't be backporting it. |
f1a8f7b to
0482fec
Compare
0482fec to
8b202c9
Compare
There was a problem hiding this comment.
PR Overview
This PR adds a plugin slot for the login page to allow greater customization and simplifies the login page implementation. Key changes include:
- Introducing a new LoginPageSlot component that wraps the LoginPage inside a PluginSlot.
- Refactoring LoginPage to use React hooks (useDispatch, useSelector, useIntl) instead of Redux connect.
- Updating Logistration and related tests to accommodate the new plugin slot and hook-based implementation.
Reviewed Changes
| File | Description |
|---|---|
| src/plugin-slots/LoginPage/index.jsx | New slot component wrapping LoginPage inside PluginSlot. |
| src/logistration/Logistration.test.jsx | Test refactoring to use a unified renderComponent helper. |
| src/login/LoginPage.jsx | Refactored to use hooks and updated dependency imports; removed connect. |
| src/recommendations/data/tests/hooks.test.jsx | Custom renderHook implementation for testing hooks. |
| src/login/tests/LoginPage.test.jsx | Test update to initialize loginFormData for LoginPage. |
| src/logistration/Logistration.jsx | Refactored to use useSelector, useDispatch, and LoginPageSlot. |
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
8b202c9 to
b71959f
Compare
|
Hi @awais-ansari - is this all set to be merged? |
e3d311b to
54d8439
Compare
|
Hey @MaxFrank13 @julrusak, any objections to merging this? As mentioned earlier we would love to get this into Ulmo. |
No objections to merging. I do not have merge rights for this repo though |
|
Thanks @MaxFrank13. @deborahgu Would you be good with merging this now? |
|
I don't actually have write access yet, though I believe I was supposed to get it. @feanil, in the case where a repository temporarily doesn't have a maintainer, is there best practice for summoning someone with permission? |
|
@openedx/committers-frontend-app-authn still has about 8 members who can merge, but I'm here now so I can do it this time around. |
|
Looks like this needs a rebase, @xitij2000 can you do that. |
Head branch was pushed to by a user without write access
8db7690 to
6adaa86
Compare
Done! |
| push: | ||
| branches: | ||
| - master | ||
| - release-ulmo |
There was a problem hiding this comment.
What's up with this change, I don't think I saw it in here before? What's the reason for this change?
There was a problem hiding this comment.
WTH, that rebase somehow pulled in some commits I made that never even existed on this repo. Last week I created a couple of local PR's and I fatfingered, made two PRs from a fork to openedx/master, both of which I promptly closed. I have absolutely no idea how those could have gotten pulled in from a rebase on openedx unless it was set to use edx as the upstream, and I can't think of why @itsjeyd would have that?!?
There was a problem hiding this comment.
in any case both of those commits should obviously be removed
There was a problem hiding this comment.
Not sure how this happened other than using Github UI's rebase function. Will fix ASAP.
There was a problem hiding this comment.
It seems my local repo clone was infact still on the edx org, fixed.
8db7690 to
2a3ff19
Compare
|
@farhaanbukhsh You might already be aware of it but just to be safe I wanted to give you a heads-up that we'll need to get this merged before the Ulmo branch cut today. If you could help make sure that happens, that would be great. |
|
@farhaanbukhsh I figured you weren't going to be able to merge this PR yourself, just wanted to make sure it was on your radar and wouldn't be forgotten :) And good to know that the date for the branch cut changed again, thanks for that update. |
|
@xitij2000 Could you please rebase the changes again and let |
This change adds a plugin slot for the login page allowing it to be customised. Since there was a dependency conflict between frontend-plugin-framework and the react-hooks testing package, the react-hooks testing package has been removed and a replaced with a simple mechanism for testing hooks. Since this touched the Login Page those have also been refactored to move away from redux connect.
2a3ff19 to
0418a04
Compare
|
@openedx/committers-frontend-app-authn @feanil This is ready to merge. |
Description
This change adds a plugin slot for the login page allowing it to be customised.
Since there was a dependency conflict between frontend-plugin-framework and the react-hooks testing package, the react-hooks testing package has been removed and a replaced with a simple mechanism for testing hooks.
Since this touched the Login Page those have also been refactored to move away from redux connect.
How Has This Been Tested?
Testing with a simple env.config.jsx, using automated tests and manual testing of login
Screenshots/sandbox (optional):
Include a link to the sandbox for design changes or screenshot for before and after. Remove this section if its not applicable.
Merge Checklist
Post-merge Checklist
Private-ref: https://tasks.opencraft.com/browse/BB-9095