FEATURE: Reason and deleted content support in the review queue (#30295)

Add flag reason filter and improve handling of deleted content in review queue

This commit enhances the review queue with several key improvements:

1. Adds a new "Reason" filter to allow filtering flags by their score type
2. Improves UI for deleted content by:
   - Adding visual indication for deleted posts (red background)
   - Properly handling deleted content visibility for staff (category mods can not see deleted content)
3. Refactors reviewable score type handling for better code organization
4. Adds  tests for trashed topics/posts visibility

This change will help moderators more efficiently manage the review queue by
being able to focus on specific types of flags and better identify deleted
content.
This commit is contained in:
Sam
2024-12-17 11:44:46 +11:00
committed by GitHub
parent d43d8e0023
commit 55a8184231
12 changed files with 158 additions and 6 deletions

View File

@@ -449,7 +449,8 @@ class Reviewable < ActiveRecord::Base
additional_filters: {},
preload: true,
include_claimed_by_others: true,
flagged_by: nil
flagged_by: nil,
score_type: nil
)
order =
case sort_order
@@ -489,6 +490,16 @@ class Reviewable < ActiveRecord::Base
SQL
end
if score_type
score_type = score_type.to_i
result = result.where(<<~SQL, score_type: score_type)
EXISTS(
SELECT 1 FROM reviewable_scores
WHERE reviewable_scores.reviewable_id = reviewables.id AND reviewable_scores.reviewable_score_type = :score_type
)
SQL
end
if reviewed_by
reviewed_by_id = User.find_by_username(reviewed_by)&.id
return none if reviewed_by_id.nil?

View File

@@ -14,6 +14,12 @@ class ReviewableScore < ActiveRecord::Base
@types ||= PostActionType.flag_types.merge(PostActionType.score_types)
end
def self.type_title(type)
I18n.t("post_action_types.#{type}.title", default: nil) ||
I18n.t("reviewable_score_types.#{type}.title", default: nil) ||
PostActionType.names[types[type]]
end
# When extending post action flags, we need to call this method in order to
# get the latests flags.
def self.reload_types