From 1407f6db9fba00dd92b8cdfa5d740c46f336428c Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Thu, 18 Jul 2024 20:13:54 -0700 Subject: [PATCH] Expand owner list, show mfa status as an asterisk --- app/helpers/rubygems_helper.rb | 13 ++++++++++ app/javascript/src/pages.js | 10 -------- app/policies/rubygem_policy.rb | 4 +++ app/views/rubygems/_gem_members.html.erb | 32 ++++++++++-------------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/helpers/rubygems_helper.rb b/app/helpers/rubygems_helper.rb index 7898a9e9475..cb4e653d2b1 100644 --- a/app/helpers/rubygems_helper.rb +++ b/app/helpers/rubygems_helper.rb @@ -139,6 +139,19 @@ def links_to_owners_without_mfa(rubygem) rubygem.owners.without_mfa.sort_by(&:id).inject("") { |link, owner| link << link_to_user(owner) }.html_safe end + def link_to_owner(owner, show_mfa_status: false) + link_text = avatar(32, "gravatar-#{owner.id}", owner, class: "tw-rounded-full tw-mr-1") + link_text << " #{owner.display_handle}" + link_text << " *" if show_mfa_status && owner.mfa_disabled? + link_to( + link_text.html_safe, + profile_path(owner.display_id), + alt: owner.display_handle, + title: owner.display_handle, + class: "t-link tw-flex tw-items-center" + ) + end + def link_to_user(user) link_to avatar(48, "gravatar-#{user.id}", user), profile_path(user.display_id), alt: user.display_handle, title: user.display_handle diff --git a/app/javascript/src/pages.js b/app/javascript/src/pages.js index f7fe0aa7289..e2777a8d01c 100644 --- a/app/javascript/src/pages.js +++ b/app/javascript/src/pages.js @@ -67,13 +67,3 @@ $(function() { $(this).animate({ width: $(this).data("bar-width") + '%' }, 700).removeClass('t-item--hidden').css("display", "block"); }); }); - -//gem page -$(function() { - $('.gem__users__mfa-text.mfa-warn').on('click', function() { - $('.gem__users__mfa-text.mfa-warn').toggleClass('t-item--hidden'); - - $owners = $('.gem__users__mfa-disabled'); - $owners.toggleClass('t-item--hidden'); - }); -}); diff --git a/app/policies/rubygem_policy.rb b/app/policies/rubygem_policy.rb index 221c6d8d048..fd2b8646f5e 100644 --- a/app/policies/rubygem_policy.rb +++ b/app/policies/rubygem_policy.rb @@ -57,4 +57,8 @@ def add_owner? def remove_owner? rubygem_owned_by?(user) end + + def show_owner_mfa_status? + rubygem_owned_by?(user) + end end diff --git a/app/views/rubygems/_gem_members.html.erb b/app/views/rubygems/_gem_members.html.erb index fc15a017930..1f498cefc49 100644 --- a/app/views/rubygems/_gem_members.html.erb +++ b/app/views/rubygems/_gem_members.html.erb @@ -1,28 +1,22 @@
<% if rubygem.owners.present? %>

<%= t '.owners_header' %>:

-
- <%= links_to_owners(rubygem) %> -
+ - <% if rubygem.owned_by?(current_user) %> + <% if rubygem.owned_by?(current_user) %> <% if rubygem.owners.without_mfa.present? %> - <% if current_user.mfa_disabled? %> - - <%= t '.self_no_mfa_warning_html' %> - - <% else %> - <%= t '.not_using_mfa_warning_show' %> - <% end %> - -
- <%= t '.not_using_mfa_warning_hide' %> -
- <%= links_to_owners_without_mfa(rubygem) %> -
-
+ + <%= current_user.mfa_disabled? ? t(".self_no_mfa_warning_html") : t(".not_using_mfa_warning_show") %> + <% else %> - <%= t '.using_mfa_info' %> + <%= t '.using_mfa_info' %> <% end %> <% end %> <% end %>