account_moderation_notes_helper.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # frozen_string_literal: true
  2. module Admin::AccountModerationNotesHelper
  3. def admin_account_link_to(account, path: nil)
  4. return if account.nil?
  5. link_to(
  6. labeled_account_avatar(account),
  7. path || admin_account_path(account.id),
  8. class: class_names('name-tag', suspended: suspended_account?(account)),
  9. title: account.acct
  10. )
  11. end
  12. def admin_account_inline_link_to(account, path: nil)
  13. return if account.nil?
  14. link_to(
  15. account_inline_text(account),
  16. path || admin_account_path(account.id),
  17. class: class_names('inline-name-tag', suspended: suspended_account?(account)),
  18. title: account.acct
  19. )
  20. end
  21. private
  22. def labeled_account_avatar(account)
  23. safe_join(
  24. [
  25. image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'),
  26. account_inline_text(account),
  27. ],
  28. ' '
  29. )
  30. end
  31. def account_inline_text(account)
  32. content_tag(:span, account.acct, class: 'username')
  33. end
  34. def suspended_account?(account)
  35. account.suspended? || (account.local? && account.user.nil?)
  36. end
  37. end