action_logs_helper.rb 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # frozen_string_literal: true
  2. module Admin::ActionLogsHelper
  3. def log_target(log)
  4. case log.target_type
  5. when 'Account'
  6. link_to (log.human_identifier.presence || I18n.t('admin.action_logs.deleted_account')), admin_account_path(log.target_id)
  7. when 'User'
  8. if log.route_param.present?
  9. link_to log.human_identifier, admin_account_path(log.route_param)
  10. else
  11. I18n.t('admin.action_logs.deleted_account')
  12. end
  13. when 'UserRole'
  14. link_to log.human_identifier, admin_roles_path(log.target_id)
  15. when 'Report'
  16. link_to "##{log.human_identifier.presence || log.target_id}", admin_report_path(log.target_id)
  17. when 'Instance', 'DomainBlock', 'DomainAllow', 'UnavailableDomain'
  18. log.human_identifier.present? ? link_to(log.human_identifier, admin_instance_path(log.human_identifier)) : I18n.t('admin.action_logs.unavailable_instance')
  19. when 'Status'
  20. link_to log.human_identifier, log.permalink
  21. when 'AccountWarning'
  22. link_to log.human_identifier, disputes_strike_path(log.target_id)
  23. when 'Announcement'
  24. link_to truncate(log.human_identifier), edit_admin_announcement_path(log.target_id)
  25. when 'IpBlock', 'EmailDomainBlock', 'CustomEmoji'
  26. log.human_identifier
  27. when 'CanonicalEmailBlock'
  28. content_tag(:samp, (log.human_identifier.presence || '')[0...7], title: log.human_identifier)
  29. when 'Appeal'
  30. if log.route_param.present?
  31. link_to log.human_identifier, disputes_strike_path(log.route_param.presence)
  32. else
  33. I18n.t('admin.action_logs.deleted_account')
  34. end
  35. when 'Relay'
  36. link_to log.human_identifier, admin_relays_path
  37. end
  38. end
  39. def sorted_action_log_types
  40. Admin::ActionLogFilter::ACTION_TYPE_MAP
  41. .keys
  42. .map { |key| [I18n.t("admin.action_logs.action_types.#{key}"), key] }
  43. .sort_by(&:first)
  44. end
  45. end