Skip to content
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

Merged
merged 12 commits into from
Oct 25, 2024

Conversation

sundasnoreen12
Copy link
Collaborator

@sundasnoreen12 sundasnoreen12 commented Oct 1, 2024

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:

  1. notifications.enable_new_notification_view
  2. notifications.show_notifications_tray
  3. notifications.enable_notification

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.

Copy link
Member

@awais-ansari awais-ansari left a 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.

src/common/context.js Outdated Show resolved Hide resolved
src/new-notifications/data/hook.js Outdated Show resolved Hide resolved
src/new-notifications/data/hook.js Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 89.56522% with 36 lines in your changes missing coverage. Please review.

Project coverage is 78.00%. Comparing base (01e5f14) to head (f7f52f3).
Report is 28 commits behind head on master.

Files with missing lines Patch % Lines
src/new-notifications/tours/data/hooks.js 56.25% 14 Missing ⚠️
src/new-notifications/index.jsx 88.23% 5 Missing and 1 partial ⚠️
src/new-notifications/data/hook.js 95.00% 3 Missing ⚠️
src/new-notifications/tours/data/api.js 57.14% 3 Missing ⚠️
src/new-notifications/utils.js 88.88% 3 Missing ⚠️
.../learning-header/New-AuthenticatedUserDropdown.jsx 93.33% 2 Missing ⚠️
src/new-notifications/tours/constants.js 0.00% 2 Missing ⚠️
src/learning-header/AuthenticatedUserDropdown.jsx 66.66% 1 Missing ⚠️
src/new-notifications/NotificationSections.jsx 97.22% 1 Missing ⚠️
src/new-notifications/tours/NotificationTour.jsx 91.66% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jsnwesson jsnwesson left a 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!

Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

Left some comments, with a few clarifying higher level questions (e.g., around the boundaries between notifications and the authenticated user dropdown). Most of the comments pertain to styling/theming, addressing ESLint rules like react-hooks/exhaustive-deps vs. disabling them, and a sanity check around a possible race condition when marking notification as "read" when clicking a hyperlink.

src/new-notifications/NotificationRowItem.jsx Outdated Show resolved Hide resolved
src/new-notifications/NotificationRowItem.jsx Outdated Show resolved Hide resolved
src/learning-header/New-AuthenticatedUserDropdown.jsx Outdated Show resolved Hide resolved
src/new-notifications/notification.scss Outdated Show resolved Hide resolved
src/new-notifications/notification.scss Outdated Show resolved Hide resolved
src/new-notifications/NotificationTabs.jsx Show resolved Hide resolved
src/new-notifications/index.jsx Outdated Show resolved Hide resolved
src/new-notifications/index.jsx Outdated Show resolved Hide resolved
src/new-notifications/index.jsx Outdated Show resolved Hide resolved
src/new-notifications/index.jsx Outdated Show resolved Hide resolved
@sundasnoreen12 sundasnoreen12 force-pushed the sundas/INF-1603 branch 6 times, most recently from 84c2b01 to 12d8092 Compare October 15, 2024 12:08
src/new-notifications/NotificationTabs.jsx Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/learning-header/LearningHeader.jsx Outdated Show resolved Hide resolved
src/new-notifications/NotificationRowItem.jsx Show resolved Hide resolved
src/new-notifications/notificationTabs.test.jsx Outdated Show resolved Hide resolved
src/new-notifications/tours/NotificationTour.jsx Outdated Show resolved Hide resolved
src/new-notifications/utils.js Outdated Show resolved Hide resolved
Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

LGTM, with a couple comments. I appreciate all your iteration through the feedback! 🙌

src/learning-header/AuthenticatedUser.jsx Outdated Show resolved Hide resolved
src/learning-header/AuthenticatedUser.jsx Outdated Show resolved Hide resolved
src/learning-header/AuthenticatedUser.jsx Outdated Show resolved Hide resolved
@sundasnoreen12 sundasnoreen12 merged commit 6a1d2c2 into master Oct 25, 2024
6 checks passed
@sundasnoreen12 sundasnoreen12 deleted the sundas/INF-1603 branch October 25, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants