From acc180611f7112d4bc11530668dd05749c26592c Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Mon, 9 Dec 2024 14:25:31 +0300 Subject: [PATCH] FEATURE: Add an option to block IPs and emails to bulk user delete (#29993) This commit adds an option for blocking the IP and email addresses when bulk-deleting users. Internal topic: t/140321/11. --- .../bulk-user-delete-confirmation.gjs | 21 ++++- app/controllers/admin/users_controller.rb | 6 +- app/services/user/bulk_destroy.rb | 6 +- config/locales/client.en.yml | 1 + spec/requests/admin/users_controller_spec.rb | 82 +++++++++++++++++-- spec/system/admin_users_list_spec.rb | 29 +++++++ .../modals/bulk_user_delete_confirmation.rb | 4 + 7 files changed, 140 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/admin/addon/components/bulk-user-delete-confirmation.gjs b/app/assets/javascripts/admin/addon/components/bulk-user-delete-confirmation.gjs index 36c246a0d75..267d5d5f9f4 100644 --- a/app/assets/javascripts/admin/addon/components/bulk-user-delete-confirmation.gjs +++ b/app/assets/javascripts/admin/addon/components/bulk-user-delete-confirmation.gjs @@ -22,6 +22,7 @@ export default class BulkUserDeleteConfirmation extends Component { failedUsernames = []; callAfterBulkDelete = false; + blockIpAndEmail = false; constructor() { super(...arguments); @@ -117,7 +118,10 @@ export default class BulkUserDeleteConfirmation extends Component { try { await ajax("/admin/users/destroy-bulk.json", { type: "DELETE", - data: { user_ids: this.args.model.userIds }, + data: { + user_ids: this.args.model.userIds, + block_ip_and_email: this.blockIpAndEmail, + }, }); this.callAfterBulkDelete = true; } catch (err) { @@ -134,6 +138,11 @@ export default class BulkUserDeleteConfirmation extends Component { } } + @action + toggleBlockIpAndEmail(event) { + this.blockIpAndEmail = event.target.checked; + } +