Skip to content

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

DEV: Move option to delete user under reviewable agree menu (#23199)

Ted Johansson12cdd7db1a4e
diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb
index c0fdb2d00c4..a6738fb68ee 100644
--- a/app/models/reviewable.rb
+++ b/app/models/reviewable.rb
@@ -656,22 +656,22 @@ class Reviewable < ActiveRecord::Base
self.score
end
- def delete_user_actions(actions, require_reject_reason: false)
- reject =
+ def delete_user_actions(actions, bundle = nil, require_reject_reason: false)
+ bundle ||=
actions.add_bundle(
"reject_user",
icon: "user-times",
label: "reviewables.actions.reject_user.title",
)
- actions.add(:delete_user, bundle: reject) do |a|
+ actions.add(:delete_user, bundle: bundle) do |a|
a.icon = "user-times"
a.label = "reviewables.actions.reject_user.delete.title"
a.require_reject_reason = require_reject_reason
a.description = "reviewables.actions.reject_user.delete.description"
end
- actions.add(:delete_user_block, bundle: reject) do |a|
+ actions.add(:delete_user_block, bundle: bundle) do |a|
a.icon = "ban"
a.label = "reviewables.actions.reject_user.block.title"
a.require_reject_reason = require_reject_reason
diff --git a/app/models/reviewable_flagged_post.rb b/app/models/reviewable_flagged_post.rb
index a144845f437..f1b0279d2a7 100644
--- a/app/models/reviewable_flagged_post.rb
+++ b/app/models/reviewable_flagged_post.rb
@@ -44,28 +44,32 @@ class ReviewableFlaggedPost < Reviewable
return unless pending?
return if post.blank?
- agree =
+ agree_bundle =
actions.add_bundle("#{id}-agree", icon: "thumbs-up", label: "reviewables.actions.agree.title")
+ if potential_spam? && guardian.can_delete_user?(target_created_by)
+ delete_user_actions(actions, agree_bundle)
+ end
+
if !post.user_deleted? && !post.hidden?
- build_action(actions, :agree_and_hide, icon: "far-eye-slash", bundle: agree)
+ build_action(actions, :agree_and_hide, icon: "far-eye-slash", bundle: agree_bundle)
end
if post.hidden?
- build_action(actions, :agree_and_keep_hidden, icon: "thumbs-up", bundle: agree)
+ build_action(actions, :agree_and_keep_hidden, icon: "thumbs-up", bundle: agree_bundle)
else
- build_action(actions, :agree_and_keep, icon: "thumbs-up", bundle: agree)
+ build_action(actions, :agree_and_keep, icon: "thumbs-up", bundle: agree_bundle)
end
if guardian.can_delete_post_or_topic?(post)
- build_action(actions, :delete_and_agree, icon: "far-trash-alt", bundle: agree)
+ build_action(actions, :delete_and_agree, icon: "far-trash-alt", bundle: agree_bundle)
if post.reply_count > 0
build_action(
actions,
:delete_and_agree_replies,
icon: "far-trash-alt",
- bundle: agree,
+ bundle: agree_bundle,
confirm: true,
)
end
@@ -76,19 +80,21 @@ class ReviewableFlaggedPost < Reviewable
actions,
:agree_and_suspend,
icon: "ban",
- bundle: agree,
+ bundle: agree_bundle,
client_action: "suspend",
)
build_action(
actions,
:agree_and_silence,
icon: "microphone-slash",
- bundle: agree,
+ bundle: agree_bundle,
client_action: "silence",
)
end
- build_action(actions, :agree_and_restore, icon: "far-eye", bundle: agree) if post.user_deleted?
+ if post.user_deleted?
+ build_action(actions, :agree_and_restore, icon: "far-eye", bundle: agree_bundle)
+ end
if post.hidden?
build_action(actions, :disagree_and_restore, icon: "thumbs-down")
else
@@ -117,8 +123,6 @@ class ReviewableFlaggedPost < Reviewable
)
end
end
-
- delete_user_actions(actions) if potential_spam? && guardian.can_delete_user?(target_created_by)
end
def perform_ignore(performed_by, args)