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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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.

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.

3 participants