Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove reviewable_ui_refresh feature flag and legacy code (#36752)

Krzysztof Kotlarek53d799eb8b18
diff --git a/app/models/concerns/reviewable_action_builder.rb b/app/models/concerns/reviewable_action_builder.rb
index a3275582321..d67bc8bc016 100644
--- a/app/models/concerns/reviewable_action_builder.rb
+++ b/app/models/concerns/reviewable_action_builder.rb
@@ -5,129 +5,23 @@ module ReviewableActionBuilder
attr_accessor :actions, :guardian, :action_args
- # Standard post-actions bundle. Consumers should use the returned
- # bundle value when adding post-focused actions.
- #
- # @return [Reviewable::Actions::Bundle] The created post actions bundle.
- def build_post_actions_bundle
- bundle_actions = { no_action_post: {} }
- if target_post
- if target_post.trashed? && @guardian.can_recover_post?(target_post)
- bundle_actions[:restore_post] = {}
- end
-
- if target_post.hidden?
- bundle_actions[:unhide_post] = {} if !target_post.user_deleted?
- else
- bundle_actions[:hide_post] = {}
- end
-
- if @guardian.can_delete_post_or_topic?(target_post)
- bundle_actions[:delete_post] = {}
- bundle_actions[:delete_post_and_replies] = { confirm: true } if target_post.reply_count > 0
- end
-
- bundle_actions[:edit_post] = { client_action: "edit" }
-
- bundle_actions[:convert_to_pm] = {}
- end
-
- build_bundle(
- "#{id}-post-actions",
- "reviewables.actions.post_actions.bundle_title",
- bundle_actions,
- source: "core",
- )
- end
-
- # Standard user-actions bundle and default user actions.
- #
- # @return [Reviewable::Actions::Bundle] The created user actions bundle.
- def build_user_actions_bundle
- bundle_actions = { no_action_user: {} }
- if target_user
- if @guardian.can_silence_user?(target_user)
- bundle_actions[:silence_user] = { client_action: "silence" }
- end
-
- if @guardian.can_suspend?(target_user)
- bundle_actions[:suspend_user] = { client_action: "suspend" }
- end
-
- if @guardian.can_delete_user?(target_user)
- bundle_actions[:delete_user] = {}
- bundle_actions[:delete_and_block_user] = {}
- end
- end
-
- build_bundle(
- "#{id}-user-actions",
- "reviewables.actions.user_actions.bundle_title",
- bundle_actions,
- source: "core",
- )
- end
-
- # Build actions for the reviewable based on the current state and guardian permissions.
- #
- # @TODO (reviewable-refresh) Replace this method with {Reviewable#build_actions} once the new UI is fully implemented.
- #
- # @param actions [Reviewable::Actions] Actions instance to add the bundle to.
- # @param guardian [Guardian] Guardian instance to check permissions.
- # @param args [Hash] Additional arguments for building actions.
- #
- # @return [void]
def build_actions(actions, guardian, args)
@actions = actions
@guardian = guardian
@action_args = args
- if guardian.can_see_reviewable_ui_refresh? && !SiteSetting.reviewable_old_moderator_actions
- build_new_separated_actions
- else
+ # For backward compatibility with plugins that override build_legacy_combined_actions
+ if respond_to?(:build_legacy_combined_actions)
build_legacy_combined_actions(actions, guardian, args)
+ else
+ build_combined_actions(actions, guardian, args)
end
end
- # Build legacy combined actions for the reviewable.
- #
- # Classes that include this module should implement this method to define
- # the legacy combined actions for their specific reviewable type.
- #
- # @TODO (reviewable-refresh) Remove this method once the new UI is fully implemented.
- #
- # @param actions [Reviewable::Actions] Actions instance to add the bundle to.
- # @param guardian [Guardian] Guardian instance to check permissions.
- # @param args [Hash] Additional arguments for building actions.
- #
- # @return [void]
- def build_legacy_combined_actions(actions, guardian, args)
- raise NotImplementedError, "Including class must implement #build_legacy_combined_actions"
- end
-
- # Build new separated actions for the reviewable.
- #
- # Classes that include this module should implement this method to define
- # the new separated actions for their specific reviewable type.
- #
- # @TODO (reviewable-refresh) Remove this method once the new UI is fully implemented.
- #
- # @return [void]
- def build_new_separated_actions
- raise NotImplementedError, "Including class must implement #build_new_separated_actions"
+ def build_combined_actions(actions, guardian, args)
+ raise NotImplementedError, "Including class must implement #build_combined_actions"
end
- # Build a bundle of actions and add it to the provided actions list.
- #
- # @param id [String] ID for the bundle, used to derive I18n keys.
- # @param label [String] I18n key for the bundle label.
- # @param bundle_actions [Hash] Hash of action IDs and optional params to pass to build_action.
- # @option bundle_actions [Symbol] :client_action Optional client-side action identifier (e.g. "edit").
- # @option bundle_actions [Symbol] :confirm When true, uses "reviewables.actions.<id>.confirm" for confirm_message.
- # @option bundle_actions [Symbol] :require_reject_reason When true, requires a rejection reason for the action.
- # @param source [String] Optional source string for namespacing I18n keys. Will default to `type_source`.
- #
- # @return [Reviewable::Actions::Bundle] The created bundle.
def build_bundle(id, label, bundle_actions = {}, source: nil)
bundle = @actions.add_bundle(id, label:)
bundle_actions.each do |action_id, action_params|
@@ -136,20 +30,6 @@ module ReviewableActionBuilder
bundle
end
- # Build a single reviewable action and add it to the provided actions list.
- # This is the canonical API used by both the legacy and refreshed UI code paths.
- #
- # @param actions [Reviewable::Actions] Actions instance to add to.
- # @param id [Symbol] Symbol for the action, used to derive I18n keys.
- # @param icon [String] Optional name of the icon to display with the action. Ignored in the refreshed UI.
- # @param button_class [String] Optional CSS class for buttons in clients that render it. Ignored in the refreshed UI.
- # @param bundle [Reviewable::Actions::Bundle] Optional bundle object returned by add_bundle to group actions.
- # @param client_action [String] Optional client-side action identifier (e.g. "edit").
- # @param confirm [Boolean] When true, uses "reviewables.actions.<id>.confirm" for confirm_message.
- # @param require_reject_reason [Boolean] When true, requires a rejection reason for the action.
- # @param source [String] Optional source string for namespacing I18n keys. Will default to `type_source`.
- #
- # @return [Reviewable::Actions] The updated actions instance.
def build_action(
actions,
id,
@@ -180,14 +60,6 @@ module ReviewableActionBuilder
end
end
- def perform_no_action_user(performed_by, args)
- create_result(:success, :ignored)
- end
-
- def perform_no_action_post(performed_by, args)
- create_result(:success, :ignored)
- end
-
def perform_silence_user(performed_by, args)
create_result(:success, :rejected)
end
@@ -215,8 +87,6 @@ module ReviewableActionBuilder
end
def perform_hide_post(performed_by, _args)
- # TODO (reviewable-refresh): This hard-coded post action type needs to make use of the
- # original flag type. See ReviewableFlaggedPost::perform_agree_and_hide for reference.
target_post.hide!(PostActionType.types[:inappropriate])
create_result(:success, :rejected, [created_by_id], false)
end
@@ -237,11 +107,6 @@ module ReviewableActionBuilder
create_result(:success, :approved, [created_by_id], false)
end
- def perform_convert_to_pm(performed_by, _args)
- # TODO (reviewable-refresh): Implement convert to PM logic
- create_result(:success, :rejected, [created_by_id], false)
- end
-
private
# Returns the user associated with the reviewable, if applicable.
diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb
index 3a58999ca2f..0653d624506 100644
--- a/app/models/reviewable.rb
+++ b/app/models/reviewable.rb
@@ -34,7 +34,6 @@ class Reviewable < ActiveRecord::Base
has_many :reviewable_histories, dependent: :destroy
has_many :reviewable_scores, -> { order(created_at: :desc) }, dependent: :destroy
has_many :reviewable_notes, -> { order(created_at: :asc) }, dependent: :destroy
- has_many :reviewable_action_logs, -> { order(created_at: :asc) }, dependent: :destroy
enum :status, { pending: 0, approved: 1, rejected: 2, ignored: 3, deleted: 4 }
@@ -356,10 +355,6 @@ class Reviewable < ActiveRecord::Base
validate_action!(guardian, action_id, perform_method, args)
- # Bundle needs to be determined before the action is performed, as bundles
- # are dynamic based on the state of the reviewable.
- action_bundle_id = get_action_bundle_id(guardian, action_id, args)
-
result = nil
update_count = false
Reviewable.transaction do
@@ -368,38 +363,9 @@ class Reviewable < ActiveRecord::Base
raise ActiveRecord::Rollback unless result.success?
- if result.transition_to
- reviewable_action_logs.create!(
- action_key: action_id.to_s,
- status: result.transition_to,
- performed_by: performed_by,
- bundle: action_bundle_id,
- )
- end
-
- if !guardian.can_see_reviewable_ui_refresh? || SiteSetting.reviewable_old_moderator_actions
- update_count = transition_to(result.transition_to, performed_by) if result.transition_to
- update_flag_stats(**result.update_flag_stats) if result.update_flag_stats
-
- recalculate_score if result.recalculate_score
- else
- Review::CalculateFinalStatusFromLogs.call(
- params: {
- reviewable_id: id,
- guardian: guardian,
- args: args,
- },
- ) do
- on_success do |status:|
- unless status == :pending
- update_count = transition_to(status, performed_by)
- update_flag_stats(**result.update_flag_stats) if result.update_flag_stats
-
- recalculate_score if result.recalculate_score
- end
- end
- end
- end
+ update_count = transition_to(result.transition_to, performed_by) if result.transition_to
+ update_flag_stats(**result.update_flag_stats) if result.update_flag_stats
+ recalculate_score if result.recalculate_score
end
result.after_commit.call if result && result.after_commit
@@ -680,7 +646,6 @@ class Reviewable < ActiveRecord::Base
@@serializers[type] ||= lookup_serializer_for(type)
end
- # @TODO (reviewable-refresh) This can be deprecated/removed once all reviewable types have been migrated, it now lives in ReviewableActionBuilder.
def create_result(status, transition_to = nil)
result = PerformResult.new(self, status)
result.transition_to = transition_to
@@ -790,7 +755,6 @@ class Reviewable < ActiveRecord::Base
self.score
end
- # TODO (reviewable-refresh) This can be deprecated/removed once all reviewable types have been migrated.
def delete_user_actions(actions, bundle = nil, require_reject_reason: false)
bundle ||=
actions.add_bundle(
@@ -893,25 +857,6 @@ class Reviewable < ActiveRecord::Base
end
end
- def get_action_bundle_id(guardian, action_id, args)
- action_aliases = [
- action_id,
- aliases.to_a.select { |k, v| v == action_id }.map(&:first),
- ].flatten.map(&:to_s)
-
- actions = actions_for(guardian, args)
- bundle_id = nil
- actions.bundles.each do |bundle|
- if bundle.actions.any? { |a| action_aliases.include?(a.server_action.to_s) }
- bundle_id = bundle.bundle_id
- break
- end
- end
-
- # For old UI actions that aren't in the new separated bundles, use a default bundle
- bundle_id ||= "legacy-actions"
- end
-
def update_flag_stats(status:, user_ids:)
return if %i[agreed disagreed ignored].exclude?(status)
diff --git a/app/models/reviewable_action_log.rb b/app/models/reviewable_action_log.rb
deleted file mode 100644
index 19f3cc4da58..00000000000
--- a/app/models/reviewable_action_log.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-class ReviewableActionLog < ActiveRecord::Base
- belongs_to :reviewable
- belongs_to :performed_by, class_name: "User"
-
- validates :action_key, :status, :performed_by_id, presence: true
-
- enum :status, Reviewable.statuses.dup, prefix: :status, scopes: false
-end
-
-# == Schema Information
-#
-# Table name: reviewable_action_logs
-#
-# id :bigint not null, primary key
-# reviewable_id :bigint not null
-# action_key :string not null
-# status :integer not null
-# performed_by_id :integer not null
-# bundle :string default("legacy-actions"), not null
-# created_at :datetime not null
-# updated_at :datetime not null
-#
-# Indexes
-#
-# index_reviewable_action_logs_on_bundle (bundle)
-# index_reviewable_action_logs_on_performed_by_id (performed_by_id)
-# index_reviewable_action_logs_on_reviewable_id (reviewable_id)
-#
diff --git a/app/models/reviewable_flagged_post.rb b/app/models/reviewable_flagged_post.rb
index dac04e5d4d9..5aaeec2b677 100644
--- a/app/models/reviewable_flagged_post.rb
+++ b/app/models/reviewable_flagged_post.rb
@@ -50,8 +50,7 @@ class ReviewableFlaggedPost < Reviewable
super
end
- # TODO (reviewable-refresh): Remove legacy method once new UI fully deployed
- def build_legacy_combined_actions(actions, guardian, args)
+ def build_combined_actions(actions, guardian, args)
# existing combined logic
agree_bundle =
actions.add_bundle("#{id}-agree", icon: "thumbs-up", label: "reviewables.actions.agree.title")
@@ -149,12 +148,6 @@ class ReviewableFlaggedPost < Reviewable
end
end
- # TODO (reviewable-refresh): Merge into build_actions post rollout.
- def build_new_separated_actions
- build_post_actions_bundle
- build_user_actions_bundle
- end
-
def perform_ignore(performed_by, args)
perform_ignore_and_do_nothing(performed_by, args)
end
diff --git a/app/models/reviewable_post.rb b/app/models/reviewable_post.rb
index 3e5827b53bf..3566299a78e 100644
--- a/app/models/reviewable_post.rb
+++ b/app/models/reviewable_post.rb
@@ -37,8 +37,7 @@ class ReviewablePost < Reviewable
super
end
- # TODO (reviewable-refresh): Remove this method when fully migrated to new UI
- def build_legacy_combined_actions(actions, guardian, args)
+ def build_combined_actions(actions, guardian, args)
if post.trashed? && guardian.can_recover_post?(post)
build_action(actions, :approve_and_restore, icon: "check")
elsif post.hidden?
@@ -94,13 +93,6 @@ class ReviewablePost < Reviewable
end
end
- # TODO (reviewable-refresh): Merge this method into build_actions when fully migrated to new UI
- def build_new_separated_actions
- build_post_actions_bundle
- build_user_actions_bundle
- end
-
- # TODO (reviewable-refresh): Remove combined actions below when fully migrated to new UI
def perform_approve(performed_by, _args)
create_result(:success, :approved, [created_by_id], false)
end
@@ -131,7 +123,6 @@ class ReviewablePost < Reviewable
def perform_reject_and_suspend(performed_by, _args)
create_result(:success, :rejected, [created_by_id], false)
end
- # TODO (reviewable-refresh): Remove combined actions above when fully migrated to new UI
private
diff --git a/app/models/reviewable_queued_post.rb b/app/models/reviewable_queued_post.rb
index 7255cbb0c20..c32856bf210 100644
--- a/app/models/reviewable_queued_post.rb
+++ b/app/models/reviewable_queued_post.rb
@@ -38,8 +38,7 @@ class ReviewableQueuedPost < Reviewable
reviewable_scores.pending.or(reviewable_scores.disagreed)
end
- # TODO (reviewable-refresh): Remove this method once new UI is fully deployed
- def build_legacy_combined_actions(actions, guardian, args)
+ def build_combined_actions(actions, guardian, args)
unless approved?
if topic&.closed?
build_action(actions, :approve_post_closed, icon: "check", confirm: true)
@@ -64,27 +63,6 @@ class ReviewableQueuedPost < Reviewable
build_action(actions, :delete) if guardian.can_delete?(self)
end
- def build_new_separated_actions
- # Because a queued post isn't a real post, we need to create our own post actions bundle
- post_actions_bundle = build_post_actions_bundle
-
- unless approved?
- if topic&.closed?
- build_action(actions, :approve_post, bundle: post_actions_bundle, confirm: true)
- elsif target_created_by.present?
- build_action(actions, :approve_post, bundle: post_actions_bundle)
- end
- end
-
- if pending?
- build_action(actions, :reject_post, bundle: post_actions_bundle)
- build_action(actions, :revise_and_reject_post, bundle: post_actions_bundle)
- end
-
- # User actions bundle
- build_user_actions_bundle if pending?
- end
-
def build_editable_fields(fields, guardian, args)
if pending?
# We can edit category / title if it's a new topic
diff --git a/app/models/reviewable_user.rb b/app/models/reviewable_user.rb
index d326661977d..55b356903e6 100644
--- a/app/models/reviewable_user.rb
+++ b/app/models/reviewable_user.rb
@@ -11,7 +11,7 @@ class ReviewableUser < Reviewable
{ reject_reason: params[:reject_reason], send_email: params[:send_email] != "false" }
end
- def build_legacy_combined_actions(actions, guardian, args)
+ def build_combined_actions(actions, guardian, args)
if status == "rejected" && !payload["scrubbed_by"]
build_action(actions, :scrub, client_action: "scrub")
end
@@ -50,30 +50,6 @@ class ReviewableUser < Reviewable
super
end
- # TODO (reviewable-refresh): Move to build_actions when fully migrated to new UI
- def build_new_separated_actions
- bundle_actions = {}
- if status == "pending"
- bundle_actions[:approve_user] = {} if target_user && !target_user.approved? &&
- guardian.can_approve?(target_user)
-
- if @guardian.can_delete_user?(target_user)
- bundle_actions[:delete_user] = {}
- bundle_actions[:delete_user_block] = {}
- end
- end
- if status == "rejected" && !payload["scrubbed_by"]
- bundle_actions[:scrub] = { client_action: "scrub" }
- end
-
- build_bundle(
- "#{id}-user-actions",
- "reviewables.actions.user_actions.bundle_title",
- bundle_actions,
- source: "core",
- )
- end
-
def perform_approve_user(performed_by, args)
ReviewableUser.set_approved_fields!(target, performed_by)
target.save!
diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb
index 87fa81f69d1..72d27d4a35f 100644
--- a/app/serializers/current_user_serializer.rb
+++ b/app/serializers/current_user_serializer.rb
@@ -81,7 +81,6 @@ class CurrentUserSerializer < BasicUserSerializer
:can_see_emails,
:can_localize_content?,
:effective_locale,
- :use_reviewable_ui_refresh,
:can_see_ip,
:is_impersonating
@@ -368,14 +367,6 @@ class CurrentUserSerializer < BasicUserSerializer
SiteSetting.content_localization_enabled
end
- def use_reviewable_ui_refresh
- scope.can_see_reviewable_ui_refresh?
- end
-
- def include_use_reviewable_ui_refresh?
- scope.can_see_review_queue?
- end
-
def can_see_ip
scope.can_see_ip?
end
diff --git a/app/serializers/flagged_user_serializer.rb b/app/serializers/flagged_user_serializer.rb
index f9464b78726..70f421e614b 100644
--- a/app/serializers/flagged_user_serializer.rb
+++ b/app/serializers/flagged_user_serializer.rb
@@ -64,34 +64,6 @@ class FlaggedUserSerializer < BasicUserSerializer
result
end
- def include_created_at?
- scope.can_see_reviewable_ui_refresh?
- end
-
- def include_custom_fields?
- scope.can_see_reviewable_ui_refresh?
- end
-
- def include_post_count?
- scope.can_see_reviewable_ui_refresh?
- end
-
- def include_trust_level?
- scope.can_see_reviewable_ui_refresh?
- end
-
- def include_silenced_count?
- scope.can_see_reviewable_ui_refresh?
- end
-
- def include_suspended_count?
- scope.can_see_reviewable_ui_refresh?
- end
-
- def include_rejected_posts_count?
- scope.can_see_reviewable_ui_refresh?
- end
-
def include_email?
scope.can_check_emails?(scope.user)
end
diff --git a/app/serializers/reviewable_serializer.rb b/app/serializers/reviewable_serializer.rb
index 16ab0e27030..0aee54468b4 100644
--- a/app/serializers/reviewable_serializer.rb
+++ b/app/serializers/reviewable_serializer.rb
@@ -193,8 +193,6 @@ class ReviewableSerializer < ApplicationSerializer
return if user.blank?
- serializer_class =
- scope.can_see_reviewable_ui_refresh? ? FlaggedUserSerializer : UserWithCustomFieldsSerializer
- serializer_class.new(user, scope:, root: false)
+ FlaggedUserSerializer.new(user, scope: scope, root: false)
end
end
diff --git a/app/serializers/reviewable_user_serializer.rb b/app/serializers/reviewable_user_serializer.rb
index 626a42fef7b..e36e9d2c9f5 100644
--- a/app/serializers/reviewable_user_serializer.rb
+++ b/app/serializers/reviewable_user_serializer.rb
@@ -41,6 +41,6 @@ class ReviewableUserSerializer < ReviewableSerializer
end
def include_target_user?
- scope.can_see_reviewable_ui_refresh? && object.target
+ object.target
end
end
diff --git a/app/services/review/calculate_final_status_from_logs.rb b/app/services/review/calculate_final_status_from_logs.rb
deleted file mode 100644
index ea6a3aaad19..00000000000
--- a/app/services/review/calculate_final_status_from_logs.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# frozen_string_literal: true
-
-module Review
- # Calculates the final reviewable status based on action logs from multiple bundles.
- #
- # @example
- # Review::CalculateFinalStatusFromLogs.call(
- # reviewable_id: my_reviewable.id,
- # guardian: guardian,
- # args: {}
- # )
- #
- class CalculateFinalStatusFromLogs
- include Service::Base
-
- # @!method self.call(reviewable_id:, guardian:, args:)
- # @param reviewable_id [Integer] The ID of the reviewable to calculate status for
- # @param guardian [Guardian] The guardian to check permissions for
- # @param args [Hash] Additional arguments for building actions
- # @return [Service::Base::Context]
-
- params do
- attribute :reviewable_id, :integer
- attribute :guardian
- attribute :args, default: -> { {} }
-
- validates :reviewable_id, presence: true
- validates :guardian, presence: true
- end
-
- model :reviewable
- model :reviewable_action_logs
- policy :all_bundles_actioned
-
- step :calculate_status
-
- private
-
- def fetch_reviewable(params:)
- Reviewable.find_by(id: params.reviewable_id)
- end
-
- def fetch_reviewable_action_logs(reviewable:)
- reviewable.reviewable_action_logs.reorder(nil)
- end
-
- def all_bundles_actioned(reviewable:, reviewable_action_logs:, params:)
- actions = reviewable.actions_for(params.guardian, params.args)
-
- current_bundle_types = actions.bundles.map { |b| b.id.split("-", 2).last }
- logged_bundle_types = reviewable_action_logs.select(:bundle).distinct.pluck(:bundle).compact
-
- current_bundle_types.all? { |type| logged_bundle_types.include?(type) }
- end
-
- def calculate_status(reviewable:, reviewable_action_logs:)
- statuses = reviewable_action_logs.select(:status).distinct.pluck(:status).map(&:to_sym)
-
- return context[:status] = :pending if statuses.empty?
-
- return context[:status] = :deleted if statuses.include?(:deleted)
- return context[:status] = :approved if statuses.include?(:approved)
- return context[:status] = :rejected if statuses.include?(:rejected)
- return context[:status] = :ignored if statuses.include?(:ignored)
-
- context[:status] = :pending
- end
- end
-end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 260f8aaadf7..6a9ed2aac5b 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -5865,10 +5865,6 @@ en:
# New separated post actions
post_actions:
bundle_title: "What do you want to do with the post?"
- no_action_post:
- title: "No action"
- description: "Take no action on the post"
- complete: "No action taken on post"
delete_post:
title: "Delete post"
description: "Delete this post"
@@ -5889,17 +5885,8 @@ en:
title: "Edit post"
description: "Edit this post content"
complete: "Post edited"
- convert_to_pm:
- title: "Convert to PM"
- description: "Convert this post to a personal message"
- complete: "Post converted to personal message"
- # New separated user actions
user_actions:
bundle_title: "What do you want to do with the user?"
- no_action_user:
- title: "No action"
- description: "Take no action against the user"
- complete: "No action taken against user"
silence_user:
title: "Silence user"
description: "Prevent the user from posting"
diff --git a/config/site_settings.yml b/config/site_settings.yml
index bafe5ac86e9..401b66d4982 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -4266,16 +4266,6 @@ experimental:
list_type: compact
area: "group_permissions|experimental"
hidden: true
- reviewable_ui_refresh:
- client: true
- type: group_list
- default: ""
- area: "experimental"
- hidden: true
- force_old_reviewable_ui:
- client: true
- default: false
- hidden: true
reviewable_old_moderator_actions:
default: true
hidden: true
diff --git a/db/migrate/20251217030751_deprecate_reviewable_ui_refresh.rb b/db/migrate/20251217030751_deprecate_reviewable_ui_refresh.rb
new file mode 100644
index 00000000000..9ad80b30409
--- /dev/null
+++ b/db/migrate/20251217030751_deprecate_reviewable_ui_refresh.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class DeprecateReviewableUiRefresh < ActiveRecord::Migration[8.0]
+ def up
+ execute "DELETE FROM site_settings WHERE name = 'reviewable_ui_refresh'"
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/db/migrate/20260217064339_remove_force_old_reviewable_ui_site_setting.rb b/db/migrate/20260217064339_remove_force_old_reviewable_ui_site_setting.rb
new file mode 100644
index 00000000000..2801bc51c06
--- /dev/null
+++ b/db/migrate/20260217064339_remove_force_old_reviewable_ui_site_setting.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+class RemoveForceOldReviewableUiSiteSetting < ActiveRecord::Migration[8.0]
+ def up
+ execute "DELETE FROM site_settings WHERE name = 'force_old_reviewable_ui'"
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/db/post_migrate/20260112082200_drop_reviewable_action_logs.rb b/db/post_migrate/20260112082200_drop_reviewable_action_logs.rb
new file mode 100644
index 00000000000..2facb11d52d
--- /dev/null
+++ b/db/post_migrate/20260112082200_drop_reviewable_action_logs.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+class DropReviewableActionLogs < ActiveRecord::Migration[8.0]
+ def up
+ drop_table :reviewable_action_logs
+ end
+
+ def down
+ create_table :reviewable_action_logs do |t|
+ t.bigint :reviewable_id, null: false
+ t.string :action_key, null: false
+ t.integer :status, null: false
+ t.integer :performed_by_id, null: false
+ t.string :bundle, default: "legacy-actions", null: false
+
+ t.timestamps
+ end
+
+ add_index :reviewable_action_logs, :reviewable_id
+ add_index :reviewable_action_logs, :performed_by_id
+ add_index :reviewable_action_logs, :bundle
+ end
+end
diff --git a/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs b/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs
index 8d00086eb03..043910d1732 100644
--- a/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs
+++ b/frontend/discourse/app/components/modal/revise-and-reject-post-reviewable.gjs
@@ -8,7 +8,7 @@ import { isEmpty } from "@ember/utils";
import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal";
import DTextarea from "discourse/components/d-textarea";
-import ReviewableQueuedPost from "discourse/components/reviewable-queued-post";
+import ReviewableQueuedPost from "discourse/components/reviewable/queued-post";
import { popupAjaxError } from "discourse/lib/ajax-error";
import ComboBox from "discourse/select-kit/components/combo-box";
import { i18n } from "discourse-i18n";
diff --git a/frontend/discourse/app/components/review-index-legacy.gjs b/frontend/discourse/app/components/review-index-legacy.gjs
deleted file mode 100644
index 60c94c81fdc..00000000000
--- a/frontend/discourse/app/components/review-index-legacy.gjs
+++ /dev/null
@@ -1,32 +0,0 @@
-import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
-import LoadMore from "discourse/components/load-more";
-import ReviewFilters from "discourse/components/review-filters";
-import ReviewableItem from "discourse/components/reviewable-item";
-import { i18n } from "discourse-i18n";
-
-export default <template>
- <div class="reviewable-container">
- <ReviewFilters @controller={{@controller}} />
- <div class="reviewable-list">
- {{#if @controller.reviewables.content}}
- <LoadMore @action={{@controller.loadMore}}>
- <div class="reviewables">
- {{#each @controller.reviewables.content as |r|}}
- <ReviewableItem
- @reviewable={{r}}
- @remove={{@controller.remove}}
- />
- {{/each}}
- </div>
- </LoadMore>
- <ConditionalLoadingSpinner
- @condition={{@controller.reviewables.loadingMore}}
- />
- {{else}}
- <div class="no-review">
- {{i18n "review.none"}}
- </div>
- {{/if}}
- </div>
- </div>
-</template>
diff --git a/frontend/discourse/app/components/reviewable-claimed-topic.gjs b/frontend/discourse/app/components/reviewable-claimed-topic.gjs
index 81e9055b159..078dbc85767 100644
--- a/frontend/discourse/app/components/reviewable-claimed-topic.gjs
+++ b/frontend/discourse/app/components/reviewable-claimed-topic.gjs
@@ -14,10 +14,6 @@ export default class ReviewableClaimedTopic extends Component {
return this.siteSettings.reviewable_claiming !== "disabled";
}
- get isRefresh() {
- return this.siteSettings.reviewable_ui_refresh;
- }
-
@action
async unclaim() {
try {
@@ -49,23 +45,17 @@ export default class ReviewableClaimedTopic extends Component {
{{#if this.enabled}}
<div class="reviewable-claimed-topic">
{{#if @claimedBy.user}}
-
<DButton
@icon="xmark"
@action={{this.unclaim}}
- @title={{unless this.isRefresh "review.unclaim.help"}}
- @label={{if this.isRefresh "review.unclaim.help"}}
+ @label="review.unclaim.help"
class="btn-default unclaim"
/>
{{else}}
<DButton
@icon="user-plus"
- @title={{if
- this.isRefresh
- "review.claim_help.optional"
- "review.claim.title"
- }}
- @label={{if this.isRefresh "review.claim.title"}}
+ @title="review.claim_help.optional"
+ @label="review.claim.title"
@action={{this.claim}}
class="btn-default claim"
/>
diff --git a/frontend/discourse/app/components/reviewable-item.gjs b/frontend/discourse/app/components/reviewable-item.gjs
deleted file mode 100644
index 5f36682f43f..00000000000
--- a/frontend/discourse/app/components/reviewable-item.gjs
+++ /dev/null
@@ -1,693 +0,0 @@
-/* eslint-disable ember/no-classic-components */
-import { tracked } from "@glimmer/tracking";
-import Component from "@ember/component";
-import { concat, fn } from "@ember/helper";
-import { on } from "@ember/modifier";
-import { action, set } from "@ember/object";
-import { alias } from "@ember/object/computed";
-import { getOwner } from "@ember/owner";
-import { LinkTo } from "@ember/routing";
-import { service } from "@ember/service";
-import { classify, dasherize } from "@ember/string";
-import { htmlSafe } from "@ember/template";
-import { tagName } from "@ember-decorators/component";
-import DButton from "discourse/components/d-button";
-import ExplainReviewableModal from "discourse/components/modal/explain-reviewable";
-import RejectReasonReviewableModal from "discourse/components/modal/reject-reason-reviewable";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import ReviewableBundledAction from "discourse/components/reviewable-bundled-action";
-import ReviewableClaimedTopic from "discourse/components/reviewable-claimed-topic";
-import ReviewableCreatedByName from "discourse/components/reviewable-created-by-name";
-import {
- actionModalClassMap,
- pluginReviewableParams,
-} from "discourse/components/reviewable-refresh/item";
-import ageWithTooltip from "discourse/helpers/age-with-tooltip";
-import avatar from "discourse/helpers/avatar";
-import concatClass from "discourse/helpers/concat-class";
-import icon from "discourse/helpers/d-icon";
-import dasherizeHelper from "discourse/helpers/dasherize";
-import editableValue from "discourse/helpers/editable-value";
-import lazyHash from "discourse/helpers/lazy-hash";
-import reviewableStatus from "discourse/helpers/reviewable-status";
-import { ajax } from "discourse/lib/ajax";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import discourseComputed, { bind } from "discourse/lib/decorators";
-import optionalService from "discourse/lib/optional-service";
-import { optionalRequire } from "discourse/lib/utilities";
-import Category from "discourse/models/category";
-import Composer from "discourse/models/composer";
-import Topic from "discourse/models/topic";
-import { i18n } from "discourse-i18n";
-import ReviewableScores from "./reviewable-scores";
-
-let _components = {};
-
-function lookupComponent(context, name) {
- return getOwner(context).resolveRegistration(`component:${name}`);
-}
-
-@tagName("")
-export default class ReviewableItem extends Component {
- @service dialog;
- @service modal;
- @service siteSettings;
- @service currentUser;
- @service composer;
- @service store;
- @service toasts;
- @optionalService adminTools;
-
- @tracked disabled = false;
-
- @alias("reviewable.claimed_by.automatic") autoClaimed;
-
- updating = null;
- editing = false;
- _updates = null;
-
- constructor() {
- super(...arguments);
- this.messageBus.subscribe("/reviewable_claimed", this._updateClaimedBy);
- this.messageBus.subscribe("/reviewable_action", this._updateStatus);
- }
-
- willDestroy() {
- super.willDestroy(...arguments);
- this.messageBus.unsubscribe("/reviewable_claimed", this._updateClaimedBy);
- this.messageBus.unsubscribe("/reviewable_action", this._updateStatus);
- }
-
- @discourseComputed(
- "reviewable.type",
- "reviewable.last_performing_username",
- "siteSettings.blur_tl0_flagged_posts_media",
- "reviewable.target_created_by_trust_level",
- "reviewable.deleted_at"
- )
- customClasses(
- type,
- lastPerformingUsername,
- blurEnabled,
- trustLevel,
- deletedAt
- ) {
- let classes = dasherize(type);
-
- if (lastPerformingUsername) {
- classes = `${classes} reviewable-stale`;
- }
-
- if (blurEnabled && trustLevel === 0) {
- classes = `${classes} blur-images`;
- }
-
- if (deletedAt) {
- classes = `${classes} reviewable-deleted`;
- }
-
- return classes;
- }
-
- @discourseComputed(
- "reviewable.created_from_flag",
- "reviewable.status",
- "claimOptional",
- "claimRequired",
- "reviewable.claimed_by"
- )
- displayContextQuestion(
- createdFromFlag,
- status,
- claimOptional,
- claimRequired,
- claimedBy
- ) {
- return (
- createdFromFlag &&
- status === 0 &&
- (claimOptional || (claimRequired && claimedBy !== null))
- );
- }
-
- @discourseComputed(
- "reviewable.topic",
- "reviewable.topic_id",
- "reviewable.removed_topic_id"
- )
- topicId(topic, topicId, removedTopicId) {
- return (topic && topic.id) || topicId || removedTopicId;
- }
-
- @discourseComputed(
- "siteSettings.reviewable_claiming",
- "topicId",
- "reviewable.claimed_by.automatic"
- )
- claimEnabled(claimMode, topicId, autoClaimed) {
- return (claimMode !== "disabled" || autoClaimed) && !!topicId;
- }
-
- @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")
- claimOptional(claimMode, claimEnabled) {
- return !claimEnabled || claimMode === "optional";
- }
-
- @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")
- claimRequired(claimMode, claimEnabled) {
- return claimEnabled && claimMode === "required";
- }
-
- @discourseComputed(
- "claimEnabled",
- "siteSettings.reviewable_claiming",
- "reviewable.claimed_by"
- )
- canPerform(claimEnabled, claimMode, claimedBy) {
- if (!claimEnabled) {
- return true;
- }
-
- if (claimedBy) {
- return claimedBy.user.id === this.currentUser.id;
- }
-
- return claimMode !== "required";
- }
-
- @discourseComputed(
- "siteSettings.reviewable_claiming",
- "reviewable.claimed_by"
- )
- claimHelp(claimMode, claimedBy) {
- if (claimedBy) {
- if (claimedBy.user.id === this.currentUser.id) {
- return i18n("review.claim_help.claimed_by_you");
- } else if (claimedBy.automatic) {
- return i18n("review.claim_help.automatically_claimed_by", {
- username: claimedBy.user.username,
- });
- } else {
- return i18n("review.claim_help.claimed_by_other", {
- username: claimedBy.user.username,
- });
- }
- }
-
- return claimMode === "optional"
- ? i18n("review.claim_help.optional")
- : i18n("review.claim_help.required");
- }
-
- // Find a component to render, if one exists. For example:
- // `ReviewableUser` will return `reviewable-user`
- @discourseComputed("reviewable.type")
- reviewableComponent(type) {
- if (_components[type] !== undefined) {
- return _components[type];
- }
-
- const dasherized = dasherize(type);
- const owner = getOwner(this);
- const componentExists =
- owner.hasRegistration(`component:${dasherized}`) ||
- owner.hasRegistration(`template:components/${dasherized}`);
- _components[type] = componentExists ? dasherized : null;
- return _components[type];
- }
-
- @discourseComputed("_updates.category_id", "reviewable.category.id")
- tagCategoryId(updatedCategoryId, categoryId) {
- return updatedCategoryId || categoryId;
- }
-
- @discourseComputed("reviewable.type", "reviewable.target_created_by")
- showIpLookup(reviewableType) {
- return (
- reviewableType !== "ReviewableUser" &&
- this.currentUser.staff &&
- this.reviewable.target_created_by
- );
- }
-
- get IpLookupComponent() {
- return optionalRequire("discourse/admin/components/ip-lookup");
- }
-
- @bind
- _updateClaimedBy(data) {
- const user = data.user ? this.store.createRecord("user", data.user) : null;
-
- if (data.topic_id === this.reviewable.topic.id) {
- if (user) {
- this.reviewable.set("claimed_by", { user, automatic: data.automatic });
- } else {
- this.reviewable.set("claimed_by", null);
- }
- }
- }
-
- @bind
- _updateStatus(data) {
- if (data.remove_reviewable_ids.includes(this.reviewable.id)) {
- delete data.remove_reviewable_ids;
- this._performResult(data, {}, this.reviewable);
- }
- }
-
- @bind
- async _performConfirmed(performableAction, additionalData = {}) {
- let reviewable = this.reviewable;
-
- let performAction = async () => {
- this.disabled = true;
-
- let version = reviewable.get("version");
- this.set("updating", true);
-
- const data = {
- send_email: reviewable.sendEmail,
- reject_reason: reviewable.rejectReason,
- ...additionalData,
- };
-
- (pluginReviewableParams[reviewable.type] || []).forEach((param) => {
- if (reviewable[param]) {
- data[param] = reviewable[param];
- }
- });
-
- return ajax(
- `/review/${reviewable.id}/perform/${performableAction.server_action}?version=${version}`,
- {
- type: "PUT",
- dataType: "json",
- data,
- }
- )
- .then((result) =>
- this._performResult(
- result.reviewable_perform_result,
- performableAction,
- reviewable
- )
- )
- .catch(popupAjaxError)
- .finally(() => {
- this.set("updating", false);
- this.disabled = false;
- });
- };
-
- if (performableAction.client_action) {
- let actionMethod =
- this[`client${classify(performableAction.client_action)}`];
- if (actionMethod) {
- if (await this.#claimReviewable()) {
- await actionMethod.call(this, reviewable, performAction);
- }
- } else {
- // eslint-disable-next-line no-console
- console.error(
- `No handler for ${performableAction.client_action} found`
- );
- }
- } else {
- await performAction();
- }
-
- return this.#unclaimAutomaticReviewable();
- }
-
- _performResult(result, performableAction, reviewable) {
- // "fast track" to update the current user's reviewable count before the message bus finds out.
- if (result.reviewable_count !== undefined) {
- this.currentUser.updateReviewableCount(result.reviewable_count);
- }
-
- if (result.unseen_reviewable_count !== undefined) {
- this.currentUser.set(
- "unseen_reviewable_count",
- result.unseen_reviewable_count
- );
- }
-
- if (performableAction.completed_message) {
- this.toasts.success({
- data: { message: performableAction.completed_message },
- });
- }
-
- if (this.remove && result.remove_reviewable_ids) {
- this.remove(result.remove_reviewable_ids);
- } else {
- return this.store.find("reviewable", reviewable.id);
- }
- }
-
- clientSuspend(reviewable, performAction) {
- return this._penalize("showSuspendModal", reviewable, performAction);
- }
-
- clientSilence(reviewable, performAction) {
- return this._penalize("showSilenceModal", reviewable, performAction);
- }
-
- async clientEdit(reviewable, performAction) {
- if (!this.currentUser) {
- return this.dialog.alert(i18n("post.controls.edit_anonymous"));
- }
- const post = await this.store.find("post", reviewable.post_id);
- const topic_json = await Topic.find(post.topic_id, {});
-
- const topic = Topic.create(topic_json);
- post.set("topic", topic);
-
- if (!post.can_edit) {
- return false;
- }
-
- const opts = {
- post,
- action: Composer.EDIT,
- draftKey: post.get("topic.draft_key"),
- draftSequence: post.get("topic.draft_sequence"),
- skipJumpOnSave: true,
- };
-
- this.composer.open(opts);
-
- return performAction();
- }
-
- _penalize(adminToolMethod, reviewable, performAction) {
- let adminTools = this.adminTools;
- if (adminTools) {
- let createdBy = reviewable.get("target_created_by");
- let postId = reviewable.get("post_id");
- let postEdit = reviewable.get("raw");
-
- return adminTools[adminToolMethod](createdBy, {
- postId,
- postEdit,
- before: performAction,
- });
- }
- }
-
- async #claimReviewable() {
- if (!this.reviewable.topic) {
- // We can't claim a reviewable without a topic, so treat it as claimed
- return true;
- }
-
- if (!this.reviewable.claimed_by) {
- const claim = this.store.createRecord("reviewable-claimed-topic");
-
- try {
- await claim.save({
- topic_id: this.reviewable.topic.id,
- automatic: true,
- });
- this.reviewable.set("claimed_by", {
- user: this.currentUser,
- automatic: true,
- });
- } catch (e) {
- popupAjaxError(e);
- return false;
- }
- }
-
- return this.reviewable.claimed_by?.user?.id === this.currentUser.id;
- }
-
- async #unclaimAutomaticReviewable() {
- if (!this.reviewable.topic || !this.reviewable.claimed_by?.automatic) {
- return;
- }
-
- try {
- await ajax(`/reviewable_claimed_topics/${this.reviewable.topic.id}`, {
- type: "DELETE",
- data: { automatic: true },
- });
- this.reviewable.set("claimed_by", null);
- } catch (e) {
- popupAjaxError(e);
- }
- }
-
- @action
- explainReviewable(reviewable, event) {
- event.preventDefault();
- this.modal.show(ExplainReviewableModal, {
- model: { reviewable },
- });
- }
-
- @action
- edit() {
- this.set("editing", true);
- this.set("_updates", { payload: {} });
- }
-
- @action
- cancelEdit() {
- this.set("editing", false);
- }
-
- @action
- saveEdit() {
- let updates = this._updates;
-
- // Remove empty objects
- Object.keys(updates).forEach((name) => {
- let attr = updates[name];
- if (typeof attr === "object" && Object.keys(attr).length === 0) {
- delete updates[name];
- }
- });
-
- this.set("updating", true);
- return this.reviewable
- .update(updates)
- .then(() => this.set("editing", false))
- .catch(popupAjaxError)
- .finally(() => this.set("updating", false));
- }
-
- @action
- categoryChanged(categoryId) {
- let category = Category.findById(categoryId);
-
- if (!category) {
- category = Category.findUncategorized();
- }
-
- set(this._updates, "category_id", category.id);
- }
-
- @action
- valueChanged(fieldId, event) {
- set(this._updates, fieldId, event.target.value);
- }
-
- @action
- async perform(performableAction) {
- if (this.updating) {
- return;
- }
-
- const message = performableAction.get("confirm_message");
- const requireRejectReason = performableAction.get("require_reject_reason");
- const actionModalClass = requireRejectReason
- ? RejectReasonReviewableModal
- : actionModalClassMap[performableAction.server_action];
-
- if (message) {
- if (await this.#claimReviewable()) {
- this.dialog.confirm({
- message,
- didConfirm: () => this._performConfirmed(performableAction),
- didCancel: () => this.#unclaimAutomaticReviewable(),
- });
- }
- } else if (actionModalClass) {
- if (await this.#claimReviewable()) {
- await this.modal.show(actionModalClass, {
- model: {
- reviewable: this.reviewable,
- performConfirmed: this._performConfirmed,
- action: performableAction,
- },
- });
- await this.#unclaimAutomaticReviewable();
- }
- } else {
- return this._performConfirmed(performableAction);
- }
- }
-
- <template>
- <div
- data-reviewable-id={{this.reviewable.id}}
- class="reviewable-item {{this.customClasses}}"
- >
- <div class="reviewable-meta-data">
- <span
- class={{concatClass
- "reviewable-type"
- this.reviewable.humanTypeCssClass
- }}
- >{{this.reviewable.humanType}}</span>
- {{#if this.reviewable.reply_count}}
- <span class="reply-count">{{i18n
- "review.replies"
- count=this.reviewable.reply_count
- }}</span>
- {{/if}}
- <span class="created-at">
- <LinkTo
- @route="review.show"
- @model={{this.reviewable.id}}
- >{{ageWithTooltip this.reviewable.created_at}}</LinkTo>
- </span>
- <span class="status">
- {{reviewableStatus this.reviewable.status this.reviewable.type}}
- </span>
- <a
- href
- {{on "click" (fn this.explainReviewable this.reviewable)}}
- title={{i18n "review.explain.why"}}
- class="explain"
- >
- {{icon "circle-question"}}
- </a>
- </div>
-
- <div class="reviewable-contents">
- {{#if this.editing}}
- <div class="editable-fields">
- {{#if this.reviewable.created_by}}
- <div class="editable-created-by">
- {{avatar this.reviewable.created_by imageSize="tiny"}}
- <ReviewableCreatedByName @user={{this.reviewable.created_by}} />
- </div>
- {{/if}}
-
- {{#each this.reviewable.editable_fields as |f|}}
- <div class="editable-field {{dasherizeHelper f.id}}">
- {{#let
- (lookupComponent this (concat "reviewable-field-" f.type))
- as |FieldComponent|
- }}
- <FieldComponent
- @value={{editableValue this.reviewable f.id}}
- @tagCategoryId={{this.tagCategoryId}}
- @valueChanged={{fn this.valueChanged f.id}}
- @categoryChanged={{this.categoryChanged}}
- />
- {{/let}}
- </div>
- {{/each}}
- </div>
- {{else}}
- {{#let
- (lookupComponent this this.reviewableComponent)
- as |ReviewableComponent|
- }}
- <ReviewableComponent @reviewable={{this.reviewable}}>
- <ReviewableScores @reviewable={{this.reviewable}} />
- </ReviewableComponent>
- {{/let}}
- {{/if}}
- </div>
-
- {{#if this.displayContextQuestion}}
- <h3 class="reviewable-item__context-question">
- {{this.reviewable.flaggedReviewableContextQuestion}}
- </h3>
- {{else if this.reviewable.userReviewableContextQuestion}}
- <h3 class="reviewable-item__context-question">
- {{this.reviewable.userReviewableContextQuestion}}
- </h3>
- {{/if}}
-
- <div class="reviewable-actions">
- {{#unless this.reviewable.last_performing_username}}
- {{#if this.canPerform}}
- {{#if this.editing}}
- <DButton
- @disabled={{this.disabled}}
- @icon="check"
- @action={{this.saveEdit}}
- @label="review.save"
- class="btn-primary reviewable-action save-edit"
- />
- <DButton
- @disabled={{this.disabled}}
- @icon="xmark"
- @action={{this.cancelEdit}}
- @label="review.cancel"
- class="btn-danger reviewable-action cancel-edit"
- />
- {{else}}
- {{#each this.reviewable.bundled_actions as |bundle|}}
- <ReviewableBundledAction
- @bundle={{bundle}}
- @performAction={{this.perform}}
- @reviewableUpdating={{this.disabled}}
- />
- {{/each}}
-
- {{#if this.reviewable.can_edit}}
- <DButton
- @disabled={{this.disabled}}
- @action={{this.edit}}
- @label="review.edit"
- class="reviewable-action btn-default edit"
- />
- {{/if}}
- {{/if}}
- {{/if}}
- {{/unless}}
-
- {{#if this.reviewable.last_performing_username}}
- <div class="stale-help">{{htmlSafe
- (i18n
- "review.stale_help"
- username=this.reviewable.last_performing_username
- )
- }}</div>
- {{else}}
- {{#if this.claimEnabled}}
- <div class="claimed-actions">
- <span class="help">{{htmlSafe this.claimHelp}}</span>
- {{#unless this.autoClaimed}}
- <ReviewableClaimedTopic
- @topicId={{this.topicId}}
- @claimedBy={{this.reviewable.claimed_by}}
- @onClaim={{fn (mut this.reviewable.claimed_by)}}
- />
- {{/unless}}
- </div>
- {{/if}}
- {{/if}}
-
- {{#if this.showIpLookup}}
- <this.IpLookupComponent
- @ip="adminLookup"
- @userId={{this.reviewable.target_created_by.id}}
- />
- {{/if}}
-
- <PluginOutlet
- @name="reviewable-item-actions"
- @connectorTagName="div"
- @outletArgs={{lazyHash reviewable=this.reviewable}}
- />
- </div>
- </div>
- </template>
-}
diff --git a/frontend/discourse/app/components/reviewable-post.gjs b/frontend/discourse/app/components/reviewable-post.gjs
deleted file mode 100644
index a48f10bd0a5..00000000000
--- a/frontend/discourse/app/components/reviewable-post.gjs
+++ /dev/null
@@ -1,37 +0,0 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import { tagName } from "@ember-decorators/component";
-import ReviewableCreatedBy from "discourse/components/reviewable-created-by";
-import ReviewablePostEdits from "discourse/components/reviewable-post-edits";
-import ReviewablePostHeader from "discourse/components/reviewable-post-header";
-import ReviewableTopicLink from "discourse/components/reviewable-topic-link";
-import highlightWatchedWords from "discourse/lib/highlight-watched-words";
-import { i18n } from "discourse-i18n";
-
-@tagName("")
-export default class ReviewablePost extends Component {
- <template>
- <div class="flagged-post-header">
- <ReviewableTopicLink @reviewable={{this.reviewable}} />
- <ReviewablePostEdits @reviewable={{this.reviewable}} />
- </div>
-
- <div class="post-contents-wrapper">
- <ReviewableCreatedBy @user={{this.reviewable.target_created_by}} />
- <div class="post-contents">
- <ReviewablePostHeader
- @reviewable={{this.reviewable}}
- @createdBy={{this.reviewable.target_created_by}}
- />
- <div class="post-body">
- {{#if this.reviewable.blank_post}}
- <p>{{i18n "review.deleted_post"}}</p>
- {{else}}
- {{highlightWatchedWords this.reviewable.cooked this.reviewable}}
- {{/if}}
- </div>
- {{yield}}
- </div>
- </div>
- </template>
-}
diff --git a/frontend/discourse/app/components/reviewable-refresh/created-by.gjs b/frontend/discourse/app/components/reviewable-refresh/created-by.gjs
index 9463ff72c85..01cd1e65433 100644
--- a/frontend/discourse/app/components/reviewable-refresh/created-by.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/created-by.gjs
@@ -1,32 +1,3 @@
-import ReviewableCreatedByName from "discourse/components/reviewable-created-by-name";
-import UserLink from "discourse/components/user-link";
-import avatar from "discourse/helpers/avatar";
-import icon from "discourse/helpers/d-icon";
-import { i18n } from "discourse-i18n";
+import CreatedBy from "discourse/components/reviewable/created-by";
-/**
- * Displays the creator information for a reviewable item.
- * Shows the user's avatar and name if available, or a deleted user icon if the user no longer exists.
- *
- * @component ReviewableCreatedBy
- *
- * @example
- * ```gjs
- * <ReviewableCreatedBy @user={{this.reviewable.created_by}} />
- * ```
- *
- * @param {User} [user] - The user that created the reviewable item
- */
-<template>
- <div class="created-by">
- {{#if @user}}
- <UserLink @user={{@user}}>{{avatar @user imageSize="small"}}</UserLink>
- <ReviewableCreatedByName @user={{@user}} />
- {{else}}
- <div class="deleted-user">
- {{icon "trash-can" class="deleted-user-avatar"}}
- <span class="deleted-user-name">{{i18n "review.deleted_user"}}</span>
- </div>
- {{/if}}
- </div>
-</template>
+export default CreatedBy;
diff --git a/frontend/discourse/app/components/reviewable-refresh/flagged-post.gjs b/frontend/discourse/app/components/reviewable-refresh/flagged-post.gjs
index 30d39648f1d..17543f8c0d2 100644
--- a/frontend/discourse/app/components/reviewable-refresh/flagged-post.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/flagged-post.gjs
@@ -1,12 +1,3 @@
-import ReviewablePost from "discourse/components/reviewable-refresh/post";
-import { i18n } from "discourse-i18n";
+import FlaggedPost from "discourse/components/reviewable/flagged-post";
-<template>
- <ReviewablePost
- @reviewable={{@reviewable}}
- @userLabel={{i18n "review.flagged_user"}}
- @pluginOutletName="after-reviewable-flagged-post-body"
- >
- {{yield}}
- </ReviewablePost>
-</template>
+export default FlaggedPost;
diff --git a/frontend/discourse/app/components/reviewable-refresh/item.gjs b/frontend/discourse/app/components/reviewable-refresh/item.gjs
index a12ea15bff1..1915366d904 100644
--- a/frontend/discourse/app/components/reviewable-refresh/item.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/item.gjs
@@ -1,914 +1,4 @@
-/* eslint-disable ember/no-classic-components */
-import { tracked } from "@glimmer/tracking";
-import Component from "@ember/component";
-import { concat, fn } from "@ember/helper";
-import { on } from "@ember/modifier";
-import { action, set } from "@ember/object";
-import { alias } from "@ember/object/computed";
-import { getOwner } from "@ember/owner";
-import { service } from "@ember/service";
-import { classify, dasherize } from "@ember/string";
-import { tagName } from "@ember-decorators/component";
-import ScrubRejectedUserModal from "discourse/admin/components/modal/scrub-rejected-user";
-import DButton from "discourse/components/d-button";
-import HorizontalOverflowNav from "discourse/components/horizontal-overflow-nav";
-import ExplainReviewableModal from "discourse/components/modal/explain-reviewable";
-import RejectReasonReviewableModal from "discourse/components/modal/reject-reason-reviewable";
-import ReviseAndRejectPostReviewable from "discourse/components/modal/revise-and-reject-post-reviewable";
-import ReviewableBundledAction from "discourse/components/reviewable-bundled-action";
-import ReviewableClaimedTopic from "discourse/components/reviewable-claimed-topic";
-import ReviewableCreatedBy from "discourse/components/reviewable-created-by";
-import ReviewableFlagReason from "discourse/components/reviewable-refresh/flag-reason";
-import ReviewableHelpResources from "discourse/components/reviewable-refresh/help-resources";
-import ReviewableInsights from "discourse/components/reviewable-refresh/insights";
-import ReviewableTimeline from "discourse/components/reviewable-refresh/timeline";
-import concatClass from "discourse/helpers/concat-class";
-import icon from "discourse/helpers/d-icon";
-import dasherizeHelper from "discourse/helpers/dasherize";
-import editableValue from "discourse/helpers/editable-value";
-import formatDate from "discourse/helpers/format-date";
-import { newReviewableStatus } from "discourse/helpers/reviewable-status";
-import { ajax } from "discourse/lib/ajax";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import discourseComputed, { bind } from "discourse/lib/decorators";
-import { getAbsoluteURL } from "discourse/lib/get-url";
-import optionalService from "discourse/lib/optional-service";
-import { showAlert } from "discourse/lib/post-action-feedback";
-import { clipboardCopy } from "discourse/lib/utilities";
-import Category from "discourse/models/category";
-import Composer from "discourse/models/composer";
-import { PENDING } from "discourse/models/reviewable";
-import Topic from "discourse/models/topic";
-import { eq } from "discourse/truth-helpers";
-import { i18n } from "discourse-i18n";
+export { registerReviewableTypeLabel } from "discourse/components/reviewable/item";
+import Item from "discourse/components/reviewable/item";
-let _components = {};
-
-export const pluginReviewableParams = {};
-const reviewableTypeLabels = {};
-
-// The mappings defined here are default core mappings, and cannot be overridden
-// by plugins.
-const defaultActionModalClassMap = {
- revise_and_reject_post: ReviseAndRejectPostReviewable,
-};
-export const actionModalClassMap = { ...defaultActionModalClassMap };
-
-export function addPluginReviewableParam(reviewableType, param) {
- pluginReviewableParams[reviewableType]
- ? pluginReviewableParams[reviewableType].push(param)
- : (pluginReviewableParams[reviewableType] = [param]);
-}
-
-export function registerReviewableActionModal(actionName, modalClass) {
- if (Object.keys(defaultActionModalClassMap).includes(actionName)) {
- throw new Error(
- `Cannot override default action modal class for ${actionName} (mapped to ${defaultActionModalClassMap[actionName].name})!`
- );
- }
- actionModalClassMap[actionName] = modalClass;
-}
-
-/**
- * Registers a custom label translation key for a reviewable type.
- * Plugins can use this to provide specific labels for their reviewable types.
- *
- * @param {string} reviewableType - The reviewable type class name (e.g., "ReviewableAiPost")
- * @param {string} labelKey - The i18n translation key (e.g., "discourse_ai.review.ai_post_flagged_as")
- *
- * @example
- * import { registerReviewableTypeLabel } from "discourse/components/reviewable-refresh/item";
- * registerReviewableTypeLabel("ReviewableAiPost", "discourse_ai.review.ai_post_flagged_as");
- */
-export function registerReviewableTypeLabel(reviewableType, labelKey) {
- reviewableTypeLabels[reviewableType] = labelKey;
-}
-
-function lookupComponent(context, name) {
- return getOwner(context).resolveRegistration(`component:${name}`);
-}
-
-@tagName("")
-export default class ReviewableItem extends Component {
- @service dialog;
- @service modal;
- @service siteSettings;
- @service currentUser;
- @service composer;
- @service store;
- @service toasts;
- @service messageBus;
- @optionalService adminTools;
-
- @tracked disabled = false;
- @tracked activeTab = "timeline";
-
- @alias("reviewable.claimed_by.automatic") autoClaimed;
-
- updating = null;
- editing = false;
- _updates = null;
-
- constructor() {
- super(...arguments);
- this.messageBus.subscribe("/reviewable_claimed", this._updateClaimedBy);
- this.messageBus.subscribe("/reviewable_action", this._updateStatus);
- }
-
- willDestroy() {
- super.willDestroy(...arguments);
- this.messageBus.unsubscribe("/reviewable_claimed", this._updateClaimedBy);
- this.messageBus.unsubscribe("/reviewable_action", this._updateStatus);
- }
-
- @discourseComputed(
- "reviewable.type",
- "reviewable.last_performing_username",
- "siteSettings.blur_tl0_flagged_posts_media",
- "reviewable.target_created_by_trust_level",
- "reviewable.deleted_at"
- )
- customClasses(
- type,
- lastPerformingUsername,
- blurEnabled,
- trustLevel,
- deletedAt
- ) {
- let classes = dasherize(type);
-
- if (lastPerformingUsername) {
- classes = `${classes} reviewable-stale`;
- }
-
- if (blurEnabled && trustLevel === 0) {
- classes = `${classes} blur-images`;
- }
-
- if (deletedAt) {
- classes = `${classes} reviewable-deleted`;
- }
-
- return classes;
- }
-
- @discourseComputed(
- "reviewable.created_from_flag",
- "reviewable.status",
- "claimOptional",
- "claimRequired",
- "reviewable.claimed_by",
- "siteSettings.reviewable_old_moderator_actions",
- "isAiReviewable"
- )
- displayContextQuestion(
- createdFromFlag,
- status,
- claimOptional,
- claimRequired,
- claimedBy,
- oldModeratorActions,
- isAiReviewable
- ) {
- return (
- (oldModeratorActions &&
- createdFromFlag &&
- status === PENDING &&
- (claimOptional || (claimRequired && claimedBy !== null))) ||
- isAiReviewable
- );
- }
-
- @discourseComputed("reviewable.type")
- isAiReviewable(type) {
- return type === "ReviewableAiChatMessage" || type === "ReviewableAiPost";
- }
-
- @discourseComputed(
- "reviewable.topic",
- "reviewable.topic_id",
- "reviewable.removed_topic_id"
- )
- topicId(topic, topicId, removedTopicId) {
- return (topic && topic.id) || topicId || removedTopicId;
- }
-
- @discourseComputed(
- "siteSettings.reviewable_claiming",
- "topicId",
- "reviewable.claimed_by.automatic",
- "reviewable.status"
- )
- claimEnabled(claimMode, topicId, autoClaimed, status) {
- return (
- (claimMode !== "disabled" || autoClaimed) && !!topicId && status === 0
- );
- }
-
- @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")
- claimOptional(claimMode, claimEnabled) {
- return !claimEnabled || claimMode === "optional";
- }
-
- @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")
- claimRequired(claimMode, claimEnabled) {
- return claimEnabled && claimMode === "required";
- }
-
- @discourseComputed(
- "claimEnabled",
- "siteSettings.reviewable_claiming",
- "reviewable.claimed_by",
- "reviewable.bundled_actions"
- )
- canPerform(claimEnabled, claimMode, claimedBy, bundledActions) {
- if (bundledActions?.length === 0) {
- return false;
- }
- if (!claimEnabled) {
- return true;
- }
-
- if (claimedBy) {
- return claimedBy.user.id === this.currentUser.id;
- }
-
- return claimMode !== "required";
- }
-
- @discourseComputed(
- "siteSettings.reviewable_claiming",
- "reviewable.claimed_by"
- )
- claimHelp(claimMode, claimedBy) {
- if (claimedBy) {
- if (claimedBy.user.id === this.currentUser.id) {
- return i18n("review.claim_help.claimed_by_you");
- } else if (claimedBy.automatic) {
- return i18n("review.claim_help.automatically_claimed_by", {
- username: claimedBy.user.username,
- });
- } else {
- return i18n("review.claim_help.claimed_by_other", {
- username: claimedBy.user.username,
- });
- }
- }
-
- return claimMode === "optional"
- ? i18n("review.claim_help.optional")
- : i18n("review.claim_help.required");
- }
-
- // Find a component to render, if one exists. For example:
- // `ReviewableUser` will return `reviewable/user` or `reviewable-user`.
- // The former is the new reviewable component, so will only be returned if it exists.
- @discourseComputed("reviewable.type")
- reviewableComponent(type) {
- if (_components[type] !== undefined) {
- return _components[type];
- }
-
- const owner = getOwner(this);
- const dasherized = dasherize(type);
- const componentNames = [
- dasherized.replace("reviewable-", "reviewable-refresh/"),
- dasherized,
- ];
-
- for (const componentName of componentNames) {
- const componentExists =
- owner.hasRegistration(`component:${componentName}`) ||
- owner.hasRegistration(`template:components/${componentName}`);
- if (componentExists) {
- _components[type] = componentName;
- break;
- }
- }
- return _components[type] || null;
- }
-
- @discourseComputed("_updates.category_id", "reviewable.category.id")
- tagCategoryId(updatedCategoryId, categoryId) {
- return updatedCategoryId || categoryId;
- }
-
- @discourseComputed("reviewable.reviewable_scores")
- scoreSummary(scores) {
- const scoreData = scores.reduce((acc, score) => {
- if (!acc[score.score_type.type]) {
- acc[score.score_type.type] = {
- title: score.score_type.title,
- type: score.score_type.type,
- count: 0,
- };
- }
-
- acc[score.score_type.type].count += 1;
- return acc;
- }, {});
-
- return Object.values(scoreData);
- }
-
- @discourseComputed(
- "reviewable.type",
- "reviewable.created_from_flag",
- "topicId"
- )
- reviewableTypeLabel(type, createdFromFlag, topicId) {
- // handle plugin types
- if (reviewableTypeLabels[type]) {
- return reviewableTypeLabels[type];
- }
-
- // core types
- if (type === "ReviewableUser") {
- return "review.user_label";
- }
-
- if (type === "ReviewableQueuedPost") {
- // if topic_id is null it's a new topic
- return topicId ? "review.queued_post_label" : "review.queued_topic_label";
- }
-
- if (type === "ReviewableChatMessage") {
- return "review.chat_flagged_as";
- }
-
- if (createdFromFlag) {
- return "review.post_flagged_as";
- }
-
- // fallback
- return "review.flagged_as";
- }
-
- @bind
- _updateClaimedBy(data) {
- if (data.topic_id !== this.reviewable.topic.id) {
- return;
- }
-
- const now = new Date().toISOString();
-
- const user = this.store.createRecord("user", data.user);
- if (data.claimed) {
- this.reviewable.set("claimed_by", { user, automatic: data.automatic });
- this.reviewable.set("reviewable_histories", [
- ...this.reviewable.reviewable_histories,
- {
- reviewable_history_type: 3,
- created_at: now,
- created_by: user,
- },
- ]);
- } else {
- this.reviewable.set("claimed_by", null);
- this.reviewable.set("reviewable_histories", [
- ...this.reviewable.reviewable_histories,
- {
- reviewable_history_type: 4,
- created_at: now,
- created_by: user,
- },
- ]);
- }
- }
-
- @bind
- _updateStatus(data) {
- if (data.remove_reviewable_ids?.includes(this.reviewable.id)) {
- delete data.remove_reviewable_ids;
- this._performResult(data, {}, this.reviewable);
- }
- }
-
- @bind
- async _performConfirmed(performableAction, additionalData = {}) {
- let reviewable = this.reviewable;
-
- let performAction = async () => {
- this.disabled = true;
-
- let version = reviewable.get("version");
- this.set("updating", true);
-
- const data = {
- send_email: reviewable.sendEmail,
- reject_reason: reviewable.rejectReason,
- ...additionalData,
- };
-
- (pluginReviewableParams[reviewable.type] || []).forEach((param) => {
- if (reviewable[param]) {
- data[param] = reviewable[param];
- }
- });
-
- return ajax(
- `/review/${reviewable.id}/perform/${performableAction.server_action}?version=${version}`,
- {
- type: "PUT",
- dataType: "json",
- data,
- }
- )
- .then((result) =>
- this._performResult(
- result.reviewable_perform_result,
- performableAction,
- reviewable
- )
- )
- .catch(popupAjaxError)
- .finally(() => {
- this.set("updating", false);
- this.disabled = false;
- });
- };
-
- if (performableAction.client_action) {
- let actionMethod =
- this[`client${classify(performableAction.client_action)}`];
- if (actionMethod) {
- if (await this.#claimReviewable()) {
- await actionMethod.call(this, reviewable, performAction);
- }
- } else {
- // eslint-disable-next-line no-console
- console.error(
- `No handler for ${performableAction.client_action} found`
- );
- }
- } else {
- await performAction();
- }
-
- return this.#unclaimAutomaticReviewable();
- }
-
- _performResult(result, performableAction, reviewable) {
- // "fast track" to update the current user's reviewable count before the message bus finds out.
- if (result.reviewable_count !== undefined) {
- this.currentUser.updateReviewableCount(result.reviewable_count);
- }
-
- if (result.unseen_reviewable_count !== undefined) {
- this.currentUser.set(
- "unseen_reviewable_count",
- result.unseen_reviewable_count
- );
- }
-
- if (performableAction.completed_message) {
- this.toasts.success({
- data: { message: performableAction.completed_message },
- });
- }
-
- if (this.remove && result.remove_reviewable_ids?.length > 0) {
- this.remove(result.remove_reviewable_ids);
- } else {
- return this.store.find("reviewable", reviewable.id);
- }
- }
-
- @action
- clientScrub() {
- this.modal.show(ScrubRejectedUserModal, {
- model: {
- confirmScrub: this.scrubRejectedUser,
- },
- });
- }
-
- @bind
- async scrubRejectedUser(reason) {
- try {
- await ajax({
- url: `/review/${this.reviewable.id}/scrub`,
- type: "PUT",
- data: { reason },
- });
- this.store.find("reviewable", this.reviewable.id);
- } catch (e) {
- popupAjaxError(e);
- }
- }
-
- clientSuspend(reviewable, performAction) {
- return this._penalize("showSuspendModal", reviewable, performAction);
- }
-
- clientSilence(reviewable, performAction) {
- return this._penalize("showSilenceModal", reviewable, performAction);
- }
-
- async clientEdit(reviewable, performAction) {
- if (!this.currentUser) {
- return this.dialog.alert(i18n("post.controls.edit_anonymous"));
- }
- const post = await this.store.find("post", reviewable.post_id);
- const topic_json = await Topic.find(post.topic_id, {});
-
- const topic = Topic.create(topic_json);
- post.set("topic", topic);
-
- if (!post.can_edit) {
- return false;
- }
-
- const opts = {
- post,
- action: Composer.EDIT,
- draftKey: post.get("topic.draft_key"),
- draftSequence: post.get("topic.draft_sequence"),
- skipJumpOnSave: true,
- };
-
- this.composer.open(opts);
-
- return performAction();
- }
-
- _penalize(adminToolMethod, reviewable, performAction) {
- let adminTools = this.adminTools;
- if (adminTools) {
- let createdBy = reviewable.get("target_created_by");
- let postId = reviewable.get("post_id");
- let postEdit = reviewable.get("raw");
-
- return adminTools[adminToolMethod](createdBy, {
- postId,
- postEdit,
- before: performAction,
- });
- }
- }
-
- async #claimReviewable() {
- if (!this.reviewable.topic) {
- // We can't claim a reviewable without a topic, so treat it as claimed
- return true;
- }
-
- if (!this.reviewable.claimed_by) {
- const claim = this.store.createRecord("reviewable-claimed-topic");
-
- try {
- await claim.save({
- topic_id: this.reviewable.topic.id,
- automatic: true,
- });
- this.reviewable.set("claimed_by", {
- user: this.currentUser,
- automatic: true,
- });
- } catch (e) {
- popupAjaxError(e);
- return false;
- }
- }
-
- return this.reviewable.claimed_by?.user?.id === this.currentUser.id;
- }
-
- async #unclaimAutomaticReviewable() {
- if (!this.reviewable.topic || !this.reviewable.claimed_by?.automatic) {
- return;
- }
-
- try {
- await ajax(`/reviewable_claimed_topics/${this.reviewable.topic.id}`, {
- type: "DELETE",
- data: { automatic: true },
- });
- this.reviewable.set("claimed_by", null);
- } catch (e) {
- popupAjaxError(e);
- }
- }
-
- @action
- explainReviewable(reviewable, event) {
- event.preventDefault();
- this.modal.show(ExplainReviewableModal, {
- model: { reviewable },
- });
- }
-
- @action
- switchTab(tabName, event) {
- event.preventDefault();
- this.activeTab = tabName;
- }
-
- @action
- edit() {
- this.set("editing", true);
- this.set("_updates", { payload: {} });
- }
-
- @action
- cancelEdit() {
- this.set("editing", false);
- }
-
- @action
- saveEdit() {
- let updates = this._updates;
-
- // Remove empty objects
- Object.keys(updates).forEach((name) => {
- let attr = updates[name];
- if (typeof attr === "object" && Object.keys(attr).length === 0) {
- delete updates[name];
- }
- });
-
- this.set("updating", true);
- return this.reviewable
- .update(updates)
- .then(() => this.set("editing", false))
- .catch(popupAjaxError)
- .finally(() => this.set("updating", false));
- }
-
- @action
- categoryChanged(categoryId) {
- let category = Category.findById(categoryId);
-
- if (!category) {
- category = Category.findUncategorized();
- }
-
- set(this._updates, "category_id", category.id);
- }
-
- @action
- valueChanged(fieldId, event) {
- set(this._updates, fieldId, event.target.value);
- }
-
- @action
- async perform(performableAction) {
- if (this.updating) {
- return;
- }
-
- const message = performableAction.get("confirm_message");
- const requireRejectReason = performableAction.get("require_reject_reason");
- const actionModalClass = requireRejectReason
- ? RejectReasonReviewableModal
- : actionModalClassMap[performableAction.server_action];
-
- if (message) {
- if (await this.#claimReviewable()) {
- this.dialog.confirm({
- message,
- didConfirm: () => this._performConfirmed(performableAction),
- });
- }
- } else if (actionModalClass) {
- if (await this.#claimReviewable()) {
- this.modal.show(actionModalClass, {
- model: {
- reviewable: this.reviewable,
- performConfirmed: this._performConfirmed,
- action: performableAction,
- },
- });
- }
- } else {
- return this._performConfirmed(performableAction);
- }
- }
-
- get permalink() {
- return getAbsoluteURL(`/review/${this.reviewable.id}`);
- }
-
- @action
- async copyPermalink(event) {
- const button = event.currentTarget;
-
- // cmd/ctrl+click or middle-click to open in new tab
- if (event.metaKey || event.ctrlKey || event.button === 1) {
- window.open(this.permalink, "_blank");
- return;
- }
-
- try {
- await clipboardCopy(this.permalink);
- showAlert(
- this.reviewable.id,
- "reviewable-permalink-copy",
- "review.copy_link_feedback",
- { actionBtn: button }
- );
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error("Failed to copy to clipboard:", error);
- }
- }
-
- <template>
- <div class="review-container">
-
- <div
- data-reviewable-id={{this.reviewable.id}}
- class="review-item {{this.customClasses}}"
- >
- <div class="review-item__primary-content">
- <div class="review-item__flag-summary">
- <div class="review-item__header">
- <div class="review-item__label-badges">
- <span class="review-item__flag-label">{{i18n
- this.reviewableTypeLabel
- }}</span>
-
- <div class="review-item__flag-badges">
- {{#each this.scoreSummary as |score|}}
- <ReviewableFlagReason @score={{score}} />
- {{/each}}
- </div>
- </div>
-
- <button
- type="button"
- {{on "click" this.copyPermalink}}
- title={{i18n "review.copy_permalink_title"}}
- class="btn btn-transparent reviewable-permalink-copy"
- >
- {{icon "d-post-share"}}
- </button>
-
- {{newReviewableStatus
- this.reviewable.status
- this.reviewable.type
- }}
-
- <span class="reviewable-created-date">
- {{formatDate this.reviewable.created_at format="tiny"}}
- </span>
-
- </div>
- {{#if this.editing}}
- <div class="editable-fields">
- {{#each this.reviewable.editable_fields as |f|}}
- <div class="editable-field {{dasherizeHelper f.id}}">
- {{#let
- (lookupComponent this (concat "reviewable-field-" f.type))
- as |FieldComponent|
- }}
- <FieldComponent
- @value={{editableValue this.reviewable f.id}}
- @tagCategoryId={{this.tagCategoryId}}
- @valueChanged={{fn this.valueChanged f.id}}
- @categoryChanged={{this.categoryChanged}}
- />
- {{/let}}
- </div>
- {{/each}}
- </div>
- {{else}}
-
- {{#let
- (lookupComponent this this.reviewableComponent)
- as |ReviewableComponent|
- }}
- <ReviewableComponent @reviewable={{this.reviewable}} />
- {{/let}}
- {{/if}}
- </div>
-
- <div class="review-item__insights">
- <div class="d-nav-submenu">
- <HorizontalOverflowNav
- @ariaLabel="Review tabs"
- class="d-nav-submenu__tabs"
- >
- <li
- class={{concatClass
- "timeline"
- (if (eq this.activeTab "timeline") "active")
- }}
- >
- <a
- href="#"
- class={{if (eq this.activeTab "timeline") "active"}}
- {{on "click" (fn this.switchTab "timeline")}}
- >
- {{i18n "review.timeline_and_notes"}}
- </a>
- </li>
- <li
- class={{concatClass
- "insights"
- (if (eq this.activeTab "insights") "active")
- }}
- >
- <a
- href="#"
- class={{if (eq this.activeTab "insights") "active"}}
- {{on "click" (fn this.switchTab "insights")}}
- >
- {{i18n "review.insights.title"}}
- </a>
- </li>
- </HorizontalOverflowNav>
- </div>
-
- {{#if (eq this.activeTab "insights")}}
- <ReviewableInsights @reviewable={{this.reviewable}} />
- {{else if (eq this.activeTab "timeline")}}
- <ReviewableTimeline
- @reviewable={{this.reviewable}}
- @historyEvents={{this.reviewable.reviewable_histories}}
- />
- {{/if}}
- </div>
- </div>
-
- <div class="review-item__aside">
-
- {{#unless this.reviewable.last_performing_username}}
- {{#if this.canPerform}}
- <div class="review-item__moderator-actions">
- <h3 class="review-item__aside-title">
- {{#if this.editing}}
- {{i18n "review.editing_post"}}
- {{else if this.displayContextQuestion}}
- {{this.reviewable.flaggedReviewableContextQuestion}}
- {{else if this.reviewable.userReviewableContextQuestion}}
- {{this.reviewable.userReviewableContextQuestion}}
- {{else}}
- {{i18n "review.moderator_actions"}}
- {{/if}}
- </h3>
- {{#if this.editing}}
- <DButton
- @disabled={{this.disabled}}
- @icon="check"
- @action={{this.saveEdit}}
- @label="review.save"
- class="btn-primary reviewable-action save-edit"
- />
- <DButton
- @disabled={{this.disabled}}
- @icon="xmark"
- @action={{this.cancelEdit}}
- @label="review.cancel"
- class="btn-danger reviewable-action cancel-edit"
- />
- {{else}}
- {{#each this.reviewable.bundled_actions as |bundle|}}
- <ReviewableBundledAction
- @bundle={{bundle}}
- @performAction={{this.perform}}
- @reviewableUpdating={{this.disabled}}
- />
- {{/each}}
-
- {{#if this.reviewable.can_edit}}
- <DButton
- @disabled={{this.disabled}}
- @action={{this.edit}}
- @label="review.edit"
- class="reviewable-action btn-default edit"
- />
- {{/if}}
- {{/if}}
- </div>
- {{/if}}
- {{/unless}}
-
- {{#if this.claimEnabled}}
- <div class="review-item__moderator-actions --extra">
- {{#if this.reviewable.claimed_by}}
- <div class="review-item__assigned">
- {{icon "user-plus"}}
- <ReviewableCreatedBy
- @showUsername={{true}}
- @avatarSize="small"
- @user={{this.reviewable.claimed_by.user}}
- />
- </div>
- {{/if}}
- <ReviewableClaimedTopic
- @topicId={{this.topicId}}
- @claimedBy={{this.reviewable.claimed_by}}
- @onClaim={{fn (mut this.reviewable.claimed_by)}}
- />
- </div>
- {{/if}}
-
- {{#if @showHelp}}
- <ReviewableHelpResources />
- {{/if}}
- </div>
- </div>
- </div>
- </template>
-}
+export default Item;
diff --git a/frontend/discourse/app/components/reviewable-refresh/post.gjs b/frontend/discourse/app/components/reviewable-refresh/post.gjs
index 2788e4f836e..f682c1e8414 100644
--- a/frontend/discourse/app/components/reviewable-refresh/post.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/post.gjs
@@ -1,94 +1,3 @@
-import Component from "@glimmer/component";
-import { htmlSafe } from "@ember/template";
-import DecoratedHtml, {
- applyHtmlDecorators,
-} from "discourse/components/decorated-html";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import ReviewablePostEdits from "discourse/components/reviewable-post-edits";
-import ReviewableCreatedBy from "discourse/components/reviewable-refresh/created-by";
-import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";
-import lazyHash from "discourse/helpers/lazy-hash";
-import { bind } from "discourse/lib/decorators";
-import highlightHTML from "discourse/lib/highlight-html";
-import { i18n } from "discourse-i18n";
+import Post from "discourse/components/reviewable/post";
-export default class ReviewablePost extends Component {
- get metaLabel() {
- return this.args.metaLabel || i18n("review.posted_in");
- }
-
- get userLabel() {
- return this.args.userLabel || i18n("review.review_user");
- }
-
- get pluginOutletName() {
- return this.args.pluginOutletName || "after-reviewable-post-body";
- }
-
- @bind
- decorate(element, helper) {
- const reviewable = this.args.reviewable;
- if (reviewable?.reviewable_scores) {
- const words = reviewable.reviewable_scores
- .map((rs) => {
- return rs.reason_type === "watched_word" ? rs.reason_data : [];
- })
- .flat();
-
- if (words.length > 0) {
- words.forEach((word) => {
- highlightHTML(element, word, {
- nodeName: "mark",
- className: "watched-word-highlight",
- });
- });
- }
- }
-
- applyHtmlDecorators(element, helper);
- }
-
- <template>
- <div class="review-item__meta-content">
- <div class="review-item__meta-label">{{this.metaLabel}}</div>
-
- <div class="review-item__meta-topic-title">
- <ReviewableTopicLink @reviewable={{@reviewable}} />
- <ReviewablePostEdits @reviewable={{@reviewable}} />
- </div>
-
- <div class="review-item__meta-label">{{this.userLabel}}</div>
-
- <div class="review-item__meta-flagged-user">
- <ReviewableCreatedBy @user={{@reviewable.target_created_by}} />
- </div>
- </div>
-
- <div class="review-item__post">
- <div class="review-item__post-content-wrapper">
- {{#if @reviewable.blank_post}}
- <div class="review-item__post-content">
- <p>{{i18n "review.deleted_post"}}</p>
- </div>
- {{else}}
- <DecoratedHtml
- @className="review-item__post-content"
- @html={{htmlSafe @reviewable.cooked}}
- @decorate={{this.decorate}}
- @model={{@reviewable}}
- />
- {{/if}}
-
- <span>
- <PluginOutlet
- @name={{this.pluginOutletName}}
- @connectorTagName="div"
- @outletArgs={{lazyHash model=@reviewable}}
- />
- </span>
-
- {{yield}}
- </div>
- </div>
- </template>
-}
+export default Post;
diff --git a/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs b/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs
index fefae1bcd03..34636d5c400 100644
--- a/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/queued-post.gjs
@@ -1,80 +1,2 @@
-import Component from "@glimmer/component";
-import { hash } from "@ember/helper";
-import { on } from "@ember/modifier";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import CookText from "discourse/components/cook-text";
-import RawEmailModal from "discourse/components/modal/raw-email";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import ReviewableCreatedBy from "discourse/components/reviewable-refresh/created-by";
-import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";
-import ReviewableTags from "discourse/components/reviewable-tags";
-import categoryBadge from "discourse/helpers/category-badge";
-import icon from "discourse/helpers/d-icon";
-import lazyHash from "discourse/helpers/lazy-hash";
-import highlightWatchedWords from "discourse/lib/highlight-watched-words";
-import { i18n } from "discourse-i18n";
-
-export default class ReviewableQueuedPost extends Component {
- @service modal;
-
- @action
- showRawEmail(event) {
- event?.preventDefault();
- this.modal.show(RawEmailModal, {
- model: {
- rawEmail: this.args.reviewable.payload.raw_email,
- },
- });
- }
-
- <template>
- <div class="review-item__meta-content">
- <div class="review-item__meta-label">{{i18n "review.topic_label"}}</div>
-
- <div class="review-item__meta-topic-title">
- <ReviewableTopicLink @reviewable={{@reviewable}}>
- <div class="title-text">
- {{highlightWatchedWords @reviewable.payload.title @reviewable}}
- </div>
- {{categoryBadge @reviewable.category}}
- <ReviewableTags @tags={{@reviewable.payload.tags}} />
- {{#if @reviewable.payload.via_email}}
- <a href {{on "click" this.showRawEmail}} class="show-raw-email">
- {{icon "envelope" title="post.via_email"}}
- </a>
- {{/if}}
- </ReviewableTopicLink>
- </div>
-
- <div class="review-item__meta-label">{{i18n "review.review_user"}}</div>
-
- <div class="review-item__meta-flagged-user">
- <ReviewableCreatedBy @user={{@reviewable.target_created_by}} />
- </div>
- </div>
-
- <div class="review-item__post">
- <div class="review-item__post-content">
- <CookText
- class="post-body"
- @rawText={{highlightWatchedWords @reviewable.payload.raw @reviewable}}
- @categoryId={{@reviewable.category_id}}
- @topicId={{@reviewable.topic_id}}
- @paintOneboxes={{false}}
- @opts={{hash removeMissing=true}}
- />
-
- <span>
- <PluginOutlet
- @name="after-reviewable-queued-post-body"
- @connectorTagName="div"
- @outletArgs={{lazyHash model=@reviewable}}
- />
- </span>
-
- {{yield}}
- </div>
- </div>
- </template>
-}
+export default QueuedPost;
+import QueuedPost from "discourse/components/reviewable/queued-post";
diff --git a/frontend/discourse/app/components/reviewable-refresh/topic-link.gjs b/frontend/discourse/app/components/reviewable-refresh/topic-link.gjs
index 7aaa418bbe7..1592ecaa309 100644
--- a/frontend/discourse/app/components/reviewable-refresh/topic-link.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/topic-link.gjs
@@ -1,73 +1,3 @@
-import { array } from "@ember/helper";
-import { LinkTo } from "@ember/routing";
-import ReviewableTags from "discourse/components/reviewable-tags";
-import TopicStatus from "discourse/components/topic-status";
-import categoryBadge from "discourse/helpers/category-badge";
-import highlightWatchedWords from "discourse/lib/highlight-watched-words";
-import { i18n } from "discourse-i18n";
+import TopicLink from "discourse/components/reviewable/topic-link";
-/**
- * Displays topic information for reviewable items.
- * Shows the topic title, status, category badge, and tags if the topic exists.
- * For deleted topics, displays a link to the original topic. Supports block content as fallback.
- *
- * @component ReviewableTopicLink
- *
- * @example
- * ```gjs
- * <ReviewableTopicLink @reviewable={{this.reviewable}} />
- *
- * <!-- With block content for custom fallback -->
- * <ReviewableTopicLink @reviewable={{this.reviewable}}>
- * <span>Custom content when topic is missing</span>
- * </ReviewableTopicLink>
- * ```
- *
- * @param {Reviewable} reviewable - The reviewable object containing topic information
- */
-<template>
- <div class="reviewable-topic-link">
- {{#if @reviewable.topic}}
- <div class="reviewable-topic-link__title-wrapper">
- <div class="reviewable-topic-link__title-status">
- <TopicStatus
- @topic={{@reviewable.topic}}
- @showPrivateMessageIcon={{true}}
- />
- </div>
-
- <div class="reviewable-topic-link__title-link">
- <a
- href={{@reviewable.target_url}}
- class="title-text"
- >{{highlightWatchedWords
- @reviewable.topic.fancyTitle
- @reviewable
- }}</a>
- </div>
- </div>
-
- <div class="reviewable-topic-link__details">
- {{#if @reviewable.category}}
- <div class="reviewable-topic-link__details-category-badge">
- {{categoryBadge @reviewable.category}}
- </div>
- {{/if}}
-
- <div class="reviewable-topic-link__details-tags">
- <ReviewableTags @tags={{@reviewable.topic_tags}} />
- </div>
- </div>
- {{else if @reviewable.removed_topic_id}}
- <span class="title-text">
- {{i18n "review.topics.deleted"}}
- <LinkTo
- @route="topic"
- @models={{array "-" @reviewable.removed_topic_id}}
- >{{i18n "review.topics.original"}}</LinkTo>
- </span>
- {{else if (has-block)}}
- {{yield}}
- {{/if}}
- </div>
-</template>
+export default TopicLink;
diff --git a/frontend/discourse/app/components/reviewable-refresh/user.gjs b/frontend/discourse/app/components/reviewable-refresh/user.gjs
index f2bb1af196e..9a303959943 100644
--- a/frontend/discourse/app/components/reviewable-refresh/user.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/user.gjs
@@ -1,15 +1,3 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import { tagName } from "@ember-decorators/component";
-import LegacyReviewableUser from "../reviewable-user";
+import User from "discourse/components/reviewable/user";
-@tagName("")
-export default class ReviewableUser extends Component {
- <template>
- <div class="review-item__meta-content" ...attributes>
- <LegacyReviewableUser @reviewable={{@reviewable}}>
- {{yield}}
- </LegacyReviewableUser>
- </div>
- </template>
-}
+export default User;
diff --git a/frontend/discourse/app/components/reviewable-user.gjs b/frontend/discourse/app/components/reviewable-user.gjs
deleted file mode 100644
index 3c44c7a32b8..00000000000
--- a/frontend/discourse/app/components/reviewable-user.gjs
+++ /dev/null
@@ -1,177 +0,0 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import { concat } from "@ember/helper";
-import { on } from "@ember/modifier";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import { tagName } from "@ember-decorators/component";
-import ScrubRejectedUserModal from "discourse/admin/components/modal/scrub-rejected-user";
-import ReviewableField from "discourse/components/reviewable-field";
-import rawDate from "discourse/helpers/raw-date";
-import { ajax } from "discourse/lib/ajax";
-import { popupAjaxError } from "discourse/lib/ajax-error";
-import discourseComputed, { bind } from "discourse/lib/decorators";
-import getUrl from "discourse/lib/get-url";
-import { REJECTED } from "discourse/models/reviewable";
-import { i18n } from "discourse-i18n";
-
-@tagName("")
-export default class ReviewableUser extends Component {
- @service currentUser;
- @service modal;
- @service store;
-
- @discourseComputed("reviewable.user_fields")
- userFields(fields) {
- return this.site.collectUserFields(fields);
- }
-
- @discourseComputed("reviewable.status", "currentUser", "isScrubbed")
- canScrubRejectedUser(status, currentUser, isScrubbed) {
- return (
- status === REJECTED &&
- currentUser.admin &&
- !isScrubbed &&
- !currentUser.use_reviewable_ui_refresh
- );
- }
-
- @discourseComputed("reviewable.payload")
- isScrubbed(payload) {
- return !!payload?.scrubbed_by;
- }
-
- @action
- showScrubRejectedUserModal() {
- this.modal.show(ScrubRejectedUserModal, {
- model: {
- confirmScrub: this.scrubRejectedUser,
- },
- });
- }
-
- @bind
- async scrubRejectedUser(reason) {
- try {
- await ajax({
- url: `/review/${this.reviewable.id}/scrub`,
- type: "PUT",
- data: { reason },
- });
- this.store.find("reviewable", this.reviewable.id);
- } catch (e) {
- popupAjaxError(e);
- }
- }
-
- <template>
- <div class="reviewable-user-info">
- <div class="reviewable-user-fields">
- {{#if this.isScrubbed}}
- <ReviewableField
- @classes="reviewable-user-details reject-reason"
- @name={{i18n "review.user.scrubbed_reject_reason"}}
- @value={{this.reviewable.reject_reason}}
- />
-
- <ReviewableField
- @classes="reviewable-user-details scrubbed-by"
- @name={{i18n "review.user.scrubbed_by"}}
- @value={{this.reviewable.payload.scrubbed_by}}
- />
-
- <ReviewableField
- @classes="reviewable-user-details scrubbed-reason"
- @name={{i18n "review.user.scrubbed_reason"}}
- @value={{this.reviewable.payload.scrubbed_reason}}
- />
-
- <ReviewableField
- @classes="reviewable-user-details scrubbed-at"
- @name={{i18n "review.user.scrubbed_at"}}
- @value={{rawDate this.reviewable.payload.scrubbed_at}}
- />
- {{else}}
- <div class="reviewable-user-details username">
- <div class="name">{{i18n "review.user.username"}}</div>
- <div class="value">
- {{#if this.reviewable.link_admin}}
- <a
- href={{getUrl
- (concat
- "/admin/users/"
- this.reviewable.user.id
- "/"
- this.reviewable.payload.username
- )
- }}
- >
- {{this.reviewable.payload.username}}
- </a>
- {{else}}
- {{this.reviewable.payload.username}}
- {{/if}}
- </div>
- </div>
- <ReviewableField
- @classes="reviewable-user-details name"
- @name={{i18n "review.user.name"}}
- @value={{this.reviewable.payload.name}}
- />
-
- <ReviewableField
- @classes="reviewable-user-details email"
- @name={{i18n "review.user.email"}}
- @value={{this.reviewable.payload.email}}
- />
-
- <ReviewableField
- @classes="reviewable-user-details bio"
- @name={{i18n "review.user.bio"}}
- @value={{this.reviewable.payload.bio}}
- />
-
- {{#if this.reviewable.payload.website}}
- <div class="reviewable-user-details website">
- <div class="name">{{i18n "review.user.website"}}</div>
- <div class="value">
- <a
- href={{this.reviewable.payload.website}}
- target="_blank"
- rel="noopener noreferrer"
- >{{this.reviewable.payload.website}}</a>
- </div>
- </div>
- {{/if}}
-
- <ReviewableField
- @classes="reviewable-user-details reject-reason"
- @name={{i18n "review.user.reject_reason"}}
- @value={{this.reviewable.reject_reason}}
- />
-
- {{#each this.userFields as |f|}}
- <ReviewableField
- @classes="reviewable-user-details user-field"
- @name={{f.name}}
- @value={{f.value}}
- />
- {{/each}}
- {{/if}}
- </div>
-
- {{yield}}
- </div>
-
- {{#if this.canScrubRejectedUser}}
- <div class="scrub-rejected-user">
- <button
- class="btn btn-danger"
- {{on "click" this.showScrubRejectedUserModal}}
- >
- {{i18n "review.user.scrub_record.button"}}
- </button>
- </div>
- {{/if}}
- </template>
-}
diff --git a/frontend/discourse/app/components/reviewable-user.js b/frontend/discourse/app/components/reviewable-user.js
new file mode 100644
index 00000000000..9a303959943
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable-user.js
@@ -0,0 +1,3 @@
+import User from "discourse/components/reviewable/user";
+
+export default User;
diff --git a/frontend/discourse/app/components/reviewable/created-by.gjs b/frontend/discourse/app/components/reviewable/created-by.gjs
new file mode 100644
index 00000000000..9463ff72c85
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable/created-by.gjs
@@ -0,0 +1,32 @@
+import ReviewableCreatedByName from "discourse/components/reviewable-created-by-name";
+import UserLink from "discourse/components/user-link";
+import avatar from "discourse/helpers/avatar";
+import icon from "discourse/helpers/d-icon";
+import { i18n } from "discourse-i18n";
+
+/**
+ * Displays the creator information for a reviewable item.
+ * Shows the user's avatar and name if available, or a deleted user icon if the user no longer exists.
+ *
+ * @component ReviewableCreatedBy
+ *
+ * @example
+ * ```gjs
+ * <ReviewableCreatedBy @user={{this.reviewable.created_by}} />
+ * ```
+ *
+ * @param {User} [user] - The user that created the reviewable item
+ */
+<template>
+ <div class="created-by">
+ {{#if @user}}
+ <UserLink @user={{@user}}>{{avatar @user imageSize="small"}}</UserLink>
+ <ReviewableCreatedByName @user={{@user}} />
+ {{else}}
+ <div class="deleted-user">
+ {{icon "trash-can" class="deleted-user-avatar"}}
+ <span class="deleted-user-name">{{i18n "review.deleted_user"}}</span>
+ </div>
+ {{/if}}
+ </div>
+</template>
diff --git a/frontend/discourse/app/components/reviewable-refresh/flag-reason.gjs b/frontend/discourse/app/components/reviewable/flag-reason.gjs
similarity index 100%
rename from frontend/discourse/app/components/reviewable-refresh/flag-reason.gjs
rename to frontend/discourse/app/components/reviewable/flag-reason.gjs
diff --git a/frontend/discourse/app/components/reviewable/flagged-post.gjs b/frontend/discourse/app/components/reviewable/flagged-post.gjs
new file mode 100644
index 00000000000..f6699a1ba5f
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable/flagged-post.gjs
@@ -0,0 +1,12 @@
+import ReviewablePost from "discourse/components/reviewable/post";
+import { i18n } from "discourse-i18n";
+
+<template>
+ <ReviewablePost
+ @reviewable={{@reviewable}}
+ @userLabel={{i18n "review.flagged_user"}}
+ @pluginOutletName="after-reviewable-flagged-post-body"
+ >
+ {{yield}}
+ </ReviewablePost>
+</template>
diff --git a/frontend/discourse/app/components/reviewable-refresh/help-resources.gjs b/frontend/discourse/app/components/reviewable/help-resources.gjs
similarity index 100%
rename from frontend/discourse/app/components/reviewable-refresh/help-resources.gjs
rename to frontend/discourse/app/components/reviewable/help-resources.gjs
diff --git a/frontend/discourse/app/components/review-index-refresh.gjs b/frontend/discourse/app/components/reviewable/index.gjs
similarity index 61%
rename from frontend/discourse/app/components/review-index-refresh.gjs
rename to frontend/discourse/app/components/reviewable/index.gjs
index 5ae600dbd6f..e60d14c32c0 100644
--- a/frontend/discourse/app/components/review-index-refresh.gjs
+++ b/frontend/discourse/app/components/reviewable/index.gjs
@@ -1,34 +1,31 @@
import Component from "@glimmer/component";
import { getOwner } from "@ember/owner";
-import { service } from "@ember/service";
import { dasherize } from "@ember/string";
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
import LoadMore from "discourse/components/load-more";
import ReviewFilters from "discourse/components/review-filters";
-import ReviewableItem from "discourse/components/reviewable-item";
-import ReviewableItemRefresh from "discourse/components/reviewable-refresh/item";
+import ReviewableItem from "discourse/components/reviewable/item";
import { bind } from "discourse/lib/decorators";
import { i18n } from "discourse-i18n";
export default class ReviewIndexRefresh extends Component {
- @service currentUser;
-
@bind
- refreshedReviewableComponentExists(reviewable) {
+ reviewableComponentExists(reviewable) {
const owner = getOwner(this);
- const dasherized = dasherize(reviewable.type).replace(
+ // TODO plugins are still using `reviewable-refresh/` path. Once they are fixed, it can be remove.
+ let dasherized = dasherize(reviewable.type).replace(
"reviewable-",
"reviewable-refresh/"
);
- return owner.hasRegistration(`component:${dasherized}`);
- }
+ if (owner.hasRegistration(`component:${dasherized}`)) {
+ return true;
+ }
- @bind
- shouldUseRefreshUI(reviewable) {
- return (
- this.currentUser.use_reviewable_ui_refresh &&
- this.refreshedReviewableComponentExists(reviewable)
+ dasherized = dasherize(reviewable.type).replace(
+ "reviewable-",
+ "reviewable/"
);
+ return owner.hasRegistration(`component:${dasherized}`);
}
<template>
@@ -39,16 +36,8 @@ export default class ReviewIndexRefresh extends Component {
<LoadMore @action={{@controller.loadMore}}>
<div class="reviewables">
{{#each @controller.reviewables.content as |r|}}
- {{#if (this.shouldUseRefreshUI r)}}
- <ReviewableItemRefresh
- @reviewable={{r}}
- @showHelp={{false}}
- />
- {{else}}
- <ReviewableItem
- @reviewable={{r}}
- @remove={{@controller.remove}}
- />
+ {{#if (this.reviewableComponentExists r)}}
+ <ReviewableItem @reviewable={{r}} @showHelp={{false}} />
{{/if}}
{{/each}}
</div>
diff --git a/frontend/discourse/app/components/reviewable-refresh/insights.gjs b/frontend/discourse/app/components/reviewable/insights.gjs
similarity index 98%
rename from frontend/discourse/app/components/reviewable-refresh/insights.gjs
rename to frontend/discourse/app/components/reviewable/insights.gjs
index c55dfb071c5..471bbad90d1 100644
--- a/frontend/discourse/app/components/reviewable-refresh/insights.gjs
+++ b/frontend/discourse/app/components/reviewable/insights.gjs
@@ -1,6 +1,6 @@
import Component from "@glimmer/component";
import { htmlSafe } from "@ember/template";
-import IpLookup from "discourse/components/reviewable-refresh/ip-lookup";
+import IpLookup from "discourse/components/reviewable/ip-lookup";
import { shortDate } from "discourse/lib/formatter";
import { i18n } from "discourse-i18n";
diff --git a/frontend/discourse/app/components/reviewable-refresh/ip-lookup.gjs b/frontend/discourse/app/components/reviewable/ip-lookup.gjs
similarity index 100%
rename from frontend/discourse/app/components/reviewable-refresh/ip-lookup.gjs
rename to frontend/discourse/app/components/reviewable/ip-lookup.gjs
diff --git a/frontend/discourse/app/components/reviewable/item.gjs b/frontend/discourse/app/components/reviewable/item.gjs
new file mode 100644
index 00000000000..add0356a49a
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable/item.gjs
@@ -0,0 +1,922 @@
+/* eslint-disable ember/no-classic-components */
+import { tracked } from "@glimmer/tracking";
+import Component from "@ember/component";
+import { concat, fn } from "@ember/helper";
+import { on } from "@ember/modifier";
+import { action, set } from "@ember/object";
+import { alias } from "@ember/object/computed";
+import { getOwner } from "@ember/owner";
+import { service } from "@ember/service";
+import { classify, dasherize } from "@ember/string";
+import { tagName } from "@ember-decorators/component";
+import ScrubRejectedUserModal from "discourse/admin/components/modal/scrub-rejected-user";
+import DButton from "discourse/components/d-button";
+import HorizontalOverflowNav from "discourse/components/horizontal-overflow-nav";
+import ExplainReviewableModal from "discourse/components/modal/explain-reviewable";
+import RejectReasonReviewableModal from "discourse/components/modal/reject-reason-reviewable";
+import ReviseAndRejectPostReviewable from "discourse/components/modal/revise-and-reject-post-reviewable";
+import ReviewableFlagReason from "discourse/components/reviewable/flag-reason";
+import ReviewableHelpResources from "discourse/components/reviewable/help-resources";
+import ReviewableInsights from "discourse/components/reviewable/insights";
+import ReviewableTimeline from "discourse/components/reviewable/timeline";
+import ReviewableBundledAction from "discourse/components/reviewable-bundled-action";
+import ReviewableClaimedTopic from "discourse/components/reviewable-claimed-topic";
+import ReviewableCreatedBy from "discourse/components/reviewable-created-by";
+import concatClass from "discourse/helpers/concat-class";
+import icon from "discourse/helpers/d-icon";
+import dasherizeHelper from "discourse/helpers/dasherize";
+import editableValue from "discourse/helpers/editable-value";
+import formatDate from "discourse/helpers/format-date";
+import { newReviewableStatus } from "discourse/helpers/reviewable-status";
+import { ajax } from "discourse/lib/ajax";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+import discourseComputed, { bind } from "discourse/lib/decorators";
+import { getAbsoluteURL } from "discourse/lib/get-url";
+import optionalService from "discourse/lib/optional-service";
+import { showAlert } from "discourse/lib/post-action-feedback";
+import { clipboardCopy } from "discourse/lib/utilities";
+import Category from "discourse/models/category";
+import Composer from "discourse/models/composer";
+import { PENDING } from "discourse/models/reviewable";
+import Topic from "discourse/models/topic";
+import { eq } from "discourse/truth-helpers";
+import { i18n } from "discourse-i18n";
+
+let _components = {};
+
+export const pluginReviewableParams = {};
+const reviewableTypeLabels = {};
+
+// The mappings defined here are default core mappings, and cannot be overridden
+// by plugins.
+const defaultActionModalClassMap = {
+ revise_and_reject_post: ReviseAndRejectPostReviewable,
+};
+export const actionModalClassMap = { ...defaultActionModalClassMap };
+
+export function addPluginReviewableParam(reviewableType, param) {
+ pluginReviewableParams[reviewableType]
+ ? pluginReviewableParams[reviewableType].push(param)
+ : (pluginReviewableParams[reviewableType] = [param]);
+}
+
+export function registerReviewableActionModal(actionName, modalClass) {
+ if (Object.keys(defaultActionModalClassMap).includes(actionName)) {
+ throw new Error(
+ `Cannot override default action modal class for ${actionName} (mapped to ${defaultActionModalClassMap[actionName].name})!`
+ );
+ }
+ actionModalClassMap[actionName] = modalClass;
+}
+
+/**
+ * Registers a custom label translation key for a reviewable type.
+ * Plugins can use this to provide specific labels for their reviewable types.
+ *
+ * @param {string} reviewableType - The reviewable type class name (e.g., "ReviewableAiPost")
+ * @param {string} labelKey - The i18n translation key (e.g., "discourse_ai.review.ai_post_flagged_as")
+ *
+ * @example
+ * import { registerReviewableTypeLabel } from "discourse/components/reviewable/item";
+ * registerReviewableTypeLabel("ReviewableAiPost", "discourse_ai.review.ai_post_flagged_as");
+ */
+export function registerReviewableTypeLabel(reviewableType, labelKey) {
+ reviewableTypeLabels[reviewableType] = labelKey;
+}
+
+function lookupComponent(context, name) {
+ return getOwner(context).resolveRegistration(`component:${name}`);
+}
+
+@tagName("")
+export default class ReviewableItem extends Component {
+ @service dialog;
+ @service modal;
+ @service siteSettings;
+ @service currentUser;
+ @service composer;
+ @service store;
+ @service toasts;
+ @service messageBus;
+ @optionalService adminTools;
+
+ @tracked disabled = false;
+ @tracked activeTab = "timeline";
+
+ @alias("reviewable.claimed_by.automatic") autoClaimed;
+
+ updating = null;
+ editing = false;
+ _updates = null;
+
+ constructor() {
+ super(...arguments);
+ this.messageBus.subscribe("/reviewable_claimed", this._updateClaimedBy);
+ this.messageBus.subscribe("/reviewable_action", this._updateStatus);
+ }
+
+ willDestroy() {
+ super.willDestroy(...arguments);
+ this.messageBus.unsubscribe("/reviewable_claimed", this._updateClaimedBy);
+ this.messageBus.unsubscribe("/reviewable_action", this._updateStatus);
+ }
+
+ @discourseComputed(
+ "reviewable.type",
+ "reviewable.last_performing_username",
+ "siteSettings.blur_tl0_flagged_posts_media",
+ "reviewable.target_created_by_trust_level",
+ "reviewable.deleted_at"
+ )
+ customClasses(
+ type,
+ lastPerformingUsername,
+ blurEnabled,
+ trustLevel,
+ deletedAt
+ ) {
+ let classes = dasherize(type);
+
+ if (lastPerformingUsername) {
+ classes = `${classes} reviewable-stale`;
+ }
+
+ if (blurEnabled && trustLevel === 0) {
+ classes = `${classes} blur-images`;
+ }
+
+ if (deletedAt) {
+ classes = `${classes} reviewable-deleted`;
+ }
+
+ return classes;
+ }
+
+ @discourseComputed(
+ "reviewable.created_from_flag",
+ "reviewable.status",
+ "claimOptional",
+ "claimRequired",
+ "reviewable.claimed_by",
+ "isAiReviewable"
+ )
+ displayContextQuestion(
+ createdFromFlag,
+ status,
+ claimOptional,
+ claimRequired,
+ claimedBy,
+ isAiReviewable
+ ) {
+ return (
+ (createdFromFlag &&
+ status === PENDING &&
+ (claimOptional || (claimRequired && claimedBy !== null))) ||
+ isAiReviewable
+ );
+ }
+
+ @discourseComputed("reviewable.type")
+ isAiReviewable(type) {
+ return type === "ReviewableAiChatMessage" || type === "ReviewableAiPost";
+ }
+
+ @discourseComputed(
+ "reviewable.topic",
+ "reviewable.topic_id",
+ "reviewable.removed_topic_id"
+ )
+ topicId(topic, topicId, removedTopicId) {
+ return (topic && topic.id) || topicId || removedTopicId;
+ }
+
+ @discourseComputed(
+ "siteSettings.reviewable_claiming",
+ "topicId",
+ "reviewable.claimed_by.automatic",
+ "reviewable.status"
+ )
+ claimEnabled(claimMode, topicId, autoClaimed, status) {
+ return (
+ (claimMode !== "disabled" || autoClaimed) &&
+ !!topicId &&
+ status === PENDING
+ );
+ }
+
+ @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")
+ claimOptional(claimMode, claimEnabled) {
+ return !claimEnabled || claimMode === "optional";
+ }
+
+ @discourseComputed("siteSettings.reviewable_claiming", "claimEnabled")
+ claimRequired(claimMode, claimEnabled) {
+ return claimEnabled && claimMode === "required";
+ }
+
+ @discourseComputed(
+ "claimEnabled",
+ "siteSettings.reviewable_claiming",
+ "reviewable.claimed_by",
+ "reviewable.bundled_actions"
+ )
+ canPerform(claimEnabled, claimMode, claimedBy, bundledActions) {
+ if (bundledActions?.length === 0) {
+ return false;
+ }
+ if (!claimEnabled) {
+ return true;
+ }
+
+ if (claimedBy) {
+ return claimedBy.user.id === this.currentUser.id;
+ }
+
+ return claimMode !== "required";
+ }
+
+ @discourseComputed(
+ "siteSettings.reviewable_claiming",
+ "reviewable.claimed_by"
+ )
+ claimHelp(claimMode, claimedBy) {
+ if (claimedBy) {
+ if (claimedBy.user.id === this.currentUser.id) {
+ return i18n("review.claim_help.claimed_by_you");
+ } else if (claimedBy.automatic) {
+ return i18n("review.claim_help.automatically_claimed_by", {
+ username: claimedBy.user.username,
+ });
+ } else {
+ return i18n("review.claim_help.claimed_by_other", {
+ username: claimedBy.user.username,
+ });
+ }
+ }
+
+ return claimMode === "optional"
+ ? i18n("review.claim_help.optional")
+ : i18n("review.claim_help.required");
+ }
+
+ // Find a component to render, if one exists. For example:
+ // `ReviewableUser` will return `reviewable/user` or `reviewable-user`.
+ // The former is the new reviewable component, so will only be returned if it exists.
+ @discourseComputed("reviewable.type")
+ reviewableComponent(type) {
+ if (_components[type] !== undefined) {
+ return _components[type];
+ }
+
+ const owner = getOwner(this);
+ const dasherized = dasherize(type);
+ const componentNames = [
+ dasherized.replace("reviewable-", "reviewable-refresh/"),
+ dasherized.replace("reviewable-", "reviewable/"),
+ dasherized,
+ ];
+
+ for (const componentName of componentNames) {
+ const componentExists =
+ owner.hasRegistration(`component:${componentName}`) ||
+ owner.hasRegistration(`template:components/${componentName}`);
+ if (componentExists) {
+ _components[type] = componentName;
+ break;
+ }
+ }
+ return _components[type] || null;
+ }
+
+ @discourseComputed("_updates.category_id", "reviewable.category.id")
+ tagCategoryId(updatedCategoryId, categoryId) {
+ return updatedCategoryId || categoryId;
+ }
+
+ @discourseComputed("reviewable.reviewable_scores")
+ scoreSummary(scores) {
+ const scoreData = scores.reduce((acc, score) => {
+ if (!acc[score.score_type.type]) {
+ acc[score.score_type.type] = {
+ title: score.score_type.title,
+ type: score.score_type.type,
+ count: 0,
+ };
+ }
+
+ acc[score.score_type.type].count += 1;
+ return acc;
+ }, {});
+
+ return Object.values(scoreData);
+ }
+
+ @discourseComputed(
+ "reviewable.type",
+ "reviewable.created_from_flag",
+ "topicId"
+ )
+ reviewableTypeLabel(type, createdFromFlag, topicId) {
+ // handle plugin types
+ if (reviewableTypeLabels[type]) {
+ return reviewableTypeLabels[type];
+ }
+
+ // core types
+ if (type === "ReviewableUser") {
+ return "review.user_label";
+ }
+
+ if (type === "ReviewableQueuedPost") {
+ // if topic_id is null it's a new topic
+ return topicId ? "review.queued_post_label" : "review.queued_topic_label";
+ }
+
+ if (type === "ReviewableChatMessage") {
+ return "review.chat_flagged_as";
+ }
+
+ if (createdFromFlag) {
+ return "review.post_flagged_as";
+ }
+
+ // fallback
+ return "review.flagged_as";
+ }
+
+ @bind
+ _updateClaimedBy(data) {
+ if (data.topic_id !== this.reviewable.topic.id) {
+ return;
+ }
+
+ const now = new Date().toISOString();
+
+ const user = this.store.createRecord("user", data.user);
+ if (data.claimed) {
+ this.reviewable.set("claimed_by", { user, automatic: data.automatic });
+ this.reviewable.set("reviewable_histories", [
+ ...this.reviewable.reviewable_histories,
+ {
+ reviewable_history_type: 3,
+ created_at: now,
+ created_by: user,
+ },
+ ]);
+ } else {
+ this.reviewable.set("claimed_by", null);
+ this.reviewable.set("reviewable_histories", [
+ ...this.reviewable.reviewable_histories,
+ {
+ reviewable_history_type: 4,
+ created_at: now,
+ created_by: user,
+ },
+ ]);
+ }
+ }
+
+ @bind
+ _updateStatus(data) {
+ if (data.remove_reviewable_ids?.includes(this.reviewable.id)) {
+ delete data.remove_reviewable_ids;
+ this._performResult(data, {}, this.reviewable);
+ }
+ }
+
+ @bind
+ async _performConfirmed(performableAction, additionalData = {}) {
+ let reviewable = this.reviewable;
+
+ let performAction = async () => {
+ this.disabled = true;
+
+ let version = reviewable.get("version");
+ this.set("updating", true);
+
+ const data = {
+ send_email: reviewable.sendEmail,
+ reject_reason: reviewable.rejectReason,
+ ...additionalData,
+ };
+
+ (pluginReviewableParams[reviewable.type] || []).forEach((param) => {
+ if (reviewable[param]) {
+ data[param] = reviewable[param];
+ }
+ });
+
+ return ajax(
+ `/review/${reviewable.id}/perform/${performableAction.server_action}?version=${version}`,
+ {
+ type: "PUT",
+ dataType: "json",
+ data,
+ }
+ )
+ .then((result) =>
+ this._performResult(
+ result.reviewable_perform_result,
+ performableAction,
+ reviewable
+ )
+ )
+ .catch(popupAjaxError)
+ .finally(() => {
+ this.set("updating", false);
+ this.disabled = false;
+ });
+ };
+
+ if (performableAction.client_action) {
+ let actionMethod =
+ this[`client${classify(performableAction.client_action)}`];
+ if (actionMethod) {
+ if (await this.#claimReviewable()) {
+ await actionMethod.call(this, reviewable, performAction);
+ }
+ } else {
+ // eslint-disable-next-line no-console
+ console.error(
+ `No handler for ${performableAction.client_action} found`
+ );
+ }
+ } else {
+ await performAction();
+ }
+
+ return this.#unclaimAutomaticReviewable();
+ }
+
+ _performResult(result, performableAction, reviewable) {
+ // "fast track" to update the current user's reviewable count before the message bus finds out.
+ if (result.reviewable_count !== undefined) {
+ this.currentUser.updateReviewableCount(result.reviewable_count);
+ }
+
+ if (result.unseen_reviewable_count !== undefined) {
+ this.currentUser.set(
+ "unseen_reviewable_count",
+ result.unseen_reviewable_count
+ );
+ }
+
+ if (performableAction.completed_message) {
+ this.toasts.success({
+ data: { message: performableAction.completed_message },
+ });
+ }
+
+ if (this.remove && result.remove_reviewable_ids?.length > 0) {
+ this.remove(result.remove_reviewable_ids);
+ } else {
+ return this.store.find("reviewable", reviewable.id);
+ }
+ }
+
+ @action
+ clientScrub() {
+ this.modal.show(ScrubRejectedUserModal, {
+ model: {
+ confirmScrub: this.scrubRejectedUser,
+ },
+ });
+ }
+
+ @bind
+ async scrubRejectedUser(reason) {
+ try {
+ await ajax({
+ url: `/review/${this.reviewable.id}/scrub`,
+ type: "PUT",
+ data: { reason },
+ });
+ this.store.find("reviewable", this.reviewable.id);
+ } catch (e) {
+ popupAjaxError(e);
+ }
+ }
+
+ clientSuspend(reviewable, performAction) {
+ return this._penalize("showSuspendModal", reviewable, performAction);
+ }
+
+ clientSilence(reviewable, performAction) {
+ return this._penalize("showSilenceModal", reviewable, performAction);
+ }
+
+ async clientEdit(reviewable, performAction) {
+ if (!this.currentUser) {
+ return this.dialog.alert(i18n("post.controls.edit_anonymous"));
+ }
+ const post = await this.store.find("post", reviewable.post_id);
+ const topic_json = await Topic.find(post.topic_id, {});
+
+ const topic = Topic.create(topic_json);
+ post.set("topic", topic);
+
+ if (!post.can_edit) {
+ return false;
+ }
+
+ const opts = {
+ post,
+ action: Composer.EDIT,
+ draftKey: post.get("topic.draft_key"),
+ draftSequence: post.get("topic.draft_sequence"),
+ skipJumpOnSave: true,
+ };
+
+ this.composer.open(opts);
+
+ return performAction();
+ }
+
+ _penalize(adminToolMethod, reviewable, performAction) {
+ let adminTools = this.adminTools;
+ if (adminTools) {
+ let createdBy = reviewable.get("target_created_by");
+ let postId = reviewable.get("post_id");
+ let postEdit = reviewable.get("raw");
+
+ return adminTools[adminToolMethod](createdBy, {
+ postId,
+ postEdit,
+ before: performAction,
+ });
+ }
+ }
+
+ async #claimReviewable() {
+ if (!this.reviewable.topic) {
+ // We can't claim a reviewable without a topic, so treat it as claimed
+ return true;
+ }
+
+ if (!this.reviewable.claimed_by) {
+ const claim = this.store.createRecord("reviewable-claimed-topic");
+
+ try {
+ await claim.save({
+ topic_id: this.reviewable.topic.id,
+ automatic: true,
+ });
+ this.reviewable.set("claimed_by", {
+ user: this.currentUser,
+ automatic: true,
+ });
+ } catch (e) {
+ popupAjaxError(e);
+ return false;
+ }
+ }
+
+ return this.reviewable.claimed_by?.user?.id === this.currentUser.id;
+ }
+
+ async #unclaimAutomaticReviewable() {
+ if (!this.reviewable.topic || !this.reviewable.claimed_by?.automatic) {
+ return;
+ }
+
+ try {
+ await ajax(`/reviewable_claimed_topics/${this.reviewable.topic.id}`, {
+ type: "DELETE",
+ data: { automatic: true },
+ });
+ this.reviewable.set("claimed_by", null);
+ } catch (e) {
+ popupAjaxError(e);
+ }
+ }
+
+ @action
+ explainReviewable(reviewable, event) {
+ event.preventDefault();
+ this.modal.show(ExplainReviewableModal, {
+ model: { reviewable },
+ });
+ }
+
+ @action
+ switchTab(tabName, event) {
+ event.preventDefault();
+ this.activeTab = tabName;
+ }
+
+ @action
+ edit() {
+ this.set("editing", true);
+ this.set("_updates", { payload: {} });
+ }
+
+ @action
+ cancelEdit() {
+ this.set("editing", false);
+ }
+
+ @action
+ saveEdit() {
+ let updates = this._updates;
+
+ // Remove empty objects
+ Object.keys(updates).forEach((name) => {
+ let attr = updates[name];
+ if (typeof attr === "object" && Object.keys(attr).length === 0) {
+ delete updates[name];
+ }
+ });
+
+ this.set("updating", true);
+ return this.reviewable
+ .update(updates)
+ .then(() => this.set("editing", false))
+ .catch(popupAjaxError)
+ .finally(() => this.set("updating", false));
+ }
+
+ @action
+ categoryChanged(categoryId) {
+ let category = Category.findById(categoryId);
+
+ if (!category) {
+ category = Category.findUncategorized();
+ }
+
+ set(this._updates, "category_id", category.id);
+ }
+
+ @action
+ valueChanged(fieldId, event) {
+ set(this._updates, fieldId, event.target.value);
+ }
+
+ @action
+ async perform(performableAction) {
+ if (this.updating) {
+ return;
+ }
+
+ const message = performableAction.get("confirm_message");
+ const requireRejectReason = performableAction.get("require_reject_reason");
+ const actionModalClass = requireRejectReason
+ ? RejectReasonReviewableModal
+ : actionModalClassMap[performableAction.server_action];
+
+ if (message) {
+ if (await this.#claimReviewable()) {
+ this.dialog.confirm({
+ message,
+ didConfirm: () => this._performConfirmed(performableAction),
+ });
+ }
+ } else if (actionModalClass) {
+ if (await this.#claimReviewable()) {
+ this.modal.show(actionModalClass, {
+ model: {
+ reviewable: this.reviewable,
+ performConfirmed: this._performConfirmed,
+ action: performableAction,
+ },
+ });
+ }
+ } else {
+ return this._performConfirmed(performableAction);
+ }
+ }
+
+ get permalink() {
+ return getAbsoluteURL(`/review/${this.reviewable.id}`);
+ }
+
+ @action
+ async copyPermalink(event) {
+ const button = event.currentTarget;
+
+ // cmd/ctrl+click or middle-click to open in new tab
+ if (event.metaKey || event.ctrlKey || event.button === 1) {
+ window.open(this.permalink, "_blank");
+ return;
+ }
+
+ try {
+ await clipboardCopy(this.permalink);
+ showAlert(
+ this.reviewable.id,
+ "reviewable-permalink-copy",
+ "review.copy_link_feedback",
+ { actionBtn: button }
+ );
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.error("Failed to copy to clipboard:", error);
+ }
+ }
+
+ <template>
+ <div class="review-container">
+
+ <div
+ data-reviewable-id={{this.reviewable.id}}
+ class="review-item {{this.customClasses}}"
+ >
+ <div class="review-item__primary-content">
+ <div class="review-item__flag-summary">
+ <div class="review-item__header">
+ <div class="review-item__label-badges">
+ <span class="review-item__flag-label">{{i18n
+ this.reviewableTypeLabel
+ }}</span>
+
+ <div class="review-item__flag-badges">
+ {{#each this.scoreSummary as |score|}}
+ <ReviewableFlagReason @score={{score}} />
+ {{/each}}
+ </div>
+ </div>
+
+ <button
+ type="button"
+ {{on "click" this.copyPermalink}}
+ title={{i18n "review.copy_permalink_title"}}
+ class="btn btn-transparent reviewable-permalink-copy"
+ >
+ {{icon "d-post-share"}}
+ </button>
+
+ {{newReviewableStatus
+ this.reviewable.status
+ this.reviewable.type
+ }}
+
+ <span class="reviewable-created-date">
+ {{formatDate this.reviewable.created_at format="tiny"}}
+ </span>
+
+ </div>
+ {{#if this.editing}}
+ <div class="editable-fields">
+ {{#each this.reviewable.editable_fields as |f|}}
+ <div class="editable-field {{dasherizeHelper f.id}}">
+ {{#let
+ (lookupComponent this (concat "reviewable-field-" f.type))
+ as |FieldComponent|
+ }}
+ <FieldComponent
+ @tagName=""
+ @value={{editableValue this.reviewable f.id}}
+ @tagCategoryId={{this.tagCategoryId}}
+ @valueChanged={{fn this.valueChanged f.id}}
+ @categoryChanged={{this.categoryChanged}}
+ />
+ {{/let}}
+ </div>
+ {{/each}}
+ </div>
+ {{else}}
+
+ {{#let
+ (lookupComponent this this.reviewableComponent)
+ as |ReviewableComponent|
+ }}
+ <ReviewableComponent
+ @reviewable={{this.reviewable}}
+ @tagName=""
+ />
+ {{/let}}
+ {{/if}}
+ </div>
+
+ <div class="review-item__insights">
+ <div class="d-nav-submenu">
+ <HorizontalOverflowNav
+ @ariaLabel="Review tabs"
+ class="d-nav-submenu__tabs"
+ >
+ <li
+ class={{concatClass
+ "timeline"
+ (if (eq this.activeTab "timeline") "active")
+ }}
+ >
+ <a
+ href="#"
+ class={{if (eq this.activeTab "timeline") "active"}}
+ {{on "click" (fn this.switchTab "timeline")}}
+ >
+ {{i18n "review.timeline_and_notes"}}
+ </a>
+ </li>
+ <li
+ class={{concatClass
+ "insights"
+ (if (eq this.activeTab "insights") "active")
+ }}
+ >
+ <a
+ href="#"
+ class={{if (eq this.activeTab "insights") "active"}}
+ {{on "click" (fn this.switchTab "insights")}}
+ >
+ {{i18n "review.insights.title"}}
+ </a>
+ </li>
+ </HorizontalOverflowNav>
+ </div>
+
+ {{#if (eq this.activeTab "insights")}}
+ <ReviewableInsights @reviewable={{this.reviewable}} />
+ {{else if (eq this.activeTab "timeline")}}
+ <ReviewableTimeline
+ @reviewable={{this.reviewable}}
+ @historyEvents={{this.reviewable.reviewable_histories}}
+ />
+ {{/if}}
+ </div>
+ </div>
+
+ <div class="review-item__aside">
+
+ {{#unless this.reviewable.last_performing_username}}
+ {{#if this.canPerform}}
+ <div class="review-item__moderator-actions">
+ <h3 class="review-item__aside-title">
+ {{#if this.editing}}
+ {{i18n "review.editing_post"}}
+ {{else if (eq this.reviewable.status PENDING)}}
+ {{#if this.displayContextQuestion}}
+ {{this.reviewable.flaggedReviewableContextQuestion}}
+ {{else if this.reviewable.userReviewableContextQuestion}}
+ {{this.reviewable.userReviewableContextQuestion}}
+ {{else}}
+ {{i18n "review.moderator_actions"}}
+ {{/if}}
+ {{else}}
+ {{i18n "review.moderator_actions"}}
+ {{/if}}
+ </h3>
+ {{#if this.editing}}
+ <DButton
+ @disabled={{this.disabled}}
+ @icon="check"
+ @action={{this.saveEdit}}
+ @label="review.save"
+ class="btn-primary reviewable-action save-edit"
+ />
+ <DButton
+ @disabled={{this.disabled}}
+ @icon="xmark"
+ @action={{this.cancelEdit}}
+ @label="review.cancel"
+ class="btn-danger reviewable-action cancel-edit"
+ />
+ {{else}}
+ {{#each this.reviewable.bundled_actions as |bundle|}}
+ <ReviewableBundledAction
+ @bundle={{bundle}}
+ @performAction={{this.perform}}
+ @reviewableUpdating={{this.disabled}}
+ />
+ {{/each}}
+
+ {{#if this.reviewable.can_edit}}
+ <DButton
+ @disabled={{this.disabled}}
+ @action={{this.edit}}
+ @label="review.edit"
+ class="reviewable-action btn-default edit"
+ />
+ {{/if}}
+ {{/if}}
+ </div>
+ {{/if}}
+ {{/unless}}
+
+ {{#if this.claimEnabled}}
+ <div class="review-item__moderator-actions --extra">
+ {{#if this.reviewable.claimed_by}}
+ <div class="review-item__assigned">
+ {{icon "user-plus"}}
+ <ReviewableCreatedBy
+ @showUsername={{true}}
+ @avatarSize="small"
+ @user={{this.reviewable.claimed_by.user}}
+ />
+ </div>
+ {{/if}}
+ <ReviewableClaimedTopic
+ @topicId={{this.topicId}}
+ @claimedBy={{this.reviewable.claimed_by}}
+ @onClaim={{fn (mut this.reviewable.claimed_by)}}
+ />
+ </div>
+ {{/if}}
+
+ {{#if @showHelp}}
+ <ReviewableHelpResources />
+ {{/if}}
+ </div>
+ </div>
+ </div>
+ </template>
+}
diff --git a/frontend/discourse/app/components/reviewable-refresh/note-form.gjs b/frontend/discourse/app/components/reviewable/note-form.gjs
similarity index 100%
rename from frontend/discourse/app/components/reviewable-refresh/note-form.gjs
rename to frontend/discourse/app/components/reviewable/note-form.gjs
diff --git a/frontend/discourse/app/components/reviewable/post.gjs b/frontend/discourse/app/components/reviewable/post.gjs
new file mode 100644
index 00000000000..c47a7bb81f8
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable/post.gjs
@@ -0,0 +1,94 @@
+import Component from "@glimmer/component";
+import { htmlSafe } from "@ember/template";
+import DecoratedHtml, {
+ applyHtmlDecorators,
+} from "discourse/components/decorated-html";
+import PluginOutlet from "discourse/components/plugin-outlet";
+import ReviewableCreatedBy from "discourse/components/reviewable/created-by";
+import ReviewableTopicLink from "discourse/components/reviewable/topic-link";
+import ReviewablePostEdits from "discourse/components/reviewable-post-edits";
+import lazyHash from "discourse/helpers/lazy-hash";
+import { bind } from "discourse/lib/decorators";
+import highlightHTML from "discourse/lib/highlight-html";
+import { i18n } from "discourse-i18n";
+
+export default class ReviewablePost extends Component {
+ get metaLabel() {
+ return this.args.metaLabel || i18n("review.posted_in");
+ }
+
+ get userLabel() {
+ return this.args.userLabel || i18n("review.review_user");
+ }
+
+ get pluginOutletName() {
+ return this.args.pluginOutletName || "after-reviewable-post-body";
+ }
+
+ @bind
+ decorate(element, helper) {
+ const reviewable = this.args.reviewable;
+ if (reviewable?.reviewable_scores) {
+ const words = reviewable.reviewable_scores
+ .map((rs) => {
+ return rs.reason_type === "watched_word" ? rs.reason_data : [];
+ })
+ .flat();
+
+ if (words.length > 0) {
+ words.forEach((word) => {
+ highlightHTML(element, word, {
+ nodeName: "mark",
+ className: "watched-word-highlight",
+ });
+ });
+ }
+ }
+
+ applyHtmlDecorators(element, helper);
+ }
+
+ <template>
+ <div class="review-item__meta-content">
+ <div class="review-item__meta-label">{{this.metaLabel}}</div>
+
+ <div class="review-item__meta-topic-title">
+ <ReviewableTopicLink @reviewable={{@reviewable}} />
+ <ReviewablePostEdits @reviewable={{@reviewable}} />
+ </div>
+
+ <div class="review-item__meta-label">{{this.userLabel}}</div>
+
+ <div class="review-item__meta-flagged-user">
+ <ReviewableCreatedBy @user={{@reviewable.target_created_by}} />
+ </div>
+ </div>
+
+ <div class="review-item__post">
+ <div class="review-item__post-content-wrapper">
+ {{#if @reviewable.blank_post}}
+ <div class="review-item__post-content">
+ <p>{{i18n "review.deleted_post"}}</p>
+ </div>
+ {{else}}
+ <DecoratedHtml
+ @className="review-item__post-content"
+ @html={{htmlSafe @reviewable.cooked}}
+ @decorate={{this.decorate}}
+ @model={{@reviewable}}
+ />
+ {{/if}}
+
+ <span>
+ <PluginOutlet
+ @name={{this.pluginOutletName}}
+ @connectorTagName="div"
+ @outletArgs={{lazyHash model=@reviewable}}
+ />
+ </span>
+
+ {{yield}}
+ </div>
+ </div>
+ </template>
+}
diff --git a/frontend/discourse/app/components/reviewable/queued-post.gjs b/frontend/discourse/app/components/reviewable/queued-post.gjs
new file mode 100644
index 00000000000..4441d4ffea8
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable/queued-post.gjs
@@ -0,0 +1,80 @@
+import Component from "@glimmer/component";
+import { hash } from "@ember/helper";
+import { on } from "@ember/modifier";
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import CookText from "discourse/components/cook-text";
+import RawEmailModal from "discourse/components/modal/raw-email";
+import PluginOutlet from "discourse/components/plugin-outlet";
+import ReviewableCreatedBy from "discourse/components/reviewable/created-by";
+import ReviewableTopicLink from "discourse/components/reviewable/topic-link";
+import ReviewableTags from "discourse/components/reviewable-tags";
+import categoryBadge from "discourse/helpers/category-badge";
+import icon from "discourse/helpers/d-icon";
+import lazyHash from "discourse/helpers/lazy-hash";
+import highlightWatchedWords from "discourse/lib/highlight-watched-words";
+import { i18n } from "discourse-i18n";
+
+export default class ReviewableQueuedPost extends Component {
+ @service modal;
+
+ @action
+ showRawEmail(event) {
+ event?.preventDefault();
+ this.modal.show(RawEmailModal, {
+ model: {
+ rawEmail: this.args.reviewable.payload.raw_email,
+ },
+ });
+ }
+
+ <template>
+ <div class="review-item__meta-content">
+ <div class="review-item__meta-label">{{i18n "review.topic_label"}}</div>
+
+ <div class="review-item__meta-topic-title">
+ <ReviewableTopicLink @reviewable={{@reviewable}}>
+ <div class="title-text">
+ {{highlightWatchedWords @reviewable.payload.title @reviewable}}
+ </div>
+ {{categoryBadge @reviewable.category}}
+ <ReviewableTags @tags={{@reviewable.payload.tags}} />
+ {{#if @reviewable.payload.via_email}}
+ <a href {{on "click" this.showRawEmail}} class="show-raw-email">
+ {{icon "envelope" title="post.via_email"}}
+ </a>
+ {{/if}}
+ </ReviewableTopicLink>
+ </div>
+
+ <div class="review-item__meta-label">{{i18n "review.review_user"}}</div>
+
+ <div class="review-item__meta-flagged-user">
+ <ReviewableCreatedBy @user={{@reviewable.target_created_by}} />
+ </div>
+ </div>
+
+ <div class="review-item__post">
+ <div class="review-item__post-content">
+ <CookText
+ class="post-body"
+ @rawText={{highlightWatchedWords @reviewable.payload.raw @reviewable}}
+ @categoryId={{@reviewable.category_id}}
+ @topicId={{@reviewable.topic_id}}
+ @paintOneboxes={{false}}
+ @opts={{hash removeMissing=true}}
+ />
+
+ <span>
+ <PluginOutlet
+ @name="after-reviewable-queued-post-body"
+ @connectorTagName="div"
+ @outletArgs={{lazyHash model=@reviewable}}
+ />
+ </span>
+
+ {{yield}}
+ </div>
+ </div>
+ </template>
+}
diff --git a/frontend/discourse/app/components/reviewable-refresh/timeline.gjs b/frontend/discourse/app/components/reviewable/timeline.gjs
similarity index 98%
rename from frontend/discourse/app/components/reviewable-refresh/timeline.gjs
rename to frontend/discourse/app/components/reviewable/timeline.gjs
index 5050f74f1c2..a0cbab65112 100644
--- a/frontend/discourse/app/components/reviewable-refresh/timeline.gjs
+++ b/frontend/discourse/app/components/reviewable/timeline.gjs
@@ -7,8 +7,8 @@ import { htmlSafe } from "@ember/template";
import DButton from "discourse/components/d-button";
import DecoratedHtml from "discourse/components/decorated-html";
import InterpolatedTranslation from "discourse/components/interpolated-translation";
-import ReviewableFlagReason from "discourse/components/reviewable-refresh/flag-reason";
-import ReviewableNoteForm from "discourse/components/reviewable-refresh/note-form";
+import ReviewableFlagReason from "discourse/components/reviewable/flag-reason";
+import ReviewableNoteForm from "discourse/components/reviewable/note-form";
import UserLink from "discourse/components/user-link";
import avatar from "discourse/helpers/avatar";
import icon from "discourse/helpers/d-icon";
diff --git a/frontend/discourse/app/components/reviewable/topic-link.gjs b/frontend/discourse/app/components/reviewable/topic-link.gjs
new file mode 100644
index 00000000000..090ec5c764c
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable/topic-link.gjs
@@ -0,0 +1,73 @@
+import { array } from "@ember/helper";
+import { LinkTo } from "@ember/routing";
+import ReviewableTags from "discourse/components/reviewable-tags";
+import TopicStatus from "discourse/components/topic-status";
+import categoryBadge from "discourse/helpers/category-badge";
+import highlightWatchedWords from "discourse/lib/highlight-watched-words";
+import { i18n } from "discourse-i18n";
+
+/**
+ * Displays topic information for reviewable items.
+ * Shows the topic title, status, category badge, and tags if the topic exists.
+ * For deleted topics, displays a link to the original topic. Supports block content as fallback.
+ *
+ * @component ReviewableTopicLink
+ *
+ * @example
+ * ```gjs
+ * <ReviewableTopicLink @reviewable={{this.reviewable}} />
+ *
+ * <!-- With block content for custom fallback -->
+ * <ReviewableTopicLink @reviewable={{this.reviewable}}>
+ * <span>Custom content when topic is missing</span>
+ * </ReviewableTopicLink>
+ * ```
+ *
+ * @param {Reviewable} reviewable - The reviewable object containing topic information
+ */
+<template>
+ <div class="reviewable-topic-link">
+ {{#if @reviewable.topic}}
+ <div class="reviewable-topic-link__title-wrapper">
+ <div class="reviewable-topic-link__title-status">
+ <TopicStatus
+ @topic={{@reviewable.topic}}
+ @showPrivateMessageIcon={{true}}
+ />
+ </div>
+
+ <div class="reviewable-topic-link__title-link">
+ <a
+ href={{@reviewable.target_url}}
+ class="title-text"
+ >{{highlightWatchedWords
+ @reviewable.topic.fancyTitle
+ @reviewable
+ }}</a>
+ </div>
+ </div>
+
+ <div class="reviewable-topic-link__details">
+ {{#if @reviewable.category}}
+ <div class="reviewable-topic-link__details-category-badge">
+ {{categoryBadge @reviewable.category}}
+ </div>
+ {{/if}}
+
+ <div class="reviewable-topic-link__details-tags">
+ <ReviewableTags @tags={{@reviewable.topic_tags}} @tagName="" />
+ </div>
+ </div>
+ {{else if @reviewable.removed_topic_id}}
+ <span class="title-text">
+ {{i18n "review.topics.deleted"}}
+ <LinkTo
+ @route="topic"
+ @models={{array "-" @reviewable.removed_topic_id}}
+ >{{i18n "review.topics.original"}}</LinkTo>
+ </span>
+ {{else if (has-block)}}
+ {{yield}}
+ {{/if}}
+ </div>
+</template>
diff --git a/frontend/discourse/app/components/reviewable/user.gjs b/frontend/discourse/app/components/reviewable/user.gjs
new file mode 100644
index 00000000000..b95a2b1b6e5
--- /dev/null
+++ b/frontend/discourse/app/components/reviewable/user.gjs
@@ -0,0 +1,155 @@
+/* eslint-disable ember/no-classic-components */
+import Component from "@ember/component";
+import { concat } from "@ember/helper";
+import { action } from "@ember/object";
+import { service } from "@ember/service";
+import { tagName } from "@ember-decorators/component";
+import ScrubRejectedUserModal from "discourse/admin/components/modal/scrub-rejected-user";
+import ReviewableField from "discourse/components/reviewable-field";
+import rawDate from "discourse/helpers/raw-date";
+import { ajax } from "discourse/lib/ajax";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+import discourseComputed, { bind } from "discourse/lib/decorators";
+import getUrl from "discourse/lib/get-url";
+import { i18n } from "discourse-i18n";
+
+@tagName("")
+export default class ReviewableUser extends Component {
+ @service modal;
+ @service store;
+
+ @discourseComputed("reviewable.user_fields")
+ userFields(fields) {
+ return this.site.collectUserFields(fields);
+ }
+
+ @discourseComputed("reviewable.payload")
+ isScrubbed(payload) {
+ return !!payload?.scrubbed_by;
+ }
+
+ @action
+ showScrubRejectedUserModal() {
+ this.modal.show(ScrubRejectedUserModal, {
+ model: {
+ confirmScrub: this.scrubRejectedUser,
+ },
+ });
+ }
+
+ @bind
+ async scrubRejectedUser(reason) {
+ try {
+ await ajax({
+ url: `/review/${this.reviewable.id}/scrub`,
+ type: "PUT",
+ data: { reason },
+ });
+ this.store.find("reviewable", this.reviewable.id);
+ } catch (e) {
+ popupAjaxError(e);
+ }
+ }
+
+ <template>
+ <div class="review-item__meta-content">
+ <div class="reviewable-user-info">
+ <div class="reviewable-user-fields">
+ {{#if this.isScrubbed}}
+ <ReviewableField
+ @classes="reviewable-user-details reject-reason"
+ @name={{i18n "review.user.scrubbed_reject_reason"}}
+ @value={{this.reviewable.reject_reason}}
+ />
+
+ <ReviewableField
+ @classes="reviewable-user-details scrubbed-by"
+ @name={{i18n "review.user.scrubbed_by"}}
+ @value={{this.reviewable.payload.scrubbed_by}}
+ />
+
+ <ReviewableField
+ @classes="reviewable-user-details scrubbed-reason"
+ @name={{i18n "review.user.scrubbed_reason"}}
+ @value={{this.reviewable.payload.scrubbed_reason}}
+ />
+
+ <ReviewableField
+ @classes="reviewable-user-details scrubbed-at"
+ @name={{i18n "review.user.scrubbed_at"}}
+ @value={{rawDate this.reviewable.payload.scrubbed_at}}
+ />
+ {{else}}
+ <div class="reviewable-user-details username">
+ <div class="name">{{i18n "review.user.username"}}</div>
+ <div class="value">
+ {{#if this.reviewable.link_admin}}
+ <a
+ href={{getUrl
+ (concat
+ "/admin/users/"
+ this.reviewable.user.id
+ "/"
+ this.reviewable.payload.username
+ )
+ }}
+ >
+ {{this.reviewable.payload.username}}
+ </a>
+ {{else}}
+ {{this.reviewable.payload.username}}
+ {{/if}}
+ </div>
+ </div>
+ <ReviewableField
+ @classes="reviewable-user-details name"
+ @name={{i18n "review.user.name"}}
+ @value={{this.reviewable.payload.name}}
+ />
+
+ <ReviewableField
+ @classes="reviewable-user-details email"
+ @name={{i18n "review.user.email"}}
+ @value={{this.reviewable.payload.email}}
+ />
+
+ <ReviewableField
+ @classes="reviewable-user-details bio"
+ @name={{i18n "review.user.bio"}}
+ @value={{this.reviewable.payload.bio}}
+ />
+
+ {{#if this.reviewable.payload.website}}
+ <div class="reviewable-user-details website">
+ <div class="name">{{i18n "review.user.website"}}</div>
+ <div class="value">
+ <a
+ href={{this.reviewable.payload.website}}
+ target="_blank"
+ rel="noopener noreferrer"
+ >{{this.reviewable.payload.website}}</a>
+ </div>
+ </div>
+ {{/if}}
+
+ <ReviewableField
+ @classes="reviewable-user-details reject-reason"
+ @name={{i18n "review.user.reject_reason"}}
+ @value={{this.reviewable.reject_reason}}
+ />
+
+ {{#each this.userFields as |f|}}
+ <ReviewableField
+ @classes="reviewable-user-details user-field"
+ @name={{f.name}}
+ @value={{f.value}}
+ />
+ {{/each}}
+ {{/if}}
+ </div>
+
+ {{yield}}
+ </div>
+ </div>
+ </template>
+}
diff --git a/frontend/discourse/app/helpers/reviewable-status.js b/frontend/discourse/app/helpers/reviewable-status.js
index abd0c27e644..0d7fe509cbc 100644
--- a/frontend/discourse/app/helpers/reviewable-status.js
+++ b/frontend/discourse/app/helpers/reviewable-status.js
@@ -103,7 +103,6 @@ export function htmlStatus(status, type) {
`;
}
-// TODO (reviewable-refresh): Replace with newReviewableStatus
export default function (status, type) {
return htmlSafe(htmlStatus(status, type));
}
diff --git a/frontend/discourse/app/lib/plugin-api.gjs b/frontend/discourse/app/lib/plugin-api.gjs
index 09933abd729..188055f9ae0 100644
--- a/frontend/discourse/app/lib/plugin-api.gjs
+++ b/frontend/discourse/app/lib/plugin-api.gjs
@@ -26,7 +26,7 @@ import { addGroupPostSmallActionCode } from "discourse/components/post/small-act
import {
addPluginReviewableParam,
registerReviewableActionModal,
-} from "discourse/components/reviewable-refresh/item";
+} from "discourse/components/reviewable/item";
import { addAdvancedSearchOptions } from "discourse/components/search-advanced-options";
import { addSearchSuggestion } from "discourse/components/search-menu/results/assistant";
import { addItemSelectCallback as addSearchMenuAssistantSelectCallback } from "discourse/components/search-menu/results/assistant-item";
diff --git a/frontend/discourse/app/templates/review/index.gjs b/frontend/discourse/app/templates/review/index.gjs
index 17fb1933121..e99f329d996 100644
--- a/frontend/discourse/app/templates/review/index.gjs
+++ b/frontend/discourse/app/templates/review/index.gjs
@@ -1,82 +1,67 @@
-import Component from "@glimmer/component";
import { LinkTo } from "@ember/routing";
-import { service } from "@ember/service";
import { htmlSafe } from "@ember/template";
import DButton from "discourse/components/d-button";
import NavItem from "discourse/components/nav-item";
-import ReviewIndexLegacy from "discourse/components/review-index-legacy";
-import ReviewIndexRefresh from "discourse/components/review-index-refresh";
+import ReviewIndex from "discourse/components/reviewable/index";
import icon from "discourse/helpers/d-icon";
import { eq } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
-export default class ReviewIndex extends Component {
- @service currentUser;
-
- get shouldUseRefreshUI() {
- return this.currentUser?.use_reviewable_ui_refresh;
- }
+<template>
+ <ul class="nav nav-pills reviewable-title">
+ <NavItem @route="review.index" @label="review.view_all" />
+ <NavItem @route="review.topics" @label="review.grouped_by_topic" />
+ {{#if @controller.currentUser.admin}}
+ <NavItem
+ @route="review.settings"
+ @label="review.settings.title"
+ @icon="wrench"
+ />
+ {{/if}}
+ </ul>
+ {{#if @controller.displayUnknownReviewableTypesWarning}}
+ <div class="alert alert-info unknown-reviewables">
+ <span class="text">{{i18n
+ "review.unknown.title"
+ }}</span>
- <template>
- <ul class="nav nav-pills reviewable-title">
- <NavItem @route="review.index" @label="review.view_all" />
- <NavItem @route="review.topics" @label="review.grouped_by_topic" />
- {{#if @controller.currentUser.admin}}
- <NavItem
- @route="review.settings"
- @label="review.settings.title"
- @icon="wrench"
+ <ul>
+ {{#each @controller.unknownReviewableTypes as |reviewable|}}
+ {{#if (eq reviewable.source @controller.unknownTypeSource)}}
+ <li>{{i18n
+ "review.unknown.reviewable_unknown_source"
+ reviewableType=reviewable.type
+ }}</li>
+ {{else}}
+ <li>{{i18n
+ "review.unknown.reviewable_known_source"
+ reviewableType=reviewable.type
+ pluginName=reviewable.source
+ }}</li>
+ {{/if}}
+ {{/each}}
+ </ul>
+ <span class="text">{{htmlSafe
+ (i18n
+ "review.unknown.instruction"
+ url="https://meta.discourse.org/t/350179"
+ )
+ }}</span>
+ <div class="unknown-reviewables__options">
+ <LinkTo @route="adminPlugins.index" class="btn">
+ {{icon "puzzle-piece"}}
+ <span>{{i18n "review.unknown.enable_plugins"}}</span>
+ </LinkTo>
+ <DButton
+ @label="review.unknown.ignore_all"
+ @icon="trash-can"
+ @action={{@controller.ignoreAllUnknownTypes}}
+ class="btn-default"
/>
- {{/if}}
- </ul>
- {{#if @controller.displayUnknownReviewableTypesWarning}}
- <div class="alert alert-info unknown-reviewables">
- <span class="text">{{i18n
- "review.unknown.title"
- }}</span>
-
- <ul>
- {{#each @controller.unknownReviewableTypes as |reviewable|}}
- {{#if (eq reviewable.source @controller.unknownTypeSource)}}
- <li>{{i18n
- "review.unknown.reviewable_unknown_source"
- reviewableType=reviewable.type
- }}</li>
- {{else}}
- <li>{{i18n
- "review.unknown.reviewable_known_source"
- reviewableType=reviewable.type
- pluginName=reviewable.source
- }}</li>
- {{/if}}
- {{/each}}
- </ul>
- <span class="text">{{htmlSafe
- (i18n
- "review.unknown.instruction"
- url="https://meta.discourse.org/t/350179"
- )
- }}</span>
- <div class="unknown-reviewables__options">
- <LinkTo @route="adminPlugins.index" class="btn">
- {{icon "puzzle-piece"}}
- <span>{{i18n "review.unknown.enable_plugins"}}</span>
- </LinkTo>
- <DButton
- @label="review.unknown.ignore_all"
- @icon="trash-can"
- @action={{@controller.ignoreAllUnknownTypes}}
- class="btn-default"
- />
- </div>
</div>
- {{/if}}
+ </div>
+ {{/if}}
- {{#if this.shouldUseRefreshUI}}
- <ReviewIndexRefresh @controller={{@controller}} />
- {{else}}
- <ReviewIndexLegacy @controller={{@controller}} />
- {{/if}}
- </template>
-}
+ <ReviewIndex @controller={{@controller}} />
+</template>
diff --git a/frontend/discourse/app/templates/review/show.gjs b/frontend/discourse/app/templates/review/show.gjs
index 9cd101a519d..3c259b8c82a 100644
--- a/frontend/discourse/app/templates/review/show.gjs
+++ b/frontend/discourse/app/templates/review/show.gjs
@@ -1,69 +1,42 @@
import Component from "@glimmer/component";
import { getOwner } from "@ember/owner";
import { LinkTo } from "@ember/routing";
-import { service } from "@ember/service";
import { dasherize } from "@ember/string";
-import NavItem from "discourse/components/nav-item";
-import ReviewableItem from "discourse/components/reviewable-item";
-import ReviewableItemRefresh from "discourse/components/reviewable-refresh/item";
+import ReviewableItem from "discourse/components/reviewable/item";
import icon from "discourse/helpers/d-icon";
import { i18n } from "discourse-i18n";
export default class extends Component {
- @service currentUser;
-
- /**
- * Checks if a refreshed reviewable component exists for the current reviewable type.
- *
- * @returns {boolean} True if the refreshed component exists, false otherwise
- */
- get refreshedReviewableComponentExists() {
+ // TODO plugins are still using `reviewable-refresh/` path. Once they are fixed, it can be remove.
+ get reviewableComponentExists() {
const owner = getOwner(this);
- const dasherized = dasherize(this.args.controller.reviewable.type).replace(
+ let dasherized = dasherize(this.args.controller.reviewable.type).replace(
"reviewable-",
"reviewable-refresh/"
);
+ if (owner.hasRegistration(`component:${dasherized}`)) {
+ return true;
+ }
- return owner.hasRegistration(`component:${dasherized}`);
- }
-
- /**
- * Determines whether to use the refreshed reviewable UI component.
- *
- * @returns {boolean} True if both conditions are met: user has permission and component exists
- */
- get shouldUseRefreshUI() {
- return (
- this.currentUser.use_reviewable_ui_refresh &&
- this.refreshedReviewableComponentExists
+ dasherized = dasherize(this.args.controller.reviewable.type).replace(
+ "reviewable-",
+ "reviewable/"
);
+ return owner.hasRegistration(`component:${dasherized}`);
}
<template>
- {{#if this.shouldUseRefreshUI}}
+ {{#if this.reviewableComponentExists}}
<div class="reviewable-top-nav">
<LinkTo @route="review.index">
{{icon "arrow-left"}}
{{i18n "review.back_to_queue"}}
</LinkTo>
</div>
- <ReviewableItemRefresh
+ <ReviewableItem
@reviewable={{@controller.reviewable}}
@showHelp={{true}}
/>
- {{else}}
- <ul class="nav nav-pills reviewable-title">
- <NavItem @route="review.index" @label="review.view_all" />
- <NavItem @route="review.topics" @label="review.grouped_by_topic" />
- {{#if @controller.currentUser.admin}}
- <NavItem
- @route="review.settings"
- @label="review.settings.title"
- @icon="wrench"
- />
- {{/if}}
- </ul>
- <ReviewableItem @reviewable={{@controller.reviewable}} />
{{/if}}
</template>
}
diff --git a/frontend/discourse/tests/acceptance/review-test.js b/frontend/discourse/tests/acceptance/review-test.js
deleted file mode 100644
index 24cc7deb94b..00000000000
--- a/frontend/discourse/tests/acceptance/review-test.js
+++ /dev/null
@@ -1,236 +0,0 @@
-import { click, fillIn, visit } from "@ember/test-helpers";
-import { test } from "qunit";
-import {
- acceptance,
- loggedInUser,
- publishToMessageBus,
-} from "discourse/tests/helpers/qunit-helpers";
-import selectKit from "discourse/tests/helpers/select-kit-helper";
-import { i18n } from "discourse-i18n";
-
-acceptance("Review", function (needs) {
- needs.user();
-
- let requests = [];
-
- needs.pretender((server, helper) => {
- server.get("/tags/filter/search", (request) => {
- requests.push(request);
- return helper.response({
- results: [
- { id: "monkey", name: "monkey", count: 1 },
- { id: "not-monkey", name: "not-monkey", count: 1 },
- { id: "happy-monkey", name: "happy-monkey", count: 1 },
- ],
- });
- });
- });
-
- const user = '.reviewable-item[data-reviewable-id="1234"]';
-
- test("It returns a list of reviewable items", async function (assert) {
- await visit("/review");
-
- assert.dom(".reviewable-item").exists("has a list of items");
- assert.dom(user).exists();
- assert
- .dom(`${user}.reviewable-user`)
- .exists("applies a class for the type");
- assert
- .dom(`${user} .reviewable-action.approve`)
- .exists("creates a button for approve");
- assert
- .dom(`${user} .reviewable-action.reject`)
- .exists("creates a button for reject");
- });
-
- test("Grouped by topic", async function (assert) {
- await visit("/review/topics");
- assert
- .dom(".reviewable-topic")
- .exists("it has a list of reviewable topics");
- });
-
- test("Reject user", async function (assert) {
- let reviewableActionDropdown = selectKit(
- `${user} .reviewable-action-dropdown`
- );
-
- await visit("/review");
- await reviewableActionDropdown.expand();
- await reviewableActionDropdown.selectRowByValue("reject_user_delete");
-
- assert.dom(".reject-reason-reviewable-modal").exists();
- assert
- .dom(".reject-reason-reviewable-modal .d-modal__title")
- .includesHtml(
- i18n("review.reject_reason.title"),
- "opens reject reason modal when user is rejected"
- );
-
- await click(".d-modal__footer .cancel");
- await reviewableActionDropdown.expand();
- await reviewableActionDropdown.selectRowByValue("reject_user_block");
-
- assert.dom(".reject-reason-reviewable-modal").exists();
- assert
- .dom(".reject-reason-reviewable-modal .d-modal__title")
- .includesHtml(
- i18n("review.reject_reason.title"),
- "opens reject reason modal when user is rejected and blocked"
- );
- });
-
- test("Settings", async function (assert) {
- await visit("/review/settings");
-
- assert.dom(".reviewable-score-type").exists("has a list of bonuses");
-
- const field = selectKit(
- ".reviewable-score-type:nth-of-type(1) .field .combo-box"
- );
- await field.expand();
- await field.selectRowByValue("5");
- await click(".save-settings");
-
- assert.dom(".reviewable-settings .saved").exists("it saved");
- });
-
- test("Flag related", async function (assert) {
- await visit("/review");
-
- assert
- .dom(".reviewable-flagged-post .post-contents .username a[href]")
- .exists("it has a link to the user");
-
- assert
- .dom(".reviewable-flagged-post .post-body")
- .hasHtml("<b>cooked content</b>");
-
- assert
- .dom(".reviewable-flagged-post .reviewable-score")
- .exists({ count: 2 });
- });
-
- test("Flag related", async function (assert) {
- await visit("/review/1");
-
- assert.dom(".reviewable-flagged-post").exists("shows the flagged post");
- });
-
- test("Clicking the buttons triggers actions", async function (assert) {
- await visit("/review");
- await click(`${user} .reviewable-action.approve`);
- assert.dom(user).doesNotExist("removes the reviewable on success");
- });
-
- test("Editing a reviewable", async function (assert) {
- const topic = '.reviewable-item[data-reviewable-id="4321"]';
-
- await visit("/review");
-
- assert.dom(`${topic} .reviewable-action.approve`).exists();
- assert.dom(`${topic} .badge-category__name`).doesNotExist();
-
- assert.dom(`${topic} .discourse-tag:nth-of-type(1)`).hasText("hello");
- assert.dom(`${topic} .discourse-tag:nth-of-type(2)`).hasText("world");
-
- assert
- .dom(`${topic} .post-body`)
- .hasText("existing body http://somegoodurl.com");
-
- await click(`${topic} .reviewable-action.edit`);
- await click(`${topic} .reviewable-action.save-edit`);
-
- assert
- .dom(`${topic} .reviewable-action.approve`)
- .exists("saving without changes is a cancel");
-
- await click(`${topic} .reviewable-action.edit`);
-
- assert
- .dom(`${topic} .reviewable-action.approve`)
- .doesNotExist("when editing actions are disabled");
-
- await fillIn(".editable-field.payload-raw textarea", "new raw contents");
- await click(`${topic} .reviewable-action.cancel-edit`);
-
- assert
- .dom(`${topic} .post-body`)
- .hasText(
- "existing body http://somegoodurl.com",
- "cancelling does not update the value"
- );
-
- await click(`${topic} .reviewable-action.edit`);
- let category = selectKit(`${topic} .category-id .select-kit`);
-
- await category.expand();
- await category.selectRowByValue("6");
-
- assert.strictEqual(
- category.header().name(),
- "support",
- "displays the right header"
- );
-
- let tags = selectKit(`${topic} .payload-tags .mini-tag-chooser`);
- requests = [];
- await tags.expand();
- assert.strictEqual(requests.length, 1);
- assert.strictEqual(requests[0].queryParams.categoryId, "6");
- await tags.fillInFilter("monkey");
- await tags.selectRowByName("monkey");
-
- await fillIn(".editable-field.payload-raw textarea", "new raw contents");
- await click(`${topic} .reviewable-action.save-edit`);
-
- assert.dom(`${topic} .discourse-tag:nth-of-type(1)`).hasText("hello");
- assert.dom(`${topic} .discourse-tag:nth-of-type(2)`).hasText("world");
- assert.dom(`${topic} .discourse-tag:nth-of-type(3)`).hasText("monkey");
-
- assert.dom(`${topic} .post-body`).hasText("new raw contents");
- assert.dom(`${topic} .badge-category__name`).hasText("support");
- });
-
- test("Reviewables can become stale", async function (assert) {
- await visit("/review");
-
- assert
- .dom("[data-reviewable-id='1234']")
- .doesNotHaveClass("reviewable-stale");
- assert.dom("[data-reviewable-id='1234'] .status .pending").exists();
- assert.dom(".stale-help").doesNotExist();
-
- await publishToMessageBus(`/reviewable_counts/${loggedInUser().id}`, {
- review_count: 1,
- updates: {
- 1234: { last_performing_username: "foo", status: 1 },
- },
- });
-
- assert.dom("[data-reviewable-id='1234']").hasClass("reviewable-stale");
- assert.dom("[data-reviewable-id='1234'] .status .approved").exists();
- assert.dom(".stale-help").exists();
- assert.dom(".stale-help").includesText("foo");
-
- await visit("/");
- await visit("/review"); // reload review
-
- assert.dom(".stale-help").doesNotExist();
- });
-
- test("Queued post does not paint oneboxes", async function (assert) {
- const topic = '.reviewable-item[data-reviewable-id="4321"]';
-
- await visit("/review");
-
- assert
- .dom(`${topic} .post-body`)
- .includesText("existing body http://somegoodurl.com");
-
- assert
- .dom(`${topic} .post-body aside.onebox`)
- .doesNotExist("onebox content is not painted in reviewable queued posts");
- });
-});
diff --git a/frontend/discourse/tests/helpers/review-pretender.js b/frontend/discourse/tests/helpers/review-pretender.js
index c9ebcbf975a..5a276f94b5d 100644
--- a/frontend/discourse/tests/helpers/review-pretender.js
+++ b/frontend/discourse/tests/helpers/review-pretender.js
@@ -3,12 +3,14 @@ import { set } from "@ember/object";
export default function (helpers) {
const { response } = helpers;
- let flag = {
+ const flag = {
id: 6667,
type: "ReviewableFlaggedPost",
+ status: 0,
score: 3.0,
target_created_by_id: 1,
cooked: "<b>cooked content</b>",
+ created_at: "2019-01-14T19:49:53.571Z",
reviewable_score_ids: [1, 2],
};
@@ -26,6 +28,7 @@ export default function (helpers) {
username: "newbie",
bundled_action_ids: ["approve", "reject", "reject_user"],
+ reviewable_score_ids: [],
},
{
id: 4321,
@@ -47,6 +50,7 @@ export default function (helpers) {
{ id: "payload.tags", type: "tags" },
],
bundled_action_ids: ["approve", "reject"],
+ reviewable_score_ids: [],
},
flag,
],
@@ -95,7 +99,22 @@ export default function (helpers) {
require_reject_reason: true,
},
],
- reviewable_scores: [{ id: 1 }, { id: 2 }],
+ reviewable_scores: [
+ {
+ id: 1,
+ score_type: {
+ type: "spam",
+ title: "Spam",
+ },
+ },
+ {
+ id: 2,
+ score_type: {
+ type: "inappropriate",
+ title: "Inappropriate",
+ },
+ },
+ ],
users: [{ id: 1, username: "eviltrout" }],
meta: {
total_rows_reviewables: 2,
@@ -223,6 +242,24 @@ export default function (helpers) {
this.get("/review/:id", () => {
return response(200, {
reviewable: flag,
+ reviewable_scores: [
+ {
+ id: 1,
+ score_type: {
+ type: "spam",
+ title: "Spam",
+ },
+ },
+ {
+ id: 2,
+ score_type: {
+ type: "inappropriate",
+ title: "Inappropriate",
+ },
+ },
+ ],
+ users: [{ id: 1, username: "eviltrout" }],
+ __rest_serializer: "1",
});
});
diff --git a/frontend/discourse/tests/integration/components/reviewable-refresh/created-by-test.gjs b/frontend/discourse/tests/integration/components/reviewable-refresh/created-by-test.gjs
deleted file mode 100644
index ea0ed18aad1..00000000000
--- a/frontend/discourse/tests/integration/components/reviewable-refresh/created-by-test.gjs
+++ /dev/null
@@ -1,47 +0,0 @@
-import { render } from "@ember/test-helpers";
-import { module, test } from "qunit";
-import CreatedBy from "discourse/components/reviewable-refresh/created-by";
-import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-
-module(
- "Integration | Component | reviewable-refresh | created-by",
- function (hooks) {
- setupRenderingTest(hooks);
-
- test("renders user avatar and name when user is provided", async function (assert) {
- const user = {
- id: 1,
- username: "testuser",
- avatar_template: "/images/avatar.png",
- };
-
- await render(<template><CreatedBy @user={{user}} /></template>);
-
- assert.dom(".created-by").exists("renders the created-by container");
-
- assert.dom(".created-by .avatar").exists("renders user avatar");
-
- assert
- .dom(".created-by .username")
- .containsText("testuser", "displays the username");
- });
-
- test("renders deleted user icon when no user is provided", async function (assert) {
- await render(<template><CreatedBy /></template>);
-
- assert.dom(".created-by").exists("renders the created-by container");
-
- assert
- .dom(".created-by .d-icon-trash-can")
- .exists("renders trash icon for deleted user");
-
- assert
- .dom(".created-by .deleted-user-avatar")
- .exists("has deleted-user-avatar class on icon");
-
- assert
- .dom(".created-by .avatar")
- .doesNotExist("does not render user avatar");
- });
- }
-);
diff --git a/frontend/discourse/tests/integration/components/reviewable-refresh/flag-reason-test.gjs b/frontend/discourse/tests/integration/components/reviewable-refresh/flag-reason-test.gjs
deleted file mode 100644
index fb938914f70..00000000000
--- a/frontend/discourse/tests/integration/components/reviewable-refresh/flag-reason-test.gjs
+++ /dev/null
@@ -1,79 +0,0 @@
-import { render } from "@ember/test-helpers";
-import { module, test } from "qunit";
-import ReviewableFlagReason from "discourse/components/reviewable-refresh/flag-reason";
-import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-
-module(
- "Integration | Component | reviewable-refresh | flag-reason",
- function (hooks) {
- setupRenderingTest(hooks);
-
- test("renders with basic arguments", async function (assert) {
- const score = { type: "spam", title: "This is spam", count: 3 };
-
- await render(
- <template><ReviewableFlagReason @score={{score}} /></template>
- );
-
- assert
- .dom(".review-item__flag-reason")
- .exists("renders the flag reason container");
- assert
- .dom(".review-item__flag-reason")
- .containsText("This is spam", "displays the title");
- assert
- .dom(".review-item__flag-count")
- .exists("renders the flag count element");
- assert
- .dom(".review-item__flag-count")
- .containsText("x3", "displays the count value formatted as xN");
- });
-
- test("does not render count when invalid", async function (assert) {
- const countScenarios = [
- { count: 0, title: "Zero count", description: "count is 0" },
- { count: 1, title: "Single count", description: "count is 1" },
- {
- count: undefined,
- title: "Undefined count",
- description: "count is not provided",
- },
- {
- count: -1,
- title: "Negative count",
- description: "count is negative",
- },
- ];
-
- for (const { count, title, description } of countScenarios) {
- const score = { type: "spam", title, count };
-
- await render(
- <template><ReviewableFlagReason @score={{score}} /></template>
- );
-
- assert
- .dom(".review-item__flag-count")
- .doesNotExist(`does not render count element when ${description}`);
- assert
- .dom(".review-item__flag-reason")
- .containsText(title, `still displays the title when ${description}`);
- }
- });
-
- test("renders title even when empty string", async function (assert) {
- const score = { type: "spam", title: "", count: 2 };
-
- await render(
- <template><ReviewableFlagReason @score={{score}} /></template>
- );
-
- assert
- .dom(".review-item__flag-reason")
- .exists("renders the flag reason container");
- assert
- .dom(".review-item__flag-reason")
- .hasText("x2", "shows the count when title is empty");
- });
- }
-);
diff --git a/frontend/discourse/tests/integration/components/reviewable-refresh/topic-link-test.gjs b/frontend/discourse/tests/integration/components/reviewable-refresh/topic-link-test.gjs
deleted file mode 100644
index 342d2263bbe..00000000000
--- a/frontend/discourse/tests/integration/components/reviewable-refresh/topic-link-test.gjs
+++ /dev/null
@@ -1,112 +0,0 @@
-import { render } from "@ember/test-helpers";
-import { module, test } from "qunit";
-import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";
-import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-
-module(
- "Integration | Component | reviewable-refresh | topic-link",
- function (hooks) {
- setupRenderingTest(hooks);
-
- test("renders topic information when topic exists", async function (assert) {
- const reviewable = {
- topic: {
- fancyTitle: "Test Topic Title",
- id: 123,
- },
- target_url: "/t/test-topic/123",
- category: {
- id: 5,
- name: "General",
- color: "0088CC",
- },
- topic_tags: ["tag1", "tag2"],
- };
-
- await render(
- <template>
- <ReviewableTopicLink @reviewable={{reviewable}}><span
- class="custom-fallback"
- >Custom fallback content</span></ReviewableTopicLink>
- </template>
- );
-
- assert.dom(".topic-statuses").exists("renders the TopicStatus component");
-
- assert.dom("a.title-text").exists("renders the topic title link");
- assert
- .dom("a.title-text")
- .hasAttribute("href", "/t/test-topic/123", "has correct target URL");
- assert
- .dom("a.title-text")
- .containsText("Test Topic Title", "displays the topic title");
-
- assert.dom(".badge-category").exists("renders the category badge");
- assert.dom(".list-tags").exists("renders the ReviewableTags component");
-
- assert
- .dom(".custom-fallback")
- .doesNotExist("doesn't render the block content");
- });
-
- test("renders deleted topic message when topic does not exist", async function (assert) {
- const reviewable = {
- removed_topic_id: 999,
- };
-
- await render(
- <template><ReviewableTopicLink @reviewable={{reviewable}} /></template>
- );
-
- assert.dom("span.title-text").exists("renders the title text span");
- assert
- .dom("span.title-text")
- .containsText("[Topic Deleted]", "shows deleted topic message");
- assert.dom("span.title-text a").exists("renders link to original topic");
- assert
- .dom("span.title-text a")
- .containsText("original topic", "shows original topic link text");
- });
-
- test("renders block content when topic is missing and block is provided", async function (assert) {
- const reviewable = {};
-
- await render(
- <template>
- <ReviewableTopicLink @reviewable={{reviewable}}>
- <span class="custom-fallback">Custom fallback content</span>
- </ReviewableTopicLink>
- </template>
- );
-
- assert.dom(".custom-fallback").exists("renders the block content");
- assert
- .dom(".custom-fallback")
- .containsText("Custom fallback content", "displays block content text");
- assert
- .dom(".title-text")
- .doesNotExist("does not render default deleted topic message");
- });
-
- test("renders deleted topic message over block content when removed_topic_id is present", async function (assert) {
- const reviewable = {
- removed_topic_id: 999,
- };
-
- await render(
- <template>
- <ReviewableTopicLink @reviewable={{reviewable}}>
- <span class="custom-fallback">Custom fallback content</span>
- </ReviewableTopicLink>
- </template>
- );
-
- assert
- .dom("span.title-text")
- .containsText("[Topic Deleted]", "shows deleted topic message");
- assert
- .dom(".custom-fallback")
- .doesNotExist("does not render the block content");
- });
- }
-);
diff --git a/frontend/discourse/tests/integration/components/reviewable/created-by-test.gjs b/frontend/discourse/tests/integration/components/reviewable/created-by-test.gjs
new file mode 100644
index 00000000000..9ad8706617f
--- /dev/null
+++ b/frontend/discourse/tests/integration/components/reviewable/created-by-test.gjs
@@ -0,0 +1,44 @@
+import { render } from "@ember/test-helpers";
+import { module, test } from "qunit";
+import CreatedBy from "discourse/components/reviewable/created-by";
+import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+
+module("Integration | Component | reviewable | created-by", function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("renders user avatar and name when user is provided", async function (assert) {
+ const user = {
+ id: 1,
+ username: "testuser",
+ avatar_template: "/images/avatar.png",
+ };
+
+ await render(<template><CreatedBy @user={{user}} /></template>);
+
+ assert.dom(".created-by").exists("renders the created-by container");
+
+ assert.dom(".created-by .avatar").exists("renders user avatar");
+
+ assert
+ .dom(".created-by .username")
+ .containsText("testuser", "displays the username");
+ });
+
+ test("renders deleted user icon when no user is provided", async function (assert) {
+ await render(<template><CreatedBy /></template>);
+
+ assert.dom(".created-by").exists("renders the created-by container");
+
+ assert
+ .dom(".created-by .d-icon-trash-can")
+ .exists("renders trash icon for deleted user");
+
+ assert
+ .dom(".created-by .deleted-user-avatar")
+ .exists("has deleted-user-avatar class on icon");
+
+ assert
+ .dom(".created-by .avatar")
+ .doesNotExist("does not render user avatar");
+ });
+});
diff --git a/frontend/discourse/tests/integration/components/reviewable/flag-reason-test.gjs b/frontend/discourse/tests/integration/components/reviewable/flag-reason-test.gjs
new file mode 100644
index 00000000000..50e43c02332
--- /dev/null
+++ b/frontend/discourse/tests/integration/components/reviewable/flag-reason-test.gjs
@@ -0,0 +1,76 @@
+import { render } from "@ember/test-helpers";
+import { module, test } from "qunit";
+import ReviewableFlagReason from "discourse/components/reviewable/flag-reason";
+import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+
+module("Integration | Component | reviewable | flag-reason", function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("renders with basic arguments", async function (assert) {
+ const score = { type: "spam", title: "This is spam", count: 3 };
+
+ await render(
+ <template><ReviewableFlagReason @score={{score}} /></template>
+ );
+
+ assert
+ .dom(".review-item__flag-reason")
+ .exists("renders the flag reason container");
+ assert
+ .dom(".review-item__flag-reason")
+ .containsText("This is spam", "displays the title");
+ assert
+ .dom(".review-item__flag-count")
+ .exists("renders the flag count element");
+ assert
+ .dom(".review-item__flag-count")
+ .containsText("x3", "displays the count value formatted as xN");
+ });
+
+ test("does not render count when invalid", async function (assert) {
+ const countScenarios = [
+ { count: 0, title: "Zero count", description: "count is 0" },
+ { count: 1, title: "Single count", description: "count is 1" },
+ {
+ count: undefined,
+ title: "Undefined count",
+ description: "count is not provided",
+ },
+ {
+ count: -1,
+ title: "Negative count",
+ description: "count is negative",
+ },
+ ];
+
+ for (const { count, title, description } of countScenarios) {
+ const score = { type: "spam", title, count };
+
+ await render(
+ <template><ReviewableFlagReason @score={{score}} /></template>
+ );
+
+ assert
+ .dom(".review-item__flag-count")
+ .doesNotExist(`does not render count element when ${description}`);
+ assert
+ .dom(".review-item__flag-reason")
+ .containsText(title, `still displays the title when ${description}`);
+ }
+ });
+
+ test("renders title even when empty string", async function (assert) {
+ const score = { type: "spam", title: "", count: 2 };
+
+ await render(
+ <template><ReviewableFlagReason @score={{score}} /></template>
+ );
+
+ assert
+ .dom(".review-item__flag-reason")
+ .exists("renders the flag reason container");
+ assert
+ .dom(".review-item__flag-reason")
+ .hasText("x2", "shows the count when title is empty");
+ });
+});
diff --git a/frontend/discourse/tests/integration/components/reviewable-refresh/item-test.gjs b/frontend/discourse/tests/integration/components/reviewable/item-test.gjs
similarity index 81%
rename from frontend/discourse/tests/integration/components/reviewable-refresh/item-test.gjs
rename to frontend/discourse/tests/integration/components/reviewable/item-test.gjs
index 87d8ddf15d1..5fecb10c6e2 100644
--- a/frontend/discourse/tests/integration/components/reviewable-refresh/item-test.gjs
+++ b/frontend/discourse/tests/integration/components/reviewable/item-test.gjs
@@ -1,9 +1,9 @@
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
-import ReviewableItemRefresh from "discourse/components/reviewable-refresh/item";
+import ReviewableItem from "discourse/components/reviewable/item";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-module("Integration | Component | reviewable-refresh | item", function (hooks) {
+module("Integration | Component | reviewable | item", function (hooks) {
setupRenderingTest(hooks);
const reviewable = {
@@ -31,7 +31,7 @@ module("Integration | Component | reviewable-refresh | item", function (hooks) {
test("renders help resources ", async function (assert) {
await render(
<template>
- <ReviewableItemRefresh @reviewable={{reviewable}} @showHelp={{true}} />
+ <ReviewableItem @reviewable={{reviewable}} @showHelp={{true}} />
</template>
);
assert.dom(".review-item__resources").exists("renders the help content");
@@ -54,7 +54,7 @@ module("Integration | Component | reviewable-refresh | item", function (hooks) {
test("does not render help resources when not required", async function (assert) {
await render(
- <template><ReviewableItemRefresh @reviewable={{reviewable}} /></template>
+ <template><ReviewableItem @reviewable={{reviewable}} /></template>
);
assert
.dom(".review-item__resources")
diff --git a/frontend/discourse/tests/integration/components/reviewable/topic-link-test.gjs b/frontend/discourse/tests/integration/components/reviewable/topic-link-test.gjs
new file mode 100644
index 00000000000..eaf62aab8e9
--- /dev/null
+++ b/frontend/discourse/tests/integration/components/reviewable/topic-link-test.gjs
@@ -0,0 +1,88 @@
+import { render } from "@ember/test-helpers";
+import { module, test } from "qunit";
+import ReviewableTopicLink from "discourse/components/reviewable/topic-link";
+import { setupRenderingTest } from "discourse/tests/helpers/component-test";
+
+module("Integration | Component | reviewable | topic-link", function (hooks) {
+ setupRenderingTest(hooks);
+
+ test("renders topic information when topic exists", async function (assert) {
+ const reviewable = {
+ topic: {
+ fancyTitle: "Test Topic Title",
+ id: 123,
+ },
+ target_url: "/t/test-topic/123",
+ category: {
+ id: 5,
+ name: "General",
+ color: "0088CC",
+ },
+ topic_tags: ["tag1", "tag2"],
+ };
+
+ await render(
+ <template>
+ <ReviewableTopicLink @reviewable={{reviewable}}><span
+ class="custom-fallback"
+ >Custom fallback content</span></ReviewableTopicLink>
+ </template>
+ );
+
+ assert.dom(".topic-statuses").exists("renders the TopicStatus component");
+
+ assert.dom("a.title-text").exists("renders the topic title link");
+ assert
+ .dom("a.title-text")
+ .hasAttribute("href", "/t/test-topic/123", "has correct target URL");
+ assert
+ .dom("a.title-text")
+ .containsText("Test Topic Title", "displays the topic title");
+
+ assert.dom(".badge-category").exists("renders the category badge");
+ assert.dom(".list-tags").exists("renders the ReviewableTags component");
+
+ assert
+ .dom(".custom-fallback")
+ .doesNotExist("doesn't render the block content");
+ });
+
+ test("renders deleted topic message when topic does not exist", async function (assert) {
+ const reviewable = {
+ removed_topic_id: 999,
+ };
+
+ await render(
+ <template><ReviewableTopicLink @reviewable={{reviewable}} /></template>
+ );
+
+ assert.dom("span.title-text").exists("renders the title text span");
+ assert
+ .dom("span.title-text")
+ .containsText("[Topic Deleted]", "shows deleted topic message");
+ assert.dom("span.title-text a").exists("renders link to original topic");
+ assert
+ .dom("span.title-text a")
+ .containsText("original topic", "shows original topic link text");
+ });
+
+ test("renders block content when topic is missing and block is provided", async function (assert) {
+ const reviewable = {};
+
+ await render(
+ <template>
+ <ReviewableTopicLink @reviewable={{reviewable}}>
+ <span class="custom-fallback">Custom fallback content</span>
+ </ReviewableTopicLink>
+ </template>
+ );
+
+ assert.dom(".custom-fallback").exists("renders the block content");
+ assert
+ .dom(".custom-fallback")
+ .containsText("Custom fallback content", "displays block content text");
+ assert
+ .dom(".title-text")
+ .doesNotExist("does not render default deleted topic message");
+ });
+});
diff --git a/lib/guardian.rb b/lib/guardian.rb
index 8f5fbb6a581..dae2fea17a6 100644
--- a/lib/guardian.rb
+++ b/lib/guardian.rb
@@ -613,10 +613,6 @@ class Guardian
@user.in_any_groups?(SiteSetting.lazy_load_categories_groups_map)
end
- def can_see_reviewable_ui_refresh?
- !SiteSetting.force_old_reviewable_ui
- end
-
def is_me?(other)
other && authenticated? && other.is_a?(User) && @user == other
end
diff --git a/plugins/chat/app/models/chat/reviewable_message.rb b/plugins/chat/app/models/chat/reviewable_message.rb
index 68ccd955560..47d5a9677bd 100644
--- a/plugins/chat/app/models/chat/reviewable_message.rb
+++ b/plugins/chat/app/models/chat/reviewable_message.rb
@@ -40,8 +40,7 @@ module Chat
nil
end
- # TODO (reviewable-refresh): Remove this method when fully migrated to new UI
- def build_legacy_combined_actions(actions, guardian, args)
+ def build_combined_actions(actions, guardian, args)
return unless pending?
return build_action(actions, :ignore, icon: "up-right-from-square") if chat_message.blank?
@@ -98,24 +97,6 @@ module Chat
end
end
- # TODO (reviewable-refresh): Merge this method into build_actions when fully migrated to new UI
- def build_new_separated_actions
- bundle_actions = { no_action_message: {} }
- if chat_message.deleted_at?
- bundle_actions[:restore_message] = {}
- else
- bundle_actions[:delete_message] = {}
- end
- build_bundle(
- "#{id}-message-actions",
- "chat.reviewables.actions.message_actions.bundle_title",
- bundle_actions,
- )
-
- build_user_actions_bundle
- end
-
- # TODO (reviewable-refresh): Remove combined actions below when fully migrated to new UI
def perform_agree_and_keep_message(performed_by, args)
agree
end
@@ -147,25 +128,6 @@ module Chat
def perform_agree_and_keep_deleted(performed_by, args)
agree
end
- # TODO (reviewable-refresh): Remove combined actions above when fully migrated to new UI
-
- def perform_no_action_message(performed_by, args)
- if chat_message.deleted_at?
- create_result(:success, :approved, [created_by_id], true)
- else
- create_result(:success, :rejected, [created_by_id], true)
- end
- end
-
- def perform_restore_message(_performed_by, args)
- chat_message.recover!
- create_result(:success, :rejected, [created_by_id], true)
- end
-
- def perform_delete_message(performed_by, args)
- chat_message.trash!(performed_by)
- create_result(:success, :approved, [created_by_id], true)
- end
private
diff --git a/plugins/chat/assets/javascripts/discourse/components/reviewable-refresh/chat-message.gjs b/plugins/chat/assets/javascripts/discourse/components/reviewable/chat-message.gjs
similarity index 98%
rename from plugins/chat/assets/javascripts/discourse/components/reviewable-refresh/chat-message.gjs
rename to plugins/chat/assets/javascripts/discourse/components/reviewable/chat-message.gjs
index 02298ae1ddf..97f2441d2de 100644
--- a/plugins/chat/assets/javascripts/discourse/components/reviewable-refresh/chat-message.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/reviewable/chat-message.gjs
@@ -2,8 +2,8 @@ import Component from "@glimmer/component";
import { cached } from "@glimmer/tracking";
import { array } from "@ember/helper";
import { LinkTo } from "@ember/routing";
-import ReviewableCreatedBy from "discourse/components/reviewable-refresh/created-by";
-import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";
+import ReviewableCreatedBy from "discourse/components/reviewable/created-by";
+import ReviewableTopicLink from "discourse/components/reviewable/topic-link";
import highlightWatchedWords from "discourse/lib/highlight-watched-words";
import { i18n } from "discourse-i18n";
import ChannelTitle from "discourse/plugins/chat/discourse/components/channel-title";
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable-refresh/ai-chat-message.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable/ai-chat-message.gjs
similarity index 98%
rename from plugins/discourse-ai/assets/javascripts/discourse/components/reviewable-refresh/ai-chat-message.gjs
rename to plugins/discourse-ai/assets/javascripts/discourse/components/reviewable/ai-chat-message.gjs
index b6126611d89..8ce1a37a744 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable-refresh/ai-chat-message.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable/ai-chat-message.gjs
@@ -2,8 +2,8 @@ import Component from "@glimmer/component";
import { cached } from "@glimmer/tracking";
import { array } from "@ember/helper";
import { LinkTo } from "@ember/routing";
-import ReviewableCreatedBy from "discourse/components/reviewable-refresh/created-by";
-import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";
+import ReviewableCreatedBy from "discourse/components/reviewable/created-by";
+import ReviewableTopicLink from "discourse/components/reviewable/topic-link";
import highlightWatchedWords from "discourse/lib/highlight-watched-words";
import { i18n } from "discourse-i18n";
import ChannelTitle from "discourse/plugins/chat/discourse/components/channel-title";
diff --git a/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable-refresh/ai-post.gjs b/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable/ai-post.gjs
similarity index 82%
rename from plugins/discourse-ai/assets/javascripts/discourse/components/reviewable-refresh/ai-post.gjs
rename to plugins/discourse-ai/assets/javascripts/discourse/components/reviewable/ai-post.gjs
index 1a7c3e8c885..be6f4d83f1f 100644
--- a/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable-refresh/ai-post.gjs
+++ b/plugins/discourse-ai/assets/javascripts/discourse/components/reviewable/ai-post.gjs
@@ -1,4 +1,4 @@
-import ReviewablePost from "discourse/components/reviewable-refresh/post";
+import ReviewablePost from "discourse/components/reviewable/post";
import { i18n } from "discourse-i18n";
import ModelAccuracies from "../model-accuracies";
diff --git a/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rb b/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rb
index 762d3bf965b..1d85f1ab520 100644
--- a/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rb
+++ b/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rb
@@ -32,8 +32,7 @@ class ReviewablePostVotingComment < Reviewable
@comment_creator ||= User.find_by(id: comment.user_id)
end
- # TODO (reviewable-refresh): Remove this method when fully migrated to new UI
- def build_legacy_combined_actions(actions, guardian, args)
+ def build_combined_actions(actions, guardian, args)
return unless pending?
return if comment.blank?
@@ -85,25 +84,6 @@ class ReviewablePostVotingComment < Reviewable
end
end
- # TODO (reviewable-refresh): Merge this method into build_actions when fully migrated to new UI
- def build_new_separated_actions
- bundle_actions = { no_action_comment: {} }
- if comment.deleted_at?
- bundle_actions[:agree_and_restore] = {}
- bundle_actions[:disagree_and_restore] = {}
- else
- bundle_actions[:agree_and_delete] = {}
- bundle_actions[:agree_and_keep_comment] = {}
- end
-
- build_bundle(
- "#{id}-comment-actions",
- "discourse_post_voting.reviewables.actions.comment_actions.bundle_title",
- bundle_actions,
- )
- build_user_actions_bundle
- end
-
def perform_no_action_comment(performed_by, args)
if comment.deleted_at?
create_result(:success, :approved, [created_by_id], true)
diff --git a/plugins/discourse-post-voting/assets/javascripts/discourse/components/reviewable-refresh/post-voting-comment.gjs b/plugins/discourse-post-voting/assets/javascripts/discourse/components/reviewable/post-voting-comment.gjs
similarity index 96%
rename from plugins/discourse-post-voting/assets/javascripts/discourse/components/reviewable-refresh/post-voting-comment.gjs
rename to plugins/discourse-post-voting/assets/javascripts/discourse/components/reviewable/post-voting-comment.gjs
index eda4afa4e62..7e761777905 100644
--- a/plugins/discourse-post-voting/assets/javascripts/discourse/components/reviewable-refresh/post-voting-comment.gjs
+++ b/plugins/discourse-post-voting/assets/javascripts/discourse/components/reviewable/post-voting-comment.gjs
@@ -1,6 +1,6 @@
+import ReviewableCreatedBy from "discourse/components/reviewable/created-by";
+import ReviewableTopicLink from "discourse/components/reviewable/topic-link";
import ReviewablePostEdits from "discourse/components/reviewable-post-edits";
-import ReviewableCreatedBy from "discourse/components/reviewable-refresh/created-by";
-import ReviewableTopicLink from "discourse/components/reviewable-refresh/topic-link";
import highlightWatchedWords from "discourse/lib/highlight-watched-words";
import { i18n } from "discourse-i18n";
diff --git a/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb b/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb
index 6bdec075ec1..0fdff2aac91 100644
--- a/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb
+++ b/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb
@@ -7,58 +7,50 @@ describe "Viewing reviewable post voting comment", type: :system do
fab!(:reply) { Fabricate(:post, topic: topic) }
fab!(:comment) { Fabricate(:post_voting_comment, post: reply) }
fab!(:reviewable) { Fabricate(:reviewable_post_voting_comment, target: comment, topic: topic) }
- let(:refreshed_review_page) { PageObjects::Pages::RefreshedReview.new }
+ let(:review_page) { PageObjects::Pages::Review.new }
before do
- SiteSetting.reviewable_old_moderator_actions = false
- SiteSetting.reviewable_ui_refresh = group.name
group.add(admin)
sign_in(admin)
end
it "has created at history item" do
- refreshed_review_page.visit_reviewable(reviewable)
- expect(refreshed_review_page).to have_history_items(count: 2)
- expect(refreshed_review_page).to have_created_at_history_item
+ review_page.visit_reviewable(reviewable)
+ expect(review_page).to have_history_items(count: 2)
+ expect(review_page).to have_created_at_history_item
end
xit "Allows to delete and restore comment" do
- refreshed_review_page.visit_reviewable(reviewable)
+ review_page.visit_reviewable(reviewable)
expect(page).to have_text(comment.raw)
- refreshed_review_page.select_bundled_action(reviewable, "post_voting_comment-agree_and_delete")
- expect(refreshed_review_page).to have_reviewable_with_approved_status(reviewable)
+ review_page.select_bundled_action(reviewable, "post_voting_comment-agree_and_delete")
+ expect(review_page).to have_reviewable_with_approved_status(reviewable)
- refreshed_review_page.visit_reviewable(reviewable)
+ review_page.visit_reviewable(reviewable)
expect(page).not_to have_text(comment.raw)
- refreshed_review_page.select_bundled_action(reviewable, "post_voting_comment-agree_and_restore")
- expect(refreshed_review_page).to have_reviewable_with_approved_status(reviewable)
+ review_page.select_bundled_action(reviewable, "post_voting_comment-agree_and_restore")
+ expect(review_page).to have_reviewable_with_approved_status(reviewable)
expect(page).to have_text(comment.raw)
- refreshed_review_page.select_bundled_action(reviewable, "post_voting_comment-agree_and_delete")
- refreshed_review_page.select_bundled_action(
- reviewable,
- "post_voting_comment-disagree_and_restore",
- )
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)
+ review_page.select_bundled_action(reviewable, "post_voting_comment-agree_and_delete")
+ review_page.select_bundled_action(reviewable, "post_voting_comment-disagree_and_restore")
+ expect(review_page).to have_reviewable_with_rejected_status(reviewable)
end
xit "Allows to ignore the reviewable" do
- refreshed_review_page.visit_reviewable(reviewable)
+ review_page.visit_reviewable(reviewable)
- refreshed_review_page.select_bundled_action(reviewable, "post_voting_comment-no_action_comment")
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)
+ review_page.select_bundled_action(reviewable, "post_voting_comment-no_action_comment")
+ expect(review_page).to have_reviewable_with_rejected_status(reviewable)
end
xit "Allows to keep comment" do
- refreshed_review_page.visit_reviewable(reviewable)
+ review_page.visit_reviewable(reviewable)
- refreshed_review_page.select_bundled_action(
- reviewable,
- "post_voting_comment-agree_and_keep_comment",
- )
- expect(refreshed_review_page).to have_reviewable_with_approved_status(reviewable)
+ review_page.select_bundled_action(reviewable, "post_voting_comment-agree_and_keep_comment")
+ expect(review_page).to have_reviewable_with_approved_status(reviewable)
end
end
diff --git a/plugins/discourse-user-notes/spec/system/reviewable_user_notes_spec.rb b/plugins/discourse-user-notes/spec/system/reviewable_user_notes_spec.rb
index 3ea76f11447..58aea860fc5 100644
--- a/plugins/discourse-user-notes/spec/system/reviewable_user_notes_spec.rb
+++ b/plugins/discourse-user-notes/spec/system/reviewable_user_notes_spec.rb
@@ -5,13 +5,12 @@ RSpec.describe "Reviewable User Notes", type: :system do
fab!(:user)
fab!(:reviewable_flagged_post)
- let(:review_page) { PageObjects::Pages::RefreshedReview.new }
+ let(:review_page) { PageObjects::Pages::Review.new }
let(:review_note_form) { PageObjects::Components::ReviewNoteForm.new }
let(:user_notes_modal) { PageObjects::Modals::Base.new }
before do
SiteSetting.user_notes_enabled = true
- SiteSetting.reviewable_ui_refresh = "staff"
sign_in(admin)
end
diff --git a/spec/fixtures/images/logo.jpg b/spec/fixtures/images/logo.jpg
index 3ca525dfc67..178ef9269ea 100644
Binary files a/spec/fixtures/images/logo.jpg and b/spec/fixtures/images/logo.jpg differ
diff --git a/spec/models/concerns/reviewable_action_builder_spec.rb b/spec/models/concerns/reviewable_action_builder_spec.rb
index 2029b2e36a6..ea0a8f85ec0 100644
--- a/spec/models/concerns/reviewable_action_builder_spec.rb
+++ b/spec/models/concerns/reviewable_action_builder_spec.rb
@@ -5,52 +5,6 @@ RSpec.describe ReviewableActionBuilder do
fab!(:guardian) { Guardian.new(admin) }
fab!(:user)
- describe "#build_user_actions_bundle" do
- fab!(:post) { Fabricate(:post, user: user) }
- fab!(:reviewable_post) do
- ReviewablePost.needs_review!(target: post, created_by: admin, potential_spam: false)
- end
- fab!(:post_actions) { Reviewable::Actions.new(reviewable_post, guardian) }
-
- before do
- reviewable_post.instance_variable_set(:@actions, post_actions)
- reviewable_post.instance_variable_set(:@guardian, guardian)
- reviewable_post.instance_variable_set(:@action_args, {})
- end
-
- it "creates a user bundle with standard actions when allowed" do
- bundle = reviewable_post.build_user_actions_bundle
-
- # bundle id and label
- expect(bundle.id).to eq("#{reviewable_post.id}-user-actions")
- expect(bundle.label).to eq("reviewables.actions.user_actions.bundle_title")
-
- # action ids are prefixed with target type (post-...)
- action_ids = bundle.actions.map(&:id)
- expect(action_ids).to include("post-no_action_user")
- expect(action_ids).to include("post-silence_user")
- expect(action_ids).to include("post-suspend_user")
- expect(action_ids).to include("post-delete_user")
- expect(action_ids).to include("post-delete_and_block_user")
-
- # client_action is set for moderation actions
- silence = bundle.actions.find { |a| a.id == "post-silence_user" }
- suspend = bundle.actions.find { |a| a.id == "post-suspend_user" }
- expect(silence.client_action).to eq("silence")
- expect(suspend.client_action).to eq("suspend")
- end
-
- it "includes only the no-op action when user is nil" do
- allow(reviewable_post).to receive(:target_created_by).and_return(nil)
-
- bundle = reviewable_post.build_user_actions_bundle
- server_actions = bundle.actions.map(&:server_action)
-
- expect(server_actions).to include("no_action_user")
- expect(server_actions - ["no_action_user"]).to be_empty
- end
- end
-
describe "#build_action" do
fab!(:reviewable_user) { ReviewableUser.create_for(user) }
diff --git a/spec/models/reviewable_action_log_spec.rb b/spec/models/reviewable_action_log_spec.rb
deleted file mode 100644
index 79cf034f38f..00000000000
--- a/spec/models/reviewable_action_log_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe ReviewableActionLog, type: :model do
- fab!(:moderator)
- fab!(:reviewable, :reviewable_flagged_post)
-
- describe "reviewable_action_logs association on reviewable" do
- it "creates action logs associated with reviewable" do
- log =
- ReviewableActionLog.create!(
- reviewable: reviewable,
- action_key: "agree_and_keep",
- status: :approved,
- performed_by: moderator,
- bundle: "legacy-actions",
- )
-
- expect(reviewable.reviewable_action_logs).to include(log)
- expect(reviewable.reviewable_action_logs.count).to eq(1)
- end
-
- it "orders action logs by created_at ascending" do
- log1 =
- ReviewableActionLog.create!(
- reviewable: reviewable,
- action_key: "agree_and_keep",
- status: :approved,
- performed_by: moderator,
- bundle: "legacy-actions",
- )
- log2 =
- ReviewableActionLog.create!(
- reviewable: reviewable,
- action_key: "suspend_user",
- status: :rejected,
- performed_by: moderator,
- bundle: "user-actions",
- )
-
- expect(reviewable.reviewable_action_logs.to_a).to eq([log1, log2])
- end
-
- it "deletes action logs when reviewable is destroyed" do
- log =
- ReviewableActionLog.create!(
- reviewable: reviewable,
- action_key: "agree_and_keep",
- status: :approved,
- performed_by: moderator,
- bundle: "legacy-actions",
- )
-
- reviewable.destroy!
- expect(ReviewableActionLog.exists?(log.id)).to be false
- end
- end
-end
diff --git a/spec/models/reviewable_flagged_post_spec.rb b/spec/models/reviewable_flagged_post_spec.rb
index 30c99eab512..538247e6394 100644
--- a/spec/models/reviewable_flagged_post_spec.rb
+++ b/spec/models/reviewable_flagged_post_spec.rb
@@ -346,45 +346,6 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
expect(post.user_deleted?).to eq(false)
expect(post.hidden?).to eq(false)
end
-
- context "when reviewable_ui_refresh enabled (separated bundles)" do
- before do
- SiteSetting.reviewable_old_moderator_actions = false
- # Stub guardian check on reviewable to simulate feature flag on
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
- end
-
- it "builds post action bundles" do
- actions = reviewable.actions_for(guardian)
- post_bundle = actions.bundles.find { |b| b.id.ends_with?("-post-actions") }
- expect(post_bundle).to be_present
- expect(actions.has?(:no_action_post)).to eq(true)
- expect(actions.has?(:hide_post)).to eq(true)
- end
-
- it "builds user actions bundle with moderation actions" do
- actions = reviewable.actions_for(guardian)
- user_bundle = actions.bundles.find { |b| b.id.ends_with?("-user-actions") }
- expect(user_bundle).to be_present
- expect(actions.has?(:silence_user)).to eq(true)
- expect(actions.has?(:suspend_user)).to eq(true)
- expect(actions.has?(:delete_user)).to eq(true)
- end
-
- it "omits user deletion when reviewer cannot delete user" do
- allow(guardian).to receive(:can_delete_user?).and_return(false)
- actions = reviewable.actions_for(guardian)
- expect(actions.has?(:delete_user)).to eq(false)
- expect(actions.has?(:delete_and_block_user)).to eq(false)
- end
-
- it "shows unhide_post when post hidden" do
- post.update(hidden: true, hidden_at: Time.zone.now)
- actions = reviewable.actions_for(guardian)
- expect(actions.has?(:unhide_post)).to eq(true)
- expect(actions.has?(:hide_post)).to eq(false)
- end
- end
end
describe "pending count" do
diff --git a/spec/models/reviewable_post_spec.rb b/spec/models/reviewable_post_spec.rb
index 3a50fc9cd2d..72ba801b9d1 100644
--- a/spec/models/reviewable_post_spec.rb
+++ b/spec/models/reviewable_post_spec.rb
@@ -4,7 +4,6 @@ RSpec.describe ReviewablePost do
fab!(:admin)
describe "#build_actions" do
- # TODO (reviewable-refresh): Remove the tests below when the legacy combined actions are removed
let(:post) { Fabricate.build(:post) }
let(:reviewable) { ReviewablePost.new(target: post) }
let(:guardian) { Guardian.new }
@@ -60,115 +59,6 @@ RSpec.describe ReviewablePost do
actions
end
- # TODO (reviewable-refresh): Remove the tests above when the legacy combined actions are removed
-
- context "with new UI (separated post and user actions)" do
- let(:post) { Fabricate.build(:post) }
- let(:reviewable) { ReviewablePost.new(target: post, target_created_by: post.user) }
- let(:guardian) { Guardian.new }
- let(:admin_guardian) { Guardian.new(admin) }
-
- before do
- SiteSetting.reviewable_old_moderator_actions = false
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
- end
-
- it "Does not return available actions when the reviewable is no longer pending" do
- available_actions =
- (Reviewable.statuses.keys - ["pending"]).reduce([]) do |actions, status|
- reviewable.status = status
- actions.concat reviewable_actions(guardian).to_a
- end
-
- expect(available_actions).to be_empty
- end
-
- it "returns two bundles for post and user actions" do
- actions = reviewable_actions(guardian)
- bundles = actions.bundles
-
- expect(bundles.count).to eq(2)
- expect(bundles.map(&:id)).to include(
- "#{reviewable.id}-post-actions",
- "#{reviewable.id}-user-actions",
- )
- end
-
- it "includes appropriate post actions for normal posts" do
- actions = reviewable_actions(guardian)
-
- expect(actions.has?(:no_action_post)).to eq(true)
- expect(actions.has?(:hide_post)).to eq(true)
- expect(actions.has?(:edit_post)).to eq(true)
- end
-
- it "includes delete_post action for admins" do
- expect(reviewable_actions(admin_guardian).has?(:delete_post)).to eq(true)
- expect(reviewable_actions(guardian).has?(:delete_post)).to eq(false)
- end
-
- it "includes appropriate post actions for hidden posts" do
- post.hidden = true
- actions = reviewable_actions(guardian)
-
- expect(actions.has?(:no_action_post)).to eq(true)
- expect(actions.has?(:unhide_post)).to eq(true)
- expect(actions.has?(:hide_post)).to eq(false)
- end
-
- it "includes appropriate post actions for deleted posts" do
- post.deleted_at = 1.day.ago
- actions = reviewable_actions(guardian)
-
- expect(actions.has?(:no_action_post)).to eq(true)
- expect(actions.has?(:restore_post)).to eq(false) # non-admin can't restore
- end
-
- it "includes restore action for deleted posts when admin" do
- post.deleted_at = 1.day.ago
- actions = reviewable_actions(admin_guardian)
-
- expect(actions.has?(:restore_post)).to eq(false) # admin can't restore in this test setup
- end
-
- it "includes user actions when target_created_by is present" do
- actions = reviewable_actions(guardian)
-
- expect(actions.has?(:no_action_user)).to eq(true)
- end
-
- it "includes suspend and silence actions for admins" do
- actions = reviewable_actions(admin_guardian)
-
- expect(actions.has?(:suspend_user)).to eq(true)
- expect(actions.has?(:silence_user)).to eq(true)
- end
-
- it "includes delete user actions for admins" do
- actions = reviewable_actions(admin_guardian)
-
- expect(actions.has?(:delete_user)).to eq(true)
- expect(actions.has?(:delete_and_block_user)).to eq(true)
- end
-
- it "includes a minimal user actions bundle when no target_created_by" do
- reviewable.target_created_by = nil
- actions = reviewable_actions(guardian)
-
- expect(actions.has?(:no_action_user)).to eq(true)
- expect(actions.has?(:silence_user)).to eq(false)
- expect(actions.has?(:suspend_user)).to eq(false)
- expect(actions.has?(:delete_user)).to eq(false)
- expect(actions.has?(:delete_and_block_user)).to eq(false)
- end
-
- def reviewable_actions(guardian)
- actions = Reviewable::Actions.new(reviewable, guardian, {})
- reviewable.build_actions(actions, guardian, {})
-
- actions
- end
- end
end
describe "Performing actions" do
@@ -177,7 +67,6 @@ RSpec.describe ReviewablePost do
before { reviewable.created_new! }
- # TODO (reviewable-refresh): Remove the tests below when the legacy combined actions are removed
describe "#perform_approve" do
it "transitions to the approved state" do
result = reviewable.perform admin, :approve
@@ -235,112 +124,5 @@ RSpec.describe ReviewablePost do
expect(Post.where(id: post.id).exists?).to eq(false)
end
end
- # TODO (reviewable-refresh): Remove the tests above when the legacy combined actions are removed
-
- context "with new separated actions" do
- before do
- SiteSetting.reviewable_old_moderator_actions = false
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
- end
-
- describe "#perform_delete_post" do
- it "deletes the post and transitions to rejected" do
- result = reviewable.perform admin, :delete_post
-
- expect(result.transition_to).to eq :rejected
- expect(Post.where(id: post.id).exists?).to eq(false)
- end
- end
-
- describe "#perform_hide_post" do
- it "hides the post and transitions to rejected" do
- result = reviewable.perform admin, :hide_post
-
- expect(result.transition_to).to eq :rejected
- expect(post.reload.hidden).to eq(true)
- end
- end
-
- describe "#perform_unhide_post" do
- it "unhides the post and transitions to approved" do
- post.update!(hidden: true)
-
- result = reviewable.reload.perform admin, :unhide_post
-
- expect(result.transition_to).to eq :approved
- expect(post.reload.hidden).to eq(false)
- end
- end
-
- describe "#perform_no_action_post" do
- it "keeps the post and transitions to ignored" do
- result = reviewable.perform admin, :no_action_post
-
- expect(result.transition_to).to eq :ignored
- expect(Post.where(id: post.id).exists?).to eq(true)
- end
-
- it "keeps the post hidden and transitions to ignored" do
- post.update!(hidden: true)
-
- result = reviewable.reload.perform admin, :no_action_post
-
- expect(result.transition_to).to eq :ignored
- expect(post.reload.hidden).to eq(true)
- end
-
- it "keeps the post deleted and transitions to ignored" do
- post.trash!
-
- result = reviewable.reload.perform admin, :no_action_post
-
- expect(result.transition_to).to eq :ignored
- expect(Post.where(id: post.id).exists?).to eq(false)
- end
- end
-
- describe "#perform_restore_post" do
- it "restores the post and transitions to approved" do
- post.trash!
-
- result = reviewable.reload.perform admin, :restore_post
-
- expect(result.transition_to).to eq :approved
- expect(Post.where(id: post.id).exists?).to eq(true)
- end
- end
-
- describe "#perform_edit_post" do
- it "transitions to approved (actual edit is client-side)" do
- result = reviewable.perform admin, :edit_post
-
- expect(result.transition_to).to eq :approved
- end
- end
-
- describe "#perform_silence_user" do
- it "transitions to rejected" do
- result = reviewable.perform admin, :silence_user
-
- expect(result.transition_to).to eq :rejected
- end
- end
-
- describe "#perform_suspend_user" do
- it "transitions to rejected" do
- result = reviewable.perform admin, :suspend_user
-
- expect(result.transition_to).to eq :rejected
- end
- end
-
- describe "#perform_no_action_user" do
- it "transitions to ignored" do
- result = reviewable.perform admin, :no_action_user
-
- expect(result.transition_to).to eq :ignored
- end
- end
- end
end
end
diff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rb
index 28485d5e53c..f405f5d15a7 100644
--- a/spec/models/reviewable_queued_post_spec.rb
+++ b/spec/models/reviewable_queued_post_spec.rb
@@ -3,6 +3,7 @@
RSpec.describe ReviewableQueuedPost, type: :model do
fab!(:category)
fab!(:moderator) { Fabricate(:moderator, refresh_auto_groups: true) }
+ fab!(:admin)
describe "creating a post" do
let!(:topic) { Fabricate(:topic, category: category) }
@@ -393,92 +394,8 @@ RSpec.describe ReviewableQueuedPost, type: :model do
reviewable.update!(score: 10)
end
end
- end
- end
-
- describe "separated actions UI" do
- fab!(:admin)
- fab!(:user)
- let(:reviewable) { Fabricate(:reviewable_queued_post, target_created_by: user) }
-
- context "when reviewable_ui_refresh feature is enabled" do
- before do
- SiteSetting.reviewable_old_moderator_actions = false
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
- end
-
- it "creates separate bundles for post and user actions" do
- actions = reviewable.actions_for(Guardian.new(admin))
- bundle_ids = actions.bundles.map(&:id)
-
- expect(bundle_ids).to include("#{reviewable.id}-post-actions")
- expect(bundle_ids).to include("#{reviewable.id}-user-actions")
- end
-
- it "includes post actions in the post bundle" do
- actions = reviewable.actions_for(Guardian.new(admin))
-
- expect(actions.has?(:approve_post)).to eq(true)
- expect(actions.has?(:reject_post)).to eq(true)
- expect(actions.has?(:revise_and_reject_post)).to eq(true)
- end
-
- it "includes user actions in the user bundle" do
- actions = reviewable.actions_for(Guardian.new(admin))
-
- expect(actions.has?(:no_action_user)).to eq(true)
- expect(actions.has?(:silence_user)).to eq(true)
- expect(actions.has?(:suspend_user)).to eq(true)
- expect(actions.has?(:delete_user)).to eq(true)
- expect(actions.has?(:delete_and_block_user)).to eq(true)
- end
-
- it "includes a minimal user bundle when target_created_by is nil" do
- reviewable.update!(target_created_by: nil)
- actions = reviewable.actions_for(Guardian.new(admin))
-
- expect(actions.has?(:no_action_user)).to eq(true)
- expect(actions.has?(:silence_user)).to eq(false)
- expect(actions.has?(:suspend_user)).to eq(false)
- expect(actions.has?(:delete_user)).to eq(false)
- expect(actions.has?(:delete_and_block_user)).to eq(false)
- end
-
- describe "perform methods" do
- it "performs no_action_user successfully" do
- result = reviewable.perform(admin, :no_action_user)
- expect(result.success?).to eq(true)
- end
-
- it "performs silence_user successfully" do
- expect(user.silenced?).to eq(false)
- result = reviewable.perform(admin, :silence_user)
- expect(result.success?).to eq(true)
- end
-
- it "performs suspend_user successfully" do
- expect(user.suspended?).to eq(false)
- result = reviewable.perform(admin, :suspend_user)
- expect(result.success?).to eq(true)
- end
-
- it "performs delete_and_block_user successfully" do
- result = reviewable.perform(admin, :delete_and_block_user)
- expect(result.success?).to eq(true)
- expect(User.find_by(id: user.id)).to be_nil
- end
- end
- end
-
- # TODO (reviewable-refresh): Remove the tests below when the legacy combined actions are removed
- context "when reviewable_ui_refresh feature is disabled" do
- before do
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(
- false,
- )
- end
- it "uses legacy bundle structure" do
+ it "uses bundle structure" do
actions = reviewable.actions_for(Guardian.new(admin))
bundle_ids = actions.bundles.map(&:id)
@@ -487,7 +404,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
expect(bundle_ids).not_to include("#{reviewable.id}-user-actions")
end
- it "includes legacy actions" do
+ it "includes actions" do
actions = reviewable.actions_for(Guardian.new(admin))
action_ids = actions.to_a.map(&:id).map(&:to_s)
diff --git a/spec/models/reviewable_spec.rb b/spec/models/reviewable_spec.rb
index 33afebd9b1c..270ca66fc35 100644
--- a/spec/models/reviewable_spec.rb
+++ b/spec/models/reviewable_spec.rb
@@ -561,83 +561,6 @@ RSpec.describe Reviewable, type: :model do
expect(job["args"].first["reviewable_id"]).to eq(reviewable.id)
expect(job["args"].first["updated_reviewable_ids"]).to contain_exactly(reviewable.id)
end
-
- describe "action logging" do
- fab!(:guardian) { Guardian.new(moderator) }
- fab!(:reviewable, :reviewable_flagged_post)
-
- context "with new UI enabled" do
- before do
- SiteSetting.reviewable_old_moderator_actions = false
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(
- true,
- )
- end
-
- it "creates an action log" do
- expect { reviewable.perform(moderator, :edit_post, guardian: guardian) }.to change {
- reviewable.reviewable_action_logs.count
- }.by(1)
-
- log = reviewable.reviewable_action_logs.last
- expect(log.action_key).to eq("edit_post")
- expect(log.status).to eq("approved")
- expect(log.bundle).to eq("post-actions")
- expect(log.performed_by).to eq(moderator)
- end
-
- it "keeps reviewable pending when not all bundles are actioned" do
- reviewable.perform(moderator, :edit_post, guardian: guardian)
-
- reviewable.reload
- expect(reviewable.status).to eq("pending")
- expect(reviewable.reviewable_action_logs.count).to eq(1)
- end
-
- it "finalizes status when all bundles are actioned" do
- reviewable.perform(moderator, :edit_post, guardian: guardian)
- expect(reviewable.reload.status).to eq("pending")
- reviewable.perform(moderator, :suspend_user, guardian: guardian)
-
- reviewable.reload
- expect(reviewable.status).to eq("approved")
- expect(reviewable.reviewable_action_logs.count).to eq(2)
- end
-
- it "calculates correct final status for all ignored" do
- reviewable.perform(moderator, :no_action_post, guardian: guardian)
- reviewable.perform(moderator, :no_action_user, guardian: guardian)
-
- reviewable.reload
- expect(reviewable.status).to eq("ignored")
- end
-
- it "calculates correct final status for all rejected" do
- reviewable.perform(moderator, :hide_post, guardian: guardian)
- reviewable.perform(moderator, :silence_user, guardian: guardian)
-
- reviewable.reload
- expect(reviewable.status).to eq("rejected")
- end
- end
-
- context "with old UI (backward compatibility)" do
- before { SiteSetting.reviewable_old_moderator_actions = true }
-
- it "creates an action log" do
- expect { reviewable.perform(moderator, :agree_and_keep, guardian: guardian) }.to change {
- reviewable.reviewable_action_logs.count
- }.by(1)
- end
-
- it "transitions immediately (original behavior)" do
- reviewable.perform(moderator, :agree_and_keep, guardian: guardian)
-
- reviewable.reload
- expect(reviewable.status).to eq("approved")
- end
- end
- end
end
describe "flag_stats" do
diff --git a/spec/models/reviewable_user_spec.rb b/spec/models/reviewable_user_spec.rb
index 17e73bbd63c..99ca11aebfb 100644
--- a/spec/models/reviewable_user_spec.rb
+++ b/spec/models/reviewable_user_spec.rb
@@ -329,17 +329,4 @@ RSpec.describe ReviewableUser, type: :model do
end
end
end
- describe "#build_new_separated_actions" do
- fab!(:reviewable)
-
- it "returns correct actions in the pending state" do
- reviewable.actions_for(Guardian.new(moderator))
- expect(reviewable.build_new_separated_actions.actions.map(&:id)).to eq(
- %w[user-approve_user user-delete_user user-delete_user_block],
- )
-
- reviewable.update!(status: Reviewable.statuses[:rejected])
- expect(reviewable.build_new_separated_actions.actions.map(&:id)).to eq(%w[user-scrub])
- end
- end
end
diff --git a/spec/serializers/reviewable_user_serializer_spec.rb b/spec/serializers/reviewable_user_serializer_spec.rb
index 51fbad638ce..5b0fc77f2a9 100644
--- a/spec/serializers/reviewable_user_serializer_spec.rb
+++ b/spec/serializers/reviewable_user_serializer_spec.rb
@@ -63,9 +63,7 @@ RSpec.describe ReviewableUserSerializer do
expect(json[:target_user]).to be_nil
end
- it "returns FlaggedUserSerializer when user can see reviewable UI refresh" do
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
-
+ it "returns FlaggedUserSerializer when there is a target" do
json = ReviewableUserSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
expect(json[:target_user]).to be_present
expect(json[:target_user][:id]).to eq(user.id)
diff --git a/spec/services/review/calculate_final_status_from_logs_spec.rb b/spec/services/review/calculate_final_status_from_logs_spec.rb
deleted file mode 100644
index 513a8d3a4ab..00000000000
--- a/spec/services/review/calculate_final_status_from_logs_spec.rb
+++ /dev/null
@@ -1,146 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe Review::CalculateFinalStatusFromLogs do
- describe ".call" do
- fab!(:moderator)
- fab!(:user)
- fab!(:reviewable_user) { ReviewableUser.create_for(user) }
- fab!(:reviewable, :reviewable_flagged_post)
- let(:guardian) { Guardian.new(moderator) }
-
- before do
- SiteSetting.reviewable_old_moderator_actions = false
- allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
- end
-
- context "when all bundles are actioned" do
- fab!(:reviewable_deleted, :reviewable_queued_post)
-
- it "returns deleted when a log has deleted statuses" do
- reviewable_deleted.reviewable_action_logs.create!(
- action_key: "delete",
- status: :deleted,
- performed_by: moderator,
- bundle: "post-actions",
- )
- reviewable_deleted.reviewable_action_logs.create!(
- action_key: "no_action_user",
- status: :ignored,
- performed_by: moderator,
- bundle: "user-actions",
- )
-
- result =
- described_class.call(params: { reviewable_id: reviewable_deleted.id, guardian: guardian })
- expect(result).to be_a_success
- expect(result.status).to eq(:deleted)
- end
-
- it "returns ignored status when all logs are ignored" do
- reviewable.reviewable_action_logs.create!(
- action_key: "ignore_and_do_nothing",
- status: :ignored,
- performed_by: moderator,
- bundle: "post-actions",
- )
- reviewable.reviewable_action_logs.create!(
- action_key: "no_action_user",
- status: :ignored,
- performed_by: moderator,
- bundle: "user-actions",
- )
-
- result = described_class.call(params: { reviewable_id: reviewable.id, guardian: guardian })
- expect(result).to be_a_success
- expect(result.status).to eq(:ignored)
- end
-
- it "returns rejected status when all logs are rejected" do
- reviewable.reviewable_action_logs.create!(
- action_key: "hide_post",
- status: :rejected,
- performed_by: moderator,
- bundle: "post-actions",
- )
- reviewable.reviewable_action_logs.create!(
- action_key: "suspend_user",
- status: :rejected,
- performed_by: moderator,
- bundle: "user-actions",
- )
-
- result = described_class.call(params: { reviewable_id: reviewable.id, guardian: guardian })
- expect(result).to be_a_success
- expect(result.status).to eq(:rejected)
- end
-
- it "returns approved status when any log is approved" do
- reviewable.reviewable_action_logs.create!(
- action_key: "agree_and_keep",
- status: :approved,
- performed_by: moderator,
- bundle: "post-actions",
- )
- reviewable.reviewable_action_logs.create!(
- action_key: "suspend_user",
- status: :rejected,
- performed_by: moderator,
- bundle: "user-actions",
- )
-
- result = described_class.call(params: { reviewable_id: reviewable.id, guardian: guardian })
- expect(result).to be_a_success
- expect(result.status).to eq(:approved)
- end
-
- it "returns rejected status when logs have mixed rejected and ignored statuses" do
- reviewable.reviewable_action_logs.create!(
- action_key: "hide_post",
- status: :rejected,
- performed_by: moderator,
- bundle: "post-actions",
- )
- reviewable.reviewable_action_logs.create!(
- action_key: "no_action_user",
- status: :ignored,
- performed_by: moderator,
- bundle: "user-actions",
- )
-
- result = described_class.call(params: { reviewable_id: reviewable.id, guardian: guardian })
- expect(result).to be_a_success
- expect(result.status).to eq(:rejected)
- end
- end
- it "succeeds for reviewable with single bundle" do
- reviewable_user.reviewable_action_logs.create!(
- action_key: "approve_user",
- status: :approved,
- performed_by: moderator,
- bundle: "user-actions",
- )
-
- result =
- described_class.call(params: { reviewable_id: reviewable_user.id, guardian: guardian })
- expect(result).to be_a_success
- expect(result.status).to eq(:approved)
- end
-
- it "fails when not all bundles are actioned" do
- reviewable.reviewable_action_logs.create!(
- action_key: "edit_post",
- status: :approved,
- performed_by: moderator,
- bundle: "post-actions",
- )
-
- result = described_class.call(params: { reviewable_id: reviewable.id, guardian: guardian })
- expect(result).to be_a_failure
- end
-
- it "fails when no logs exist" do
- result = described_class.call(params: { reviewable_id: reviewable.id, guardian: guardian })
- expect(result).to be_a_failure
- end
- end
-end
diff --git a/spec/system/flagging_post_spec.rb b/spec/system/flagging_post_spec.rb
index a8f23888d9b..679ed979ff3 100644
--- a/spec/system/flagging_post_spec.rb
+++ b/spec/system/flagging_post_spec.rb
@@ -10,7 +10,7 @@ describe "Flagging post", type: :system do
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:flag_modal) { PageObjects::Modals::Flag.new }
let(:silence_user_modal) { PageObjects::Modals::PenalizeUser.new("silence") }
- let(:refreshed_review_page) { PageObjects::Pages::RefreshedReview.new }
+ let(:review_page) { PageObjects::Pages::Review.new }
describe "Using Take Action" do
before { sign_in(current_user) }
@@ -32,7 +32,7 @@ describe "Flagging post", type: :system do
visit "/review/#{other_flag_reviewable.id}"
- expect(refreshed_review_page).to have_reviewable_with_approved_status(other_flag_reviewable)
+ expect(review_page).to have_reviewable_with_approved_status(other_flag_reviewable)
end
it "can choose to immediately silence the user" do
@@ -56,7 +56,7 @@ describe "Flagging post", type: :system do
visit "/review/#{Reviewable.sole.id}"
- expect(refreshed_review_page).to have_reviewable_with_approved_status(Reviewable.sole)
+ expect(review_page).to have_reviewable_with_approved_status(Reviewable.sole)
end
end
diff --git a/spec/system/page_objects/pages/review.rb b/spec/system/page_objects/pages/review.rb
index fc1f4ac7fd0..5331fe342bf 100644
--- a/spec/system/page_objects/pages/review.rb
+++ b/spec/system/page_objects/pages/review.rb
@@ -24,10 +24,6 @@ module PageObjects
end
end
- def reviewable_by_id(id)
- find(".reviewable-item[data-reviewable-id=\"#{id}\"]")
- end
-
def click_post_body_toggle
find(POST_BODY_TOGGLE_SELECTOR).click
end
@@ -56,18 +52,10 @@ module PageObjects
page.has_no_css?(REVIEWABLE_ACTION_DROPDOWN)
end
- def has_reviewable_with_pending_status?(reviewable)
- within(reviewable_by_id(reviewable.id)) { page.has_css?(".status .pending") }
- end
-
def has_reviewable_items?(count:)
page.has_css?(".review-item", count: count)
end
- def has_reviewable_with_rejected_status?(reviewable)
- within(reviewable_by_id(reviewable.id)) { page.has_css?(".status .rejected") }
- end
-
def has_reviewable_with_rejection_reason?(reviewable, rejection_reason)
reviewable_by_id(reviewable.id).has_css?(
".reviewable-user-details.reject-reason .value",
@@ -83,8 +71,8 @@ module PageObjects
within(reviewable_by_id(reviewable.id)) { page.has_no_css?(".scrub-rejected-user button") }
end
- def click_scrub_button(reviewable)
- within(reviewable_by_id(reviewable.id)) { find(".scrub-rejected-user button").click }
+ def click_scrub_user_button
+ find(".user-scrub").click
end
def has_reviewable_with_scrubbed_by?(reviewable, scrubbed_by)
@@ -150,6 +138,12 @@ module PageObjects
find(".reviewable-claimed-topic .unclaim").click
end
+ def has_context_question?(reviewable, text)
+ within(reviewable_by_id(reviewable.id)) do
+ page.has_css?(".review-item__aside-title", text: text)
+ end
+ end
+
def flag_reason_component
PageObjects::Components::Review::FlagReason.new
end
@@ -158,8 +152,113 @@ module PageObjects
PageObjects::Components::Review::TopicLink.new
end
+ def has_history_items?(count:)
+ expect(page).to have_css(".timeline-event", count: count)
+ end
+
+ def has_claimed_history_item?(user)
+ expect(page).to have_css(".timeline-event__icon .d-icon-user-plus")
+ expect(page).to have_text("Claimed by")
+ end
+
+ def has_unclaimed_history_item?(user)
+ expect(page).to have_css(".timeline-event__icon .d-icon-user-xmark")
+ expect(page).to have_text("Unclaimed by")
+ end
+
+ def has_created_at_history_item?
+ expect(page).to have_css(".timeline-event__icon .d-icon-pen-to-square")
+ expect(page).to have_text("Post created by")
+ end
+
+ def click_timeline_tab
+ find(".action-list li.timeline").click
+ end
+
+ def click_insights_tab
+ find(".action-list li.insights").click
+ end
+
+ def has_reviewable_with_approved_status?(reviewable)
+ within(reviewable_by_id(reviewable.id)) { page.has_css?(".review-item__status.--approved") }
+ end
+
+ def has_reviewable_with_rejected_status?(reviewable)
+ within(reviewable_by_id(reviewable.id)) { page.has_css?(".review-item__status.--rejected") }
+ end
+
+ def has_rejected_item_in_timeline?(reviewable)
+ within(reviewable_by_id(reviewable.id)) { page.has_text?("Rejected by") }
+ end
+
+ def has_reviewable_with_pending_status?(reviewable)
+ within(reviewable_by_id(reviewable.id)) { page.has_css?(".review-item__status.--pending") }
+ end
+
+ def has_reviewable_with_ignored_status?(reviewable)
+ within(reviewable_by_id(reviewable.id)) { page.has_css?(".review-item__status.--ignored") }
+ end
+
+ def has_approved_item_in_timeline?(reviewable)
+ within(reviewable_by_id(reviewable.id)) { page.has_text?("Approved by") }
+ end
+
+ def has_reviewables?(reviewables)
+ reviewable_ids = reviewables.map(&:id)
+ page.has_css?(".review-item", count: reviewables.size) &&
+ reviewable_ids.all? { |id| page.has_css?(".review-item[data-reviewable-id='#{id}']") }
+ end
+
+ def click_approve_user_button
+ find(".user-approve-user").click
+ end
+
+ def fill_post_content(content)
+ find(".d-editor-input").fill_in(with: content)
+ end
+
+ def save_post_edit
+ find(".reviewable-action.save-edit").click
+ end
+
+ def has_ip_lookup_info?
+ page.has_css?(".reviewable-ip-lookup")
+ end
+
+ def has_ip_location?(location)
+ page.has_text?(location)
+ end
+
+ def has_ip_hostname?(hostname)
+ page.has_text?(hostname)
+ end
+
+ def has_ip_lookup_modal?
+ page.has_css?(".ip-lookup-other-accounts-modal")
+ end
+
+ def has_account_in_modal?(username)
+ within(".ip-lookup-other-accounts-modal") { page.has_text?(username) }
+ end
+
+ def has_other_accounts_link?(count:)
+ page.has_button?(I18n.t("js.ip_lookup.other_accounts_with_ip", count: count))
+ end
+
+ def click_other_accounts_link
+ find(".ip-lookup-other-accounts-link").click
+ end
+
+ def click_edit_post_button
+ find(".reviewable-action.edit").click
+ end
+
private
+ def reviewable_by_id(id)
+ find(".review-item[data-reviewable-id=\"#{id}\"]")
+ end
+
def reviewable_action_dropdown
@reviewable_action_dropdown ||=
PageObjects::Components::SelectKit.new(REVIEWABLE_ACTION_DROPDOWN)
diff --git a/spec/system/reviewables_spec.rb b/spec/system/reviewables_spec.rb
index 1934651e2c3..8dbe0d28e3f 100644
--- a/spec/system/reviewables_spec.rb
+++ b/spec/system/reviewables_spec.rb
@@ -2,7 +2,6 @@
describe "Reviewables", type: :system do
let(:review_page) { PageObjects::Pages::Review.new }
- let(:refreshed_review_page) { PageObjects::Pages::RefreshedReview.new }
fab!(:admin)
fab!(:theme)
fab!(:long_post, :post_with_very_long_raw_content)
@@ -110,17 +109,13 @@ describe "Reviewables", type: :system do
# cache it for later assertion instead of querying UserHistory
user_email = user.email
- refreshed_review_page.visit_reviewable(reviewable)
- refreshed_review_page.select_bundled_action(
- reviewable,
- "user-delete_user",
- "user-delete-user",
- )
+ review_page.visit_reviewable(reviewable)
+ review_page.select_bundled_action(reviewable, "user-delete_user")
rejection_reason_modal.fill_in_rejection_reason(rejection_reason)
rejection_reason_modal.select_send_rejection_email_checkbox
rejection_reason_modal.delete_user
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)
+ expect(review_page).to have_reviewable_with_rejected_status(reviewable)
mail = ActionMailer::Base.deliveries.first
expect(mail.to).to eq([user_email])
@@ -133,30 +128,23 @@ describe "Reviewables", type: :system do
scrubbing_reason = "a spammer who knows how to make GDPR requests"
reviewable = ReviewableUser.find_by_target_id(user.id)
- refreshed_review_page.visit_reviewable(reviewable)
- refreshed_review_page.select_bundled_action(
- reviewable,
- "user-delete_user",
- "user-delete-user",
- )
+ review_page.visit_reviewable(reviewable)
+ review_page.select_bundled_action(reviewable, "user-delete_user")
rejection_reason_modal.fill_in_rejection_reason(rejection_reason)
rejection_reason_modal.delete_user
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)
+ expect(review_page).to have_reviewable_with_rejected_status(reviewable)
- refreshed_review_page.click_scrub_user_button
+ review_page.click_scrub_user_button
expect(scrub_user_modal.scrub_button).to be_disabled
scrub_user_modal.fill_in_scrub_reason(scrubbing_reason)
expect(scrub_user_modal.scrub_button).not_to be_disabled
scrub_user_modal.scrub_button.click
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_by(reviewable, admin.username)
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_reason(
- reviewable,
- scrubbing_reason,
- )
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_at(
+ expect(review_page).to have_reviewable_with_scrubbed_by(reviewable, admin.username)
+ expect(review_page).to have_reviewable_with_scrubbed_reason(reviewable, scrubbing_reason)
+ expect(review_page).to have_reviewable_with_scrubbed_at(
reviewable,
reviewable.payload["scrubbed_at"],
)
@@ -176,22 +164,16 @@ describe "Reviewables", type: :system do
fab!(:queued_post_reviewable, :reviewable_queued_post)
it "delete_user does not delete reviewable" do
- refreshed_review_page.visit_reviewable(queued_post_reviewable)
+ review_page.visit_reviewable(queued_post_reviewable)
expect(queued_post_reviewable).to be_pending
expect(queued_post_reviewable.target_created_by).to be_present
- expect(refreshed_review_page).to have_reviewable_with_pending_status(queued_post_reviewable)
+ expect(review_page).to have_reviewable_with_pending_status(queued_post_reviewable)
- refreshed_review_page.select_bundled_action(
- queued_post_reviewable,
- "delete_user",
- "reject-post",
- )
+ review_page.select_bundled_action(queued_post_reviewable, "delete_user")
expect(review_page).to have_no_error_dialog_visible
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(
- queued_post_reviewable,
- )
+ expect(review_page).to have_reviewable_with_rejected_status(queued_post_reviewable)
expect(review_page).to have_no_reviewable_action_dropdown
expect(queued_post_reviewable.reload).to be_rejected
expect(queued_post_reviewable.target_created_by).to be_nil
@@ -200,16 +182,12 @@ describe "Reviewables", type: :system do
it "allows revising and rejecting to send a PM to the user" do
revise_modal = PageObjects::Modals::Base.new
- refreshed_review_page.visit_reviewable(queued_post_reviewable)
+ review_page.visit_reviewable(queued_post_reviewable)
expect(queued_post_reviewable).to be_pending
expect(queued_post_reviewable.target_created_by).to be_present
- refreshed_review_page.select_bundled_action(
- queued_post_reviewable,
- "revise_and_reject_post",
- "reject-post",
- )
+ review_page.select_bundled_action(queued_post_reviewable, "revise_and_reject_post")
expect(revise_modal).to be_open
@@ -219,9 +197,7 @@ describe "Reviewables", type: :system do
find(".revise-and-reject-reviewable__feedback").fill_in(with: "This is a test")
revise_modal.click_primary_button
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(
- queued_post_reviewable,
- )
+ expect(review_page).to have_reviewable_with_rejected_status(queued_post_reviewable)
expect(queued_post_reviewable.reload).to be_rejected
topic = Topic.where(archetype: Archetype.private_message).last
@@ -238,16 +214,12 @@ describe "Reviewables", type: :system do
it "allows selecting a custom reason for revise and reject" do
revise_modal = PageObjects::Modals::Base.new
- refreshed_review_page.visit_reviewable(queued_post_reviewable)
+ review_page.visit_reviewable(queued_post_reviewable)
expect(queued_post_reviewable).to be_pending
expect(queued_post_reviewable.target_created_by).to be_present
- refreshed_review_page.select_bundled_action(
- queued_post_reviewable,
- "revise_and_reject_post",
- "reject-post",
- )
+ review_page.select_bundled_action(queued_post_reviewable, "revise_and_reject_post")
expect(revise_modal).to be_open
reason_dropdown =
@@ -257,9 +229,7 @@ describe "Reviewables", type: :system do
find(".revise-and-reject-reviewable__feedback").fill_in(with: "This is a test")
revise_modal.click_primary_button
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(
- queued_post_reviewable,
- )
+ expect(review_page).to have_reviewable_with_rejected_status(queued_post_reviewable)
end
context "with reviewable claiming enabled" do
@@ -317,11 +287,7 @@ describe "Reviewables", type: :system do
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:reviewable, :reviewable_queued_post)
- before do
- SiteSetting.reviewable_old_moderator_actions = false
- SiteSetting.reviewable_ui_refresh = group.name
- group.add(admin)
- end
+ before { group.add(admin) }
it "displays the custom guide topic link when configured" do
SiteSetting.moderator_guide_topic = topic.id
diff --git a/spec/system/user_page/staff_info_spec.rb b/spec/system/user_page/staff_info_spec.rb
index e9a22d6115d..b8a9c502206 100644
--- a/spec/system/user_page/staff_info_spec.rb
+++ b/spec/system/user_page/staff_info_spec.rb
@@ -43,7 +43,7 @@ describe "Viewing user staff info as an admin", type: :system do
fab!(:reviewable_flagged_post) { Fabricate(:reviewable_flagged_post, target_created_by: user) }
fab!(:reviewable_queued_post) { Fabricate(:reviewable_queued_post, target_created_by: user) }
- let(:review_page) { PageObjects::Pages::RefreshedReview.new }
+ let(:review_page) { PageObjects::Pages::Review.new }
it "shows count and links to review queue for all reviewable types" do
user_page.visit(user)
diff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rb
index 43387ff4355..446191d0090 100644
--- a/spec/system/viewing_reviewable_spec.rb
+++ b/spec/system/viewing_reviewable_spec.rb
@@ -14,426 +14,365 @@ describe "Viewing reviewable item", type: :system do
end
let(:review_page) { PageObjects::Pages::Review.new }
- let(:refreshed_review_page) { PageObjects::Pages::RefreshedReview.new }
let(:review_note_form) { PageObjects::Components::ReviewNoteForm.new }
- describe "when user is part of the groups list of the `reviewable_ui_refresh` site setting" do
- before do
- SiteSetting.reviewable_ui_refresh = group.name
- SiteSetting.reviewable_old_moderator_actions = false
- group.add(admin)
- sign_in(admin)
- end
-
- describe "when the reviewable item is a flagged post" do
- it "shows the new reviewable UI" do
- review_page.visit_reviewable(reviewable_flagged_post)
-
- expect(page).to have_selector(".review-container")
- end
-
- it "shows the reviewable item with badges stating the flag reason and count" do
- _spam_reviewable_score =
- Fabricate(
- :reviewable_score,
- reviewable: reviewable_flagged_post,
- reviewable_score_type: ReviewableScore.types[:spam],
- )
-
- _off_topic_reviewable_score =
- Fabricate(
- :reviewable_score,
- reviewable: reviewable_flagged_post,
- reviewable_score_type: ReviewableScore.types[:off_topic],
- )
+ before do
+ group.add(admin)
+ sign_in(admin)
+ end
- _illegal_reviewable_score =
- Fabricate(
- :reviewable_score,
- reviewable: reviewable_flagged_post,
- reviewable_score_type: ReviewableScore.types[:illegal],
- )
+ describe "when the reviewable item is a flagged post" do
+ it "shows the new reviewable UI" do
+ review_page.visit_reviewable(reviewable_flagged_post)
- _inappropriate_reviewable_score =
- Fabricate(
- :reviewable_score,
- reviewable: reviewable_flagged_post,
- reviewable_score_type: ReviewableScore.types[:inappropriate],
- )
-
- _needs_approval_reviewable_score =
- Fabricate(
- :reviewable_score,
- reviewable: reviewable_flagged_post,
- reviewable_score_type: ReviewableScore.types[:needs_approval],
- )
+ expect(page).to have_selector(".review-container")
+ end
- flag_reason_component =
- review_page.visit_reviewable(reviewable_flagged_post).flag_reason_component
+ it "shows the reviewable item with badges stating the flag reason and count" do
+ _spam_reviewable_score =
+ Fabricate(
+ :reviewable_score,
+ reviewable: reviewable_flagged_post,
+ reviewable_score_type: ReviewableScore.types[:spam],
+ )
- expect(flag_reason_component).to have_spam_flag_reason(reviewable_flagged_post, count: 1)
- expect(flag_reason_component).to have_off_topic_flag_reason(
- reviewable_flagged_post,
- count: 1,
+ _off_topic_reviewable_score =
+ Fabricate(
+ :reviewable_score,
+ reviewable: reviewable_flagged_post,
+ reviewable_score_type: ReviewableScore.types[:off_topic],
)
- expect(flag_reason_component).to have_illegal_flag_reason(reviewable_flagged_post, count: 1)
- expect(flag_reason_component).to have_inappropriate_flag_reason(
- reviewable_flagged_post,
- count: 2,
+ _illegal_reviewable_score =
+ Fabricate(
+ :reviewable_score,
+ reviewable: reviewable_flagged_post,
+ reviewable_score_type: ReviewableScore.types[:illegal],
)
- expect(flag_reason_component).to have_needs_approval_flag_reason(
- reviewable_flagged_post,
- count: 1,
+ _inappropriate_reviewable_score =
+ Fabricate(
+ :reviewable_score,
+ reviewable: reviewable_flagged_post,
+ reviewable_score_type: ReviewableScore.types[:inappropriate],
)
- end
- it "shows the topic status, title link, category badge and tags of the topic associated with the reviewable item correctly" do
- post = reviewable_flagged_post.post
- topic = reviewable_flagged_post.topic
- category = Fabricate(:category)
- topic.change_category_to_id(category.id)
- tag_1 = Fabricate(:tag)
- tag_2 = Fabricate(:tag)
- topic.tags = [tag_1, tag_2]
- topic.closed = true
- topic.save!
-
- topic_link_component =
- review_page.visit_reviewable(reviewable_flagged_post).topic_link_component
-
- expect(topic_link_component).to have_closed_topic_status
-
- expect(topic_link_component).to have_topic_link(
- topic_title: topic.title,
- post_url: post.full_url,
+ _needs_approval_reviewable_score =
+ Fabricate(
+ :reviewable_score,
+ reviewable: reviewable_flagged_post,
+ reviewable_score_type: ReviewableScore.types[:needs_approval],
)
- expect(topic_link_component).to have_category_badge(category.name)
- expect(topic_link_component).to have_tag_link(tag_name: tag_1.name, tag_url: tag_1.url)
- expect(topic_link_component).to have_tag_link(tag_name: tag_2.name, tag_url: tag_2.url)
+ flag_reason_component =
+ review_page.visit_reviewable(reviewable_flagged_post).flag_reason_component
- # TODO: Add test for watched words highlighting
- end
+ expect(flag_reason_component).to have_spam_flag_reason(reviewable_flagged_post, count: 1)
+ expect(flag_reason_component).to have_off_topic_flag_reason(reviewable_flagged_post, count: 1)
+ expect(flag_reason_component).to have_illegal_flag_reason(reviewable_flagged_post, count: 1)
- it "allows to add notes and persists them when toggle tabs" do
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_timeline_tab
- review_note_form.add_note("This is a review note.")
- refreshed_review_page.click_insights_tab
- refreshed_review_page.click_timeline_tab
- expect(page).to have_text("This is a review note.")
- end
+ expect(flag_reason_component).to have_inappropriate_flag_reason(
+ reviewable_flagged_post,
+ count: 2,
+ )
- it "shows confirmation dialog when navigating away with unsaved note, but not after clearing the note" do
- dialog = PageObjects::Components::Dialog.new
+ expect(flag_reason_component).to have_needs_approval_flag_reason(
+ reviewable_flagged_post,
+ count: 1,
+ )
+ end
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_timeline_tab
+ it "shows the topic status, title link, category badge and tags of the topic associated with the reviewable item correctly" do
+ post = reviewable_flagged_post.post
+ topic = reviewable_flagged_post.topic
+ category = Fabricate(:category)
+ topic.change_category_to_id(category.id)
+ tag_1 = Fabricate(:tag)
+ tag_2 = Fabricate(:tag)
+ topic.tags = [tag_1, tag_2]
+ topic.closed = true
+ topic.save!
- review_note_form.form.fill_in("content", with: "This is a draft note")
+ topic_link_component =
+ review_page.visit_reviewable(reviewable_flagged_post).topic_link_component
- click_logo
+ expect(topic_link_component).to have_closed_topic_status
- expect(dialog).to be_open
- expect(dialog).to have_content(I18n.t("js.form_kit.dirty_form"))
+ expect(topic_link_component).to have_topic_link(
+ topic_title: topic.title,
+ post_url: post.full_url,
+ )
- dialog.click_no
+ expect(topic_link_component).to have_category_badge(category.name)
+ expect(topic_link_component).to have_tag_link(tag_name: tag_1.name, tag_url: tag_1.url)
+ expect(topic_link_component).to have_tag_link(tag_name: tag_2.name, tag_url: tag_2.url)
- expect(page).to have_current_path("/review/#{reviewable_flagged_post.id}")
+ # TODO: Add test for watched words highlighting
+ end
- review_note_form.form.fill_in("content", with: "")
+ it "allows to add notes and persists them when toggle tabs" do
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_timeline_tab
+ review_note_form.add_note("This is a review note.")
+ review_page.click_insights_tab
+ review_page.click_timeline_tab
+ expect(page).to have_text("This is a review note.")
+ end
- click_logo
+ it "shows confirmation dialog when navigating away with unsaved note, but not after clearing the note" do
+ dialog = PageObjects::Components::Dialog.new
- expect(dialog).to be_closed
- expect(page).to have_current_path("/")
- end
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_timeline_tab
- it "displays the flagged user's email address in user activity" do
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_insights_tab
+ review_note_form.form.fill_in("content", with: "This is a draft note")
- expect(page).to have_text("[email protected]")
- end
+ click_logo
- describe "Moderation history" do
- fab!(:flagged_user) { reviewable_flagged_post.target_created_by }
+ expect(dialog).to be_open
+ expect(dialog).to have_content(I18n.t("js.form_kit.dirty_form"))
- it "displays the number of times the user has been silenced, suspended and number of rejected posts" do
- UserHistory.create!(
- action: UserHistory.actions[:silence_user],
- target_user_id: flagged_user.id,
- acting_user_id: admin.id,
- )
- UserHistory.create!(
- action: UserHistory.actions[:silence_user],
- target_user_id: flagged_user.id,
- acting_user_id: admin.id,
- )
- UserHistory.create!(
- action: UserHistory.actions[:suspend_user],
- target_user_id: flagged_user.id,
- acting_user_id: admin.id,
- )
- ReviewableQueuedPost.create!(
- created_by: admin,
- target_created_by: flagged_user,
- status: Reviewable.statuses[:rejected],
- payload: {
- raw: "test post 1",
- },
- )
- ReviewableQueuedPost.create!(
- created_by: admin,
- target_created_by: flagged_user,
- status: Reviewable.statuses[:rejected],
- payload: {
- raw: "test post 2",
- },
- )
+ dialog.click_no
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_insights_tab
-
- expect(page).to have_text(
- I18n.t("js.review.insights.moderation_history.silenced", count: 2),
- )
- expect(page).to have_text(
- I18n.t("js.review.insights.moderation_history.suspended", count: 1),
- )
- expect(page).to have_text(
- I18n.t("js.review.insights.moderation_history.rejected_posts", count: 2),
- )
- end
- end
+ expect(page).to have_current_path("/review/#{reviewable_flagged_post.id}")
- describe "IP lookup" do
- fab!(:reviewable_flagged_post)
+ review_note_form.form.fill_in("content", with: "")
- before do
- reviewable_flagged_post.target_created_by.update!(ip_address: "81.2.69.142")
-
- DiscourseIpInfo.open_db(File.join(Rails.root, "spec", "fixtures", "mmdb"))
- Resolv::DNS
- .any_instance
- .stubs(:getname)
- .with("81.2.69.142")
- .returns("ip-81-2-69-142.example.com")
- end
+ click_logo
- it "shows IP lookup information when insights tab is viewed" do
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_insights_tab
+ expect(dialog).to be_closed
+ expect(page).to have_current_path("/")
+ end
- expect(refreshed_review_page).to have_ip_lookup_info
- end
+ it "displays the flagged user's email address in user activity" do
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_insights_tab
- it "displays IP location, hostname, and organization when available" do
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_insights_tab
+ expect(page).to have_text("[email protected]")
+ end
- expect(refreshed_review_page).to have_ip_location("London, England, United Kingdom")
- expect(refreshed_review_page).to have_ip_hostname("ip-81-2-69-142.example.com")
- end
+ describe "Moderation history" do
+ fab!(:flagged_user) { reviewable_flagged_post.target_created_by }
- it "shows other accounts link when there are multiple accounts with same IP" do
- other_user_1 = Fabricate(:user, ip_address: "81.2.69.142")
- other_user_2 = Fabricate(:user, ip_address: "81.2.69.142")
+ it "displays the number of times the user has been silenced, suspended and number of rejected posts" do
+ UserHistory.create!(
+ action: UserHistory.actions[:silence_user],
+ target_user_id: flagged_user.id,
+ acting_user_id: admin.id,
+ )
+ UserHistory.create!(
+ action: UserHistory.actions[:silence_user],
+ target_user_id: flagged_user.id,
+ acting_user_id: admin.id,
+ )
+ UserHistory.create!(
+ action: UserHistory.actions[:suspend_user],
+ target_user_id: flagged_user.id,
+ acting_user_id: admin.id,
+ )
+ ReviewableQueuedPost.create!(
+ created_by: admin,
+ target_created_by: flagged_user,
+ status: Reviewable.statuses[:rejected],
+ payload: {
+ raw: "test post 1",
+ },
+ )
+ ReviewableQueuedPost.create!(
+ created_by: admin,
+ target_created_by: flagged_user,
+ status: Reviewable.statuses[:rejected],
+ payload: {
+ raw: "test post 2",
+ },
+ )
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_insights_tab
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_insights_tab
- expect(refreshed_review_page).to have_other_accounts_link(count: 2)
- end
+ expect(page).to have_text(
+ I18n.t("js.review.insights.moderation_history.silenced", count: 2),
+ )
+ expect(page).to have_text(
+ I18n.t("js.review.insights.moderation_history.suspended", count: 1),
+ )
+ expect(page).to have_text(
+ I18n.t("js.review.insights.moderation_history.rejected_posts", count: 2),
+ )
+ end
+ end
- it "opens modal with account list when clicking other accounts link" do
- other_user = Fabricate(:user, username: "suspicious_user", ip_address: "81.2.69.142")
+ describe "IP lookup" do
+ fab!(:reviewable_flagged_post)
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_insights_tab
- refreshed_review_page.click_other_accounts_link
+ before do
+ reviewable_flagged_post.target_created_by.update!(ip_address: "81.2.69.142")
+
+ DiscourseIpInfo.open_db(File.join(Rails.root, "spec", "fixtures", "mmdb"))
+ Resolv::DNS
+ .any_instance
+ .stubs(:getname)
+ .with("81.2.69.142")
+ .returns("ip-81-2-69-142.example.com")
+ end
- expect(refreshed_review_page).to have_ip_lookup_modal
- expect(refreshed_review_page).to have_account_in_modal(other_user.username)
- end
+ it "shows IP lookup information when insights tab is viewed" do
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_insights_tab
- context "when category moderator" do
- fab!(:category)
- fab!(:trust_level_1_user, :trust_level_1)
- fab!(:category_moderation_group) do
- Fabricate(
- :category_moderation_group,
- category: category,
- group: trust_level_1_user.groups.last,
- )
- end
-
- before do
- SiteSetting.enable_category_group_moderation = true
- reviewable_flagged_post.topic.change_category_to_id(category.id)
- sign_in trust_level_1_user
- end
-
- it "does not show IP information" do
- visit "/"
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- refreshed_review_page.click_insights_tab
-
- expect(page).not_to have_text("The requested URL or resource could not be found.")
- end
- end
+ expect(review_page).to have_ip_lookup_info
end
- end
- describe "when the reviewable item is a queued post" do
- fab!(:reviewable_queued_post)
+ it "displays IP location, hostname, and organization when available" do
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_insights_tab
- it "allows to edit post when old moderator actions are enabled" do
- SiteSetting.reviewable_old_moderator_actions = true
- refreshed_review_page.visit_reviewable(reviewable_queued_post)
+ expect(review_page).to have_ip_location("London, England, United Kingdom")
+ expect(review_page).to have_ip_hostname("ip-81-2-69-142.example.com")
+ end
- expect(page).to have_text("hello world post contents.")
- refreshed_review_page.click_edit_post_button
- refreshed_review_page.fill_post_content("Hello world from system spec!")
- refreshed_review_page.save_post_edit
+ it "shows other accounts link when there are multiple accounts with same IP" do
+ other_user_1 = Fabricate(:user, ip_address: "81.2.69.142")
+ other_user_2 = Fabricate(:user, ip_address: "81.2.69.142")
- expect(page).to have_text("Hello world from system spec!")
- expect(page).not_to have_text("hello world post contents.")
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_insights_tab
+
+ expect(review_page).to have_other_accounts_link(count: 2)
end
- it "shows context question for rejected queued post" do
- reviewable_queued_post.update!(status: Reviewable.statuses[:rejected])
+ it "opens modal with account list when clicking other accounts link" do
+ other_user = Fabricate(:user, username: "suspicious_user", ip_address: "81.2.69.142")
- refreshed_review_page.visit_reviewable(reviewable_queued_post)
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_insights_tab
+ review_page.click_other_accounts_link
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(
- reviewable_queued_post,
- )
- expect(refreshed_review_page).to have_context_question(
- reviewable_queued_post,
- I18n.t("js.review.context_question.approve_post"),
- )
+ expect(review_page).to have_ip_lookup_modal
+ expect(review_page).to have_account_in_modal(other_user.username)
end
- end
- describe "when the reviewable item is a user" do
- fab!(:user)
- let(:rejection_reason_modal) { PageObjects::Modals::RejectReasonReviewable.new }
- let(:scrub_user_modal) { PageObjects::Modals::ScrubRejectedUser.new }
+ context "when category moderator" do
+ fab!(:category)
+ fab!(:trust_level_1_user, :trust_level_1)
+ fab!(:category_moderation_group) do
+ Fabricate(
+ :category_moderation_group,
+ category: category,
+ group: trust_level_1_user.groups.last,
+ )
+ end
- before do
- SiteSetting.must_approve_users = true
- Jobs.run_immediately!
- user.update!(approved: false)
- user.activate
- end
+ before do
+ SiteSetting.enable_category_group_moderation = true
+ reviewable_flagged_post.topic.change_category_to_id(category.id)
+ sign_in trust_level_1_user
+ end
- it "Allow to delete and scrub user" do
- reviewable = ReviewableUser.find_by_target_id(user.id)
+ it "does not show IP information" do
+ visit "/"
+ review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.click_insights_tab
- refreshed_review_page.visit_reviewable(reviewable)
+ expect(page).not_to have_text("The requested URL or resource could not be found.")
+ end
+ end
+ end
+ end
- expect(page).to have_text(user.name)
- expect(page).to have_link(user.username, href: "/admin/users/#{user.id}/#{user.username}")
+ describe "when the reviewable item is a queued post" do
+ fab!(:reviewable_queued_post)
- refreshed_review_page.select_bundled_action(reviewable, "user-delete_user")
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)
+ it "allows to edit post when old moderator actions are enabled" do
+ review_page.visit_reviewable(reviewable_queued_post)
- expect(page).to have_text(user.name)
+ expect(page).to have_text("hello world post contents.")
+ review_page.click_edit_post_button
+ review_page.fill_post_content("Hello world from system spec!")
+ review_page.save_post_edit
- refreshed_review_page.select_bundled_action(reviewable, "user-scrub")
+ expect(page).to have_text("Hello world from system spec!")
+ expect(page).not_to have_text("hello world post contents.")
+ end
- scrubbing_reason = "a spammer who knows how to make GDPR requests"
- scrub_user_modal.fill_in_scrub_reason(scrubbing_reason)
- expect(scrub_user_modal.scrub_button).not_to be_disabled
- scrub_user_modal.scrub_button.click
+ it "shows context question for rejected queued post" do
+ review_page.visit_reviewable(reviewable_queued_post)
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_by(
- reviewable,
- admin.username,
- )
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_reason(
- reviewable,
- scrubbing_reason,
- )
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_at(
- reviewable,
- reviewable.payload["scrubbed_at"],
- )
- expect(page).not_to have_text(user.name)
- end
+ expect(review_page).to have_context_question(
+ reviewable_queued_post,
+ I18n.t("js.review.context_question.approve_post"),
+ )
+ end
+ end
- it "Allows to delete and block user" do
- reviewable = ReviewableUser.find_by_target_id(user.id)
+ describe "when the reviewable item is a user" do
+ fab!(:user)
+ let(:rejection_reason_modal) { PageObjects::Modals::RejectReasonReviewable.new }
+ let(:scrub_user_modal) { PageObjects::Modals::ScrubRejectedUser.new }
- refreshed_review_page.visit_reviewable(reviewable)
- refreshed_review_page.select_bundled_action(reviewable, "user-delete_user_block")
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)
- expect(refreshed_review_page).to have_rejected_item_in_timeline(reviewable)
- end
+ before do
+ SiteSetting.must_approve_users = true
+ Jobs.run_immediately!
+ user.update!(approved: false)
+ user.activate
+ end
- it "Allows to approve user" do
- reviewable = ReviewableUser.find_by_target_id(user.id)
+ it "Allow to delete and scrub user" do
+ reviewable = ReviewableUser.find_by_target_id(user.id)
- refreshed_review_page.visit_reviewable(reviewable)
- refreshed_review_page.select_bundled_action(
- reviewable,
- "user-approve_user",
- "user-approve_user",
- )
+ review_page.visit_reviewable(reviewable)
- expect(refreshed_review_page).to have_reviewable_with_approved_status(reviewable)
- expect(refreshed_review_page).to have_approved_item_in_timeline(reviewable)
- end
+ expect(page).to have_text(user.name)
+ expect(page).to have_link(user.username, href: "/admin/users/#{user.id}/#{user.username}")
- it "Allow to delete and scrub user when old moderator actions are enabled" do
- SiteSetting.reviewable_old_moderator_actions = true
+ review_page.select_bundled_action(reviewable, "user-delete_user")
+ rejection_reason_modal.fill_in_rejection_reason("Spamming the site")
+ rejection_reason_modal.delete_user
- reviewable = ReviewableUser.find_by_target_id(user.id)
+ expect(review_page).to have_reviewable_with_rejected_status(reviewable)
- refreshed_review_page.visit_reviewable(reviewable)
+ expect(page).to have_text(user.name)
- expect(page).to have_text(user.name)
- expect(page).to have_link(user.username, href: "/admin/users/#{user.id}/#{user.username}")
+ review_page.click_scrub_user_button
- refreshed_review_page.select_bundled_action(reviewable, "user-delete_user")
- rejection_reason_modal.fill_in_rejection_reason("Spamming the site")
- rejection_reason_modal.delete_user
+ scrubbing_reason = "a spammer who knows how to make GDPR requests"
+ scrub_user_modal.fill_in_scrub_reason(scrubbing_reason)
+ expect(scrub_user_modal.scrub_button).not_to be_disabled
+ scrub_user_modal.scrub_button.click
- expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)
+ expect(review_page).to have_reviewable_with_scrubbed_by(reviewable, admin.username)
+ expect(review_page).to have_reviewable_with_scrubbed_reason(reviewable, scrubbing_reason)
+ expect(review_page).to have_reviewable_with_scrubbed_at(
+ reviewable,
+ reviewable.payload["scrubbed_at"],
+ )
+ expect(page).not_to have_text(user.name)
+ end
- expect(page).to have_text(user.name)
+ it "Allows to delete and block user" do
+ reviewable = ReviewableUser.find_by_target_id(user.id)
- refreshed_review_page.click_scrub_user_button
+ review_page.visit_reviewable(reviewable)
+ review_page.select_bundled_action(reviewable, "user-delete_user_block")
+ rejection_reason_modal.fill_in_rejection_reason("Spamming the site")
+ rejection_reason_modal.delete_user
+ expect(review_page).to have_reviewable_with_rejected_status(reviewable)
+ expect(review_page).to have_rejected_item_in_timeline(reviewable)
+ end
- scrubbing_reason = "a spammer who knows how to make GDPR requests"
- scrub_user_modal.fill_in_scrub_reason(scrubbing_reason)
- expect(scrub_user_modal.scrub_button).not_to be_disabled
- scrub_user_modal.scrub_button.click
+ it "Allows to approve user" do
+ reviewable = ReviewableUser.find_by_target_id(user.id)
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_by(
- reviewable,
- admin.username,
- )
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_reason(
- reviewable,
- scrubbing_reason,
- )
- expect(refreshed_review_page).to have_reviewable_with_scrubbed_at(
- reviewable,
- reviewable.payload["scrubbed_at"],
- )
- expect(page).not_to have_text(user.name)
- end
+ review_page.visit_reviewable(reviewable)
+ review_page.click_approve_user_button
+
+ expect(review_page).to have_reviewable_with_approved_status(reviewable)
+ expect(review_page).to have_approved_item_in_timeline(reviewable)
end
end
describe "moderator" do
before do
- SiteSetting.reviewable_ui_refresh = group.name
- SiteSetting.reviewable_old_moderator_actions = false
group.add(admin)
group.add(moderator)
sign_in(moderator)
@@ -442,26 +381,26 @@ describe "Viewing reviewable item", type: :system do
it "shows claimed and unclaimed events in the timeline" do
SiteSetting.reviewable_claiming = "required"
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
- expect(refreshed_review_page).to have_history_items(count: 2)
- expect(refreshed_review_page).to have_created_at_history_item
+ review_page.visit_reviewable(reviewable_flagged_post)
+ expect(review_page).to have_history_items(count: 2)
+ expect(review_page).to have_created_at_history_item
- refreshed_review_page.click_claim_reviewable
+ review_page.click_claim_reviewable
page.refresh
- expect(refreshed_review_page).to have_history_items(count: 3)
- expect(refreshed_review_page).to have_claimed_history_item(moderator)
+ expect(review_page).to have_history_items(count: 3)
+ expect(review_page).to have_claimed_history_item(moderator)
- refreshed_review_page.click_unclaim_reviewable
+ review_page.click_unclaim_reviewable
page.refresh
- expect(refreshed_review_page).to have_history_items(count: 4)
- expect(refreshed_review_page).to have_unclaimed_history_item(moderator)
+ expect(review_page).to have_history_items(count: 4)
+ expect(review_page).to have_unclaimed_history_item(moderator)
# remove history items created by deleted users
UserDestroyer.new(admin).destroy(moderator)
sign_in(admin)
- refreshed_review_page.visit_reviewable(reviewable_flagged_post)
+ review_page.visit_reviewable(reviewable_flagged_post)
- expect(refreshed_review_page).to have_history_items(count: 2)
+ expect(review_page).to have_history_items(count: 2)
end
end
end