From 7ea499a108be8416495daddab45fab20ae3506eb Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Sat, 26 Sep 2026 17:01:19 +0900 Subject: [PATCH] Dim avatars of inactive users so that locked users can be distinguished at a glance --- app/assets/stylesheets/application.css | 1 + app/helpers/avatars_helper.rb | 2 ++ test/functional/calendars_controller_test.rb | 2 +- test/functional/gantts_controller_test.rb | 2 +- test/helpers/avatars_helper_test.rb | 18 ++++++++++++++++-- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index ef24265fb..361506c8f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -2380,6 +2380,7 @@ img.filecontent.image {background-image: url(/transparent.png);} vertical-align: middle; flex-shrink: 0; } +.avatar.locked, .avatar.registered {opacity: .6;} span[role="img"].avatar { font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index c9aea637e..e5875e9ba 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -39,6 +39,8 @@ module AvatarsHelper def avatar(user, options = {}) # "avatar" class should be added to all avatars options[:class] = ['avatar', options[:class]].compact.join(' ') + # Add the status of the user as a class (e.g. "active", "locked") + options[:class] += " #{User::LABEL_BY_STATUS[user.status]}" if user.is_a?(User) if user.is_a?(AnonymousUser) anonymous_avatar(options) diff --git a/test/functional/calendars_controller_test.rb b/test/functional/calendars_controller_test.rb index 202c076ac..8b1f6dabd 100644 --- a/test/functional/calendars_controller_test.rb +++ b/test/functional/calendars_controller_test.rb @@ -57,7 +57,7 @@ class CalendarsControllerTest < Redmine::ControllerTest ) do assert_select 'a.issue[href=?]', '/issues/2', :text => 'Feature request #2' assert_select 'span.tip' do - assert_select 'img[class="gravatar avatar"]' + assert_select 'img[class="gravatar avatar active"]' end assert_select 'input[name=?][type=?][value=?]', 'ids[]', 'checkbox', '2' end diff --git a/test/functional/gantts_controller_test.rb b/test/functional/gantts_controller_test.rb index 877a1a345..ca6561454 100644 --- a/test/functional/gantts_controller_test.rb +++ b/test/functional/gantts_controller_test.rb @@ -58,7 +58,7 @@ class GanttsControllerTest < Redmine::ControllerTest # Assert context menu on issues subject and gantt bar assert_select 'div[class=?]', 'issue-subject hascontextmenu' assert_select 'div.tooltip.hascontextmenu' do - assert_select 'img[class="gravatar avatar"]' + assert_select 'img[class="gravatar avatar active"]' end assert_select "form[data-cm-url=?]", '/issues/context_menu' diff --git a/test/helpers/avatars_helper_test.rb b/test/helpers/avatars_helper_test.rb index a27d2b08d..7d13550f0 100644 --- a/test/helpers/avatars_helper_test.rb +++ b/test/helpers/avatars_helper_test.rb @@ -39,7 +39,7 @@ class AvatarsHelperTest < Redmine::HelperTest avatar_tag = avatar(User.anonymous) assert_match %r{src="/assets/anonymous(-\w+)?.png"}, avatar_tag - assert_match 'class="anonymous-avatar avatar"', avatar_tag + assert_match 'class="anonymous-avatar avatar anon"', avatar_tag end def test_avatar_with_group @@ -88,10 +88,24 @@ class AvatarsHelperTest < Redmine::HelperTest def test_avatar_disabled_should_display_user_initials with_settings :gravatar_enabled => '0' do - assert_equal "JS", avatar(User.find_by_mail('jsmith@somenet.foo')) + assert_equal "JS", avatar(User.find_by_mail('jsmith@somenet.foo')) end end + def test_avatar_should_have_user_status_class + assert_include 'class="gravatar avatar active"', avatar(User.find(2)) + + user = User.find(5) + assert user.locked? + assert_include 'class="gravatar avatar locked"', avatar(user) + with_settings :gravatar_enabled => '0' do + assert_equal "DL", avatar(user) + end + + user.status = User::STATUS_REGISTERED + assert_include 'class="gravatar avatar registered"', avatar(user) + end + def test_avatar_server_url to_test = { 'https://www.gravatar.com' => %r|https://www.gravatar.com/avatar/\h{32}|, -- 2.55.0