action_logs_helper.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 'DomainBlock', 'DomainAllow', 'EmailDomainBlock', 'UnavailableDomain'
  18. link_to log.human_identifier, "https://#{log.human_identifier.presence}"
  19. when 'Status'
  20. link_to log.human_identifier, log.permalink
  21. when 'AccountWarning'
  22. link_to log.human_identifier, admin_account_path(log.target_id)
  23. when 'Announcement'
  24. link_to truncate(log.human_identifier), edit_admin_announcement_path(log.target_id)
  25. when 'IpBlock', 'Instance', '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. end
  36. end
  37. end