From e51cf7e2b9eb8ef1ee9ac2da08442a513696b3eb Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sat, 22 Feb 2020 01:05:20 -0600 Subject: treat profile metadata fields with a `badge` label as custom profile badges --- app/helpers/statuses_helper.rb | 9 +++++++++ .../glitch/features/account/components/header.js | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/helpers/statuses_helper.rb b/app/helpers/statuses_helper.rb index 574b3ad5c..66f17d939 100644 --- a/app/helpers/statuses_helper.rb +++ b/app/helpers/statuses_helper.rb @@ -56,6 +56,15 @@ module StatusesHelper roles << content_tag(:div, t('accounts.roles.gently'), class: 'account-role gently') if account.gently? roles << content_tag(:div, t('accounts.roles.kobold'), class: 'account-role kobold') if account.kobold? + user_badges = account.fields + .select { |field| field.name == 'badge' && !field.value&.strip.blank? } + .map { |field| field.value.strip } + .uniq + + roles |= user_badges.map do |field| + content_tag(:div, badge_text, class: 'account-role custom') + end + if (Setting.show_staff_badge && account.user_can_moderate?) || all if all && !account.user_staff? roles << content_tag(:div, t('admin.accounts.roles.user'), class: 'account-role') diff --git a/app/javascript/flavours/glitch/features/account/components/header.js b/app/javascript/flavours/glitch/features/account/components/header.js index 553302cbc..8314ce109 100644 --- a/app/javascript/flavours/glitch/features/account/components/header.js +++ b/app/javascript/flavours/glitch/features/account/components/header.js @@ -226,7 +226,22 @@ class Header extends ImmutablePureComponent {

@{acct} -
{badge_admin}{badge_mod}{badge_halfmod}{badge_froze}{badge_locked}{badge_limited}{badge_ac}{badge_bot}{badge_gently}{badge_kobold}
+
+ {badge_admin} + {badge_mod} + {badge_halfmod} + {badge_froze} + {badge_locked} + {badge_limited} + {badge_ac} + {badge_bot} + {badge_gently} + {badge_kobold} + + {fields.filter(pair => pair.get('name') === 'badge').map((pair, i) => ( +
) + )} +

@@ -246,7 +261,7 @@ class Header extends ImmutablePureComponent { ))} - {fields.map((pair, i) => ( + {fields.filter(pair => pair.get('name') !== 'badge').map((pair, i) => (
-- cgit