UX: display 'merge' button in all non-staff user profiles.

This commit is contained in:
Vinoth Kannan 2020-04-22 17:42:09 +05:30
parent c8fed90e4e
commit e5c44f6dcf
4 changed files with 15 additions and 3 deletions

View File

@ -683,6 +683,9 @@
icon="trash-alt"
class="btn-danger"
action=(action "destroy")}}
{{/if}}
{{#if model.can_be_merged}}
{{d-button label="admin.user.merge.transfer_and_delete"
icon="trash-alt"
class="btn-danger"

View File

@ -476,7 +476,7 @@ class Admin::UsersController < Admin::AdminController
target_username = params.require(:target_username)
target_user = User.find_by_username(target_username)
guardian.ensure_can_merge_user!(@user, target_user)
guardian.ensure_can_merge_users!(@user, target_user)
if user = UserMerger.new(@user, target_user, current_user).merge!
render json: success_json.merge(merged: true, user: user)

View File

@ -18,6 +18,7 @@ class AdminDetailedUserSerializer < AdminUserSerializer
:can_delete_all_posts,
:can_be_deleted,
:can_be_anonymized,
:can_be_merged,
:full_suspend_reason,
:suspended_till,
:silence_reason,
@ -74,6 +75,10 @@ class AdminDetailedUserSerializer < AdminUserSerializer
scope.can_anonymize_user?(object)
end
def can_be_merged
scope.can_merge_user?(object)
end
def topic_count
object.topics.count
end

View File

@ -76,8 +76,12 @@ module UserGuardian
is_staff? && !user.nil? && !user.staff?
end
def can_merge_user?(source_user, target_user)
is_admin? && !source_user.nil? && !source_user.staff? && !target_user.nil?
def can_merge_user?(user)
is_admin? && !user.nil? && !user.staff?
end
def can_merge_users?(source_user, target_user)
can_merge_user?(source_user) && !target_user.nil?
end
def can_reset_bounce_score?(user)