Skip to content

Add a "watch" button to add/change notifications for datasets#2819

Open
robyngit wants to merge 11 commits into
developfrom
feature-2252-notification-models
Open

Add a "watch" button to add/change notifications for datasets#2819
robyngit wants to merge 11 commits into
developfrom
feature-2252-notification-models

Conversation

@robyngit
Copy link
Copy Markdown
Member

This PR adds a notification subscription modal for managing object-level notification subscriptions. It adds a "Watch" button from the dataset landing page that allows users open the modal for a dataset, review their current subscriptions, select or clear supported notification types, and save changes through the updated notification-service-js library.

image

Changes

  • Add ObjectNotification model to handle notification state, setup checks, current subscriptions, and save/unsubscribe logic.
  • Add NotificationModalView for the dataset notification subscription UI.
  • Render the Watch button and insert the modal into DatasetControlsView (conditionally, if the appModel has notifications turned on.)
  • Add app-level Notification Service configuration, including supported resource types with labels and descriptions. Notifications are turned off by default, but can easily be turned on when the backend service is ready.
  • Show clear states for loading, signed-out users, missing email addresses, save failures, and successful saves.
  • Fix the getTokenPromise method in UserModel
  • Add unit tests for ObjectNotification and NotificationModalView.

Testing

The WIP notification service is available at https://notifications.test.dataone.org/notifications. This demo expects tokens from https://metacat-dev.test.dataone.org/. So the following app model options should be added for testing this modal:

{
  theme: "arctic", // or any theme
  d1CNBaseUrl: "https://cn-sandbox.test.dataone.org/",
  root: "/",
  metacatContext: "metacat",
  baseUrl: "https://metacat-dev.test.dataone.org/",
  notificationServiceUrl:
    "https://notifications.test.dataone.org/notifications",
  enableNotificationService: true
};

Note the full notification-service-js library that wraps all of the notification-service API can be tested here: https://dataoneorg.github.io/notification-service-js/

Closes #2757

- Install the current WIP notificationService package & add npm action to update in the future
- Add config options to AppModel to enable/disable the notification service, set url, and set resource types

Issue #2252
- Update to the current version of notification-service-js, which aligns with the new backend API.
- Neither JS client nor backend are versioned yet

Issue #2252
- Align view to use the recently updated notification-service-js library
- Also fix a small bug where the client const was missing

Issue #2252
- Configure notification resource types with labels and descriptions
- Add Watch button wiring from dataset controls to NotificationServiceView
- Implement modal loading, checkbox state, save diffing, unsubscribe handling, and cancel reset
- Require a user email address before managing notification subscriptions
- Fix user token promise handling for notification service requests

Issue #2252
- Add BEM styling for the modal via MetacatUI.appModel.addCSS
- Make signing and missing email errors more user-friendly and informative

Issue #2252
- emit a saved event from NotificationServiceView after subscription changes are successfully saved
- make DatasetControlsView briefly switch the Watch button to a checkmarked "Saved" state before restoring to normal

Issue #2252
- Rename NotificationServiceView to NotificationModalView, remove model logic
- Rename modal CSS to match the new modal view name
- Add ObjectNotification model for setup checks, client creation, load/save state, and subscription diffs
- Update DatasetControlsView to use the renamed modal view
- Add unit tests

Issue #2252
- Prevent the modal from updating itself with old data when a request finishes after auth/config has changed
- Ignore outdated load and save results so they don't overwrite the current state
- Add tests to cover stale loads and save success/failure cases

Issue #2252
- Move notification model, view, specs, and screenshots into `notifications/` directories and update refs
- In modal header, separate the "Manage notifications for" prefix from the dataset title, truncate long titles, & pin the close button to the upper-right (for consistency with other views)
- Increase checkbox size, make full notification type rows clickable, and put modal sizing values in CSS custom properties

Issue #2757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant