Skip to content

New Watchlist

Dany Marcoux edited this page Feb 21, 2022 · 5 revisions

Data model

We can watch Projects, Packages and BsRequests.

Polymorphic association: watchable.

Table watched_items

  • watchable_id
  • watchable_type
  • user_id

Project

has_many :watched_items, as: :watchable

Package

has_many :watched_items, as: :watchable

BsRequest

has_many :watched_items, as: :watchable

WatchedItem

  belongs_to :watchable, polymorphic: true
  belongs_to :user

Controller

The action Webui::WatchedItemsController#toggle is in charge of adding or removing an item from the watchlist. There are three routes (one per each type of object: project, package, request) that end up in this controller action.

'watched_items/package/:project/:package/toggle'
'watched_items/project/:project/toggle'
'watched_items/request/:number/toggle'

Feature Toggle

This feature is behind the new_watchlist feature toggle. The watchlist replaces the old one allowing users to watch packages and requests in addition to projects.

User Operations

Those operations should be behind the feature toggle.

We could:

  • a user watches a project/package/bs_request
  • a user stops watching a project/package/bs_request
  • list projects/packages/bs_requests a user is watching

Checking permissions to

  • anyone can watch items for themselves
  • nobody can watch items for anyone else, but admins can
  • nobody can stop watching items from someone else's watchlist, but admins can
  • only the user can see their own watchlist

Steps

  • Create the migration
  • Update models
  • Create the feature flag
  • Implement the controllers to manage watchables
  • Implement the new UI behind the feature flag

Data and migration

Once the feature is rolled out, we'll need to sync the data with data migration. Adding the projects the user had in the old watched_projects table to the new watched_items table.

UI Improvements

Bookmark a project, package or request by clicking on an icon near the project name, package name or request name (:fa-bookmark)

Clone this wiki locally