-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: converted notification redux structure to context API #598
base: master
Are you sure you want to change the base?
Conversation
4c2b880
to
8967d0a
Compare
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.
Create a context folder and move all the context there.
995a8a7
to
f7f52f3
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #598 +/- ##
==========================================
+ Coverage 72.47% 78.00% +5.53%
==========================================
Files 52 74 +22
Lines 821 1205 +384
Branches 169 253 +84
==========================================
+ Hits 595 940 +345
- Misses 216 254 +38
- Partials 10 11 +1 ☔ View full report in Codecov by Sentry. |
@@ -70,6 +71,10 @@ const AuthenticatedUserDropdown = (props) => { | |||
careersMenuItem = ''; | |||
} | |||
|
|||
if (isNewNotificationViewEnabled) { |
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.
is there a reason why this condition can't be further up in LearningHeader.jsx?
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.
The value of isNewNotificationViewEnabled is derived from the count API, which is called in AuthenticatedUserDropdown for the Redux structure and in NewAuthenticatedUserDropdown for the Context API structure. Moving this condition up to LearningHeader.jsx would mean calling the count API for both Redux and Context API structures in the same file. To maintain separation between the two architectures, it's more efficient to keep the current structure until we fully transition away from Redux. Does that make sense?
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.
Ahh, that does make sense, I didn't catch that the Context API was the reason for writing it this way. Does this mean that there will eventually be a follow-up ticket to remove the old AuthenticatedUserDropdown and/or Redux, or is that a hope for eventual future work?
email={authenticatedUser.email} | ||
/> | ||
<> | ||
<AuthenticatedUserDropdown |
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.
Connected to my previous question in AuthenticatedUserDropdown.jsx
, presenting both AuthenticatedUserDropdown
and NewAuthenticatedUserDropdown
here makes it look like both should be rendered. Even if this is all temporary and the plan is to remove the old dropdown, I think it'd make sense to keep the if (isNewNotificationViewEnabled)
condition here where it clearly demonstrates the repercussions of that boolean.
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.
Explanation in the above comment
37206bd
to
d77a779
Compare
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.
One thing I'd suggest is that I noticed the test files for NotificationRowItem
, NotificationSections
, and NotificationTabs
start with a lowercase letter, but that's probably more of a nit pick than something that would affect the tests passing/failing.
Otherwise, this looks okay to me!
https://2u-internal.atlassian.net/browse/INF-1603
Purpose
The purpose of converting the notification architecture from Redux to the Context API is to eliminate duplicated providers and stores, streamlining the structure and improving efficiency in managing state across the application.
Description
We have refactored the state management of the notification tray, transitioning from Redux to the Context API as the central store. This involved replacing all dispatch calls in the reducer with direct API calls, and managing server data through the Context provider. This change centralizes state management and resolves the issue of duplicate providers.
We have introduced a new waffle flag, “notifications.enable_new_notification_view,” in the backend as part of PR #35569.
All changes related to the Context API have been organized in a new folder named “new-notifications,” while the existing Redux architecture remains intact in the “Notifications” folder. This approach allows us to test the Context API structure by enabling the waffle flag on the staging environment. Once testing is complete, we plan to remove the Redux-related notifications folder and exclusively utilize the new notifications folder that incorporates the Context API changes.
Test
I conducted testing on the local machine by enabling these waffle flags and following the instructions outlined in the document found here:
Note: I have made updates specifically for the Learning Header for now. Since the Discussion MFE uses the Learning Header, I tested the notification tray locally on that implementation.