From b5991baaedd28c05cd5812956cce5b047b01a1d8 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Sun, 3 May 2026 13:43:42 +0900 Subject: [PATCH] Add last note author to assignee dropdown participants Show the author, prior assignee, and most recent visible note author in the assignee dropdown's quick-pick section for existing issues. Rename the English section label to "Author / Recent participants". --- app/helpers/application_helper.rb | 11 +++++++++- config/locales/en.yml | 2 +- test/helpers/application_helper_test.rb | 29 ++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index dd6c8f464..ccf762d1e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -690,8 +690,17 @@ module ApplicationHelper involved_principals = [] # This optgroup is displayed only when editing a single issue if @issue.present? && !@issue.new_record? + last_notes_author = + @issue.journals.visible(User.current). + where.not(:notes => ''). + reorder(:id => :desc). + first&.user involved_principals = - [@issue.author, @issue.prior_assigned_to].uniq.compact.map do |principal| + [ + @issue.author, + @issue.prior_assigned_to, + last_notes_author + ].uniq.compact.map do |principal| [principal, {:disabled => !collection.include?(principal)}] end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 789694d67..0be4d1a41 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1172,7 +1172,7 @@ en: label_default_query: Default query label_edited: Edited label_time_by_author: "%{time} by %{author}" - label_involved_principals: Author / Previous assignee + label_involved_principals: Author / Recent participants label_assignee_dropdown_display_format_users_then_groups: Users then groups label_assignee_dropdown_display_format_groups_then_users: Groups then users label_assignee_dropdown_display_format_users_by_group: Users by group diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index ef0488c8c..2d05835a4 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -1993,21 +1993,44 @@ class ApplicationHelperTest < Redmine::HelperTest principals_options_for_select(users) end - def test_principals_options_for_select_should_include_author_and_previous_assignee + def test_principals_options_for_select_should_include_author_previous_assignee_and_last_notes_author set_language_if_valid 'en' - users = [User.find(2), User.find(3), User.find(1)] + users = [User.find(2), User.find(3), User.find(1), User.find(4)] @issue = Issue.generate!(author_id: 1, assigned_to_id: 2) @issue.init_journal(users.first, 'update') @issue.assigned_to_id = 3 @issue.save + Journal.create!(:journalized => @issue, :user_id => 4, :notes => 'Last notes') result = principals_options_for_select(users) - assert_select_in result, 'optgroup[label="Author / Previous assignee"]' do + assert_select_in result, 'optgroup[label="Author / Recent participants"]' do assert_select 'option:nth-of-type(1)', text: 'Redmine Admin' # Author assert_select 'option:nth-of-type(2)', text: 'John Smith' # Prior assignee + assert_select 'option:nth-of-type(3)', text: 'Robert Hill' # Last notes author end end + def test_principals_options_for_select_should_not_include_private_last_notes_author_without_permission + set_language_if_valid 'en' + User.current = User.find(3) + users = [User.find(2), User.find(3), User.find(1), User.find(4)] + @issue = Issue.generate!(author_id: 1, assigned_to_id: 2) + @issue.init_journal(users.first, 'update') + @issue.assigned_to_id = 3 + @issue.save + Journal.create!(:journalized => @issue, :user_id => 4, :notes => 'Public notes') + Journal.create!(:journalized => @issue, :user_id => 8, :notes => 'Private notes', :private_notes => true) + + result = principals_options_for_select(users) + assert_select_in result, 'optgroup[label="Author / Recent participants"]' do + assert_select 'option:nth-of-type(1)', text: 'Redmine Admin' + assert_select 'option:nth-of-type(2)', text: 'John Smith' + assert_select 'option:nth-of-type(3)', text: 'Robert Hill' + end + ensure + User.current = nil + end + def test_stylesheet_link_tag_should_pick_the_default_stylesheet assert_match 'href="/assets/styles.css"', stylesheet_link_tag("styles") end -- 2.50.1