From fef7f3b6d527d427c8a5907e94a79e47d748977d Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 9 Sep 2019 14:15:52 +0200 Subject: [PATCH] Add account bio to account admin view (#11473) * Add account bio to account admin view * Change styling to make bio fields / content more readable --- app/javascript/styles/mastodon/admin.scss | 44 +++++++++++++++++++++++ app/lib/formatter.rb | 3 +- app/views/admin/accounts/show.html.haml | 28 +++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index f625bc1398..5d4fe4ef81 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -716,3 +716,47 @@ a.name-tag, text-overflow: ellipsis; vertical-align: middle; } + +.admin-account-bio { + display: flex; + flex-wrap: wrap; + margin: 0 -5px; + margin-top: 20px; + + > div { + box-sizing: border-box; + padding: 0 5px; + margin-bottom: 10px; + flex: 1 0 50%; + } + + .account__header__fields, + .account__header__content { + background: lighten($ui-base-color, 8%); + border-radius: 4px; + height: 100%; + } + + .account__header__fields { + margin: 0; + border: 0; + + a { + color: lighten($ui-highlight-color, 8%); + } + + dl:first-child .verified { + border-radius: 0 4px 0 0; + } + + .verified a { + color: $valid-value-color; + } + } + + .account__header__content { + box-sizing: border-box; + padding: 20px; + color: $primary-text-color; + } +} diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index b5f42305fe..990b9f63ed 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -84,8 +84,7 @@ class Formatter end def format_field(account, str, **options) - return reformat(str).html_safe unless account.local? # rubocop:disable Rails/OutputSafety - html = encode_and_link_urls(str, me: true) + html = account.local? ? encode_and_link_urls(str, me: true) : reformat(str) html = encode_custom_emojis(html, account.emojis, options[:autoplay]) if options[:custom_emojify] html.html_safe # rubocop:disable Rails/OutputSafety end diff --git a/app/views/admin/accounts/show.html.haml b/app/views/admin/accounts/show.html.haml index 59babd3b00..40a936e869 100644 --- a/app/views/admin/accounts/show.html.haml +++ b/app/views/admin/accounts/show.html.haml @@ -3,6 +3,34 @@ = render 'application/card', account: @account +- account = @account +- proofs = account.identity_proofs.active +- fields = account.fields +- unless fields.empty? && proofs.empty? && account.note.blank? + .admin-account-bio + - unless fields.empty? && proofs.empty? + %div + .account__header__fields + - proofs.each do |proof| + %dl + %dt= proof.provider.capitalize + %dd.verified + = link_to fa_icon('check'), proof.badge.proof_url, class: 'verified__mark', title: t('accounts.link_verified_on', date: l(proof.updated_at)) + = link_to proof.provider_username, proof.badge.profile_url + + - fields.each do |field| + %dl + %dt.emojify{ title: field.name }= Formatter.instance.format_field(account, field.name, custom_emojify: true) + %dd{ title: field.value, class: custom_field_classes(field) } + - if field.verified? + %span.verified__mark{ title: t('accounts.link_verified_on', date: l(field.verified_at)) } + = fa_icon 'check' + = Formatter.instance.format_field(account, field.value, custom_emojify: true) + + - if account.note.present? + %div + .account__header__content.emojify= Formatter.instance.simplified_format(account, custom_emojify: true) + .dashboard__counters{ style: 'margin-top: 10px' } %div = link_to admin_account_statuses_path(@account.id) do