From 690da4c1e73317797232351636f001f067f608a3 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 2 Oct 2024 08:24:12 -0400 Subject: [PATCH] Helper method for deletion req due at --- app/helpers/admin/accounts_helper.rb | 20 +++++++++++++++++++ .../accounts/_suspended_buttons.html.haml | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/helpers/admin/accounts_helper.rb b/app/helpers/admin/accounts_helper.rb index a936797e888..2e50170e75b 100644 --- a/app/helpers/admin/accounts_helper.rb +++ b/app/helpers/admin/accounts_helper.rb @@ -11,8 +11,28 @@ module Admin::AccountsHelper ] end + def remote_suspension_hint(deletion_request) + if deletion_request.present? + t('admin.accounts.remote_suspension_reversible_hint_html', date: due_date_for_hint(deletion_request)) + else + t('admin.accounts.remote_suspension_irreversible') + end + end + + def suspension_hint(deletion_request) + if deletion_request.present? + t('admin.accounts.suspension_reversible_hint_html', date: due_date_for_hint(deletion_request)) + else + t('admin.accounts.suspension_irreversible') + end + end + private + def due_date_for_hint(deletion_request) + tag.strong(l(deletion_request.due_at.to_date)) + end + def pending_user_count_label number_with_delimiter User.pending.count end diff --git a/app/views/admin/accounts/_suspended_buttons.html.haml b/app/views/admin/accounts/_suspended_buttons.html.haml index 8352c2a03be..9697a036dee 100644 --- a/app/views/admin/accounts/_suspended_buttons.html.haml +++ b/app/views/admin/accounts/_suspended_buttons.html.haml @@ -3,9 +3,9 @@ %p.muted-hint - if account.suspension_origin_remote? - = deletion_request.present? ? t('admin.accounts.remote_suspension_reversible_hint_html', date: content_tag(:strong, l(deletion_request.due_at.to_date))) : t('admin.accounts.remote_suspension_irreversible') + = remote_suspension_hint(deletion_request) - else - = deletion_request.present? ? t('admin.accounts.suspension_reversible_hint_html', date: content_tag(:strong, l(deletion_request.due_at.to_date))) : t('admin.accounts.suspension_irreversible') + = suspension_hint(deletion_request) - if can?(:unsuspend, account) = button_to t('admin.accounts.undo_suspension'), @@ -20,6 +20,6 @@ - if deletion_request.present? && can?(:destroy, account) = link_to t('admin.accounts.delete'), admin_account_path(account.id), - class: 'button button--destructive', + class: [:button, 'button--destructive'], data: { confirm: t('admin.accounts.are_you_sure') }, method: :delete