DEV: Include pending reviewables in the main tab in the user menu (#18471)

This commit makes pending reviewables show up in the main tab (a.k.a. "all notifications" tab). Pending reviewables along with unread notifications are always shown first and they're sorted based on their creation date (most recent comes first).

The dismiss button currently only shows up if there are unread notifications and it doesn't dismiss pending reviewables. We may follow up with another change soon that allows makes the dismiss button work with reviewables and remove them from the list without taking any action on them. 

Follow-up to 079450c9e4.
This commit is contained in:
Osama Sayegh
2022-10-05 12:30:02 +03:00
committed by GitHub
parent c0037dc0f0
commit 4d05e3edab
12 changed files with 394 additions and 125 deletions

View File

@ -71,9 +71,11 @@ class ReviewablesController < ApplicationController
end
def user_menu_list
reviewables = Reviewable.list_for(current_user, limit: 30, status: :pending).to_a
json = {
reviewables: reviewables.map! { |r| r.basic_serializer.new(r, scope: guardian, root: nil).as_json }
reviewables: Reviewable.basic_serializers_for_list(
Reviewable.user_menu_list_for(current_user),
current_user
).as_json
}
render_json_dump(json, rest_serializer: true)
end