Fix admin action logs page (#19649)
* Add tests * Fix crash when trying to display orphaned action logs * Add migration for older admin action logs
This commit is contained in:
		@@ -4,15 +4,19 @@ module Admin::ActionLogsHelper
 | 
			
		||||
  def log_target(log)
 | 
			
		||||
    case log.target_type
 | 
			
		||||
    when 'Account'
 | 
			
		||||
      link_to log.human_identifier, admin_account_path(log.target_id)
 | 
			
		||||
      link_to (log.human_identifier.presence || I18n.t('admin.action_logs.deleted_account')), admin_account_path(log.target_id)
 | 
			
		||||
    when 'User'
 | 
			
		||||
      link_to log.human_identifier, admin_account_path(log.route_param)
 | 
			
		||||
      if log.route_param.present?
 | 
			
		||||
        link_to log.human_identifier, admin_account_path(log.route_param)
 | 
			
		||||
      else
 | 
			
		||||
        I18n.t('admin.action_logs.deleted_account')
 | 
			
		||||
      end
 | 
			
		||||
    when 'UserRole'
 | 
			
		||||
      link_to log.human_identifier, admin_roles_path(log.target_id)
 | 
			
		||||
    when 'Report'
 | 
			
		||||
      link_to "##{log.human_identifier}", admin_report_path(log.target_id)
 | 
			
		||||
      link_to "##{log.human_identifier.presence || log.target_id}", admin_report_path(log.target_id)
 | 
			
		||||
    when 'DomainBlock', 'DomainAllow', 'EmailDomainBlock', 'UnavailableDomain'
 | 
			
		||||
      link_to log.human_identifier, "https://#{log.human_identifier}"
 | 
			
		||||
      link_to log.human_identifier, "https://#{log.human_identifier.presence}"
 | 
			
		||||
    when 'Status'
 | 
			
		||||
      link_to log.human_identifier, log.permalink
 | 
			
		||||
    when 'AccountWarning'
 | 
			
		||||
@@ -22,9 +26,13 @@ module Admin::ActionLogsHelper
 | 
			
		||||
    when 'IpBlock', 'Instance', 'CustomEmoji'
 | 
			
		||||
      log.human_identifier
 | 
			
		||||
    when 'CanonicalEmailBlock'
 | 
			
		||||
      content_tag(:samp, log.human_identifier[0...7], title: log.human_identifier)
 | 
			
		||||
      content_tag(:samp, (log.human_identifier.presence || '')[0...7], title: log.human_identifier)
 | 
			
		||||
    when 'Appeal'
 | 
			
		||||
      link_to log.human_identifier, disputes_strike_path(log.route_param)
 | 
			
		||||
      if log.route_param.present?
 | 
			
		||||
        link_to log.human_identifier, disputes_strike_path(log.route_param.presence)
 | 
			
		||||
      else
 | 
			
		||||
        I18n.t('admin.action_logs.deleted_account')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user