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

Create infrastructure for systemwide and user notifications in OneMAC Application #1512

Draft
wants to merge 14 commits into
base: onemacmmdl
Choose a base branch
from

Conversation

andieswift
Copy link
Collaborator

@andieswift andieswift commented Sep 24, 2024

Story: https://qmacbis.atlassian.net/browse//OY2-30181
Endpoint: https://d3o6kg6uaumkqe.cloudfront.net/

Details

As a developer, I want to create a notification banner infrastructure that can deliver a set of messages to the front end. These messages could be either system messages displayed for all users or user specific messages that are displayed per user. The per user messages should be able to be removed through a dismiss operation.

Changes

backend:
created the following api endpoints:
getActiveSystemNotifications: will get all active system notifications based on publication and expiry date
getActiveUserNotifications: will get all active user notifications that have been published since last user login
dismissUserNotification: will mark a user notification as dismissed
createUserNotifications: create new records for the given user that are active and not yet in the users pk; returns the collection of notifications created; this method will also dismiss any previous notifications the user had as active

frontend:
NotificationApi: API for all things Notifications
NotificationBanner: component for the user Notification's that appear at the top of every page
NotificationCard: component for system wide Notifications which appear on the home page

Implementation Notes

backend:

  • getActiveUserNotifications turned out to not be utilized since we combined the functionality into the createUserNotifications as it already returns the notifications that were created. Combine that with the fact that this method is only called upon login (or when not in local storage) and for this implementation notifications should only be displayed on first login, therefore only new notifications need to be displayed. We decided to keep the function since it was already built and could be utilized in the future.
    frontend:
  • using context in App.tsx to store user notifications so that it displays across all the application
  • context does not store on refresh, so for user notifications we also used local storage
  • the props for the notification components use the same type as returned from notificationApi
  • the system notification has an API call on the home.js page

https://qmacbis.atlassian.net/wiki/spaces/MACPRO/pages/3657957377/User+Notification+System+Architecture+and+Implementation

Screenshots

Screenshot 2024-09-23 at 12 24 34 PM

Test Plan

  1. Insert test records to DB (both system and user_notification)
  2. Verify system notification is displayed on home page even when unauthenticated
  3. Verify upon login the user notification is displayed for the user and the system notification is still displayed on home page
  4. Navigate within application and verify user notification continues to display
  5. Refresh or close browser and reload and verify user notification still displays
  6. Dismiss user notification and navigate application; verify user notification no longer appears
  7. Logout and the Login and verify user notification is no longer there (Retry this step also without first manually dismissing)

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.

2 participants