diff options
author | Go MAEDA <maeda@farend.jp> | 2025-05-17 08:46:25 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2025-05-17 08:46:25 +0000 |
commit | 8d1ad3f2395bccce67679199d4ce4b8780f1cc1a (patch) | |
tree | d6a2702b6cfacaa1973b3a58412797af2b93882d | |
parent | 4b42d688426e699e1aebe9f85c7075e04a09c1f9 (diff) | |
download | redmine-8d1ad3f2395bccce67679199d4ce4b8780f1cc1a.tar.gz redmine-8d1ad3f2395bccce67679199d4ce4b8780f1cc1a.zip |
Allow reactions on journals with property changes only (#42630).
Patch by Katsuya HIDAKA (user:hidakatsuya).
git-svn-id: https://svn.redmine.org/redmine/trunk@23781 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/assets/javascripts/application-legacy.js | 8 | ||||
-rw-r--r-- | app/helpers/journals_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/reactions_helper.rb | 2 | ||||
-rw-r--r-- | test/helpers/journals_helper_test.rb | 17 | ||||
-rw-r--r-- | test/helpers/reactions_helper_test.rb | 4 | ||||
-rw-r--r-- | test/system/reactions_test.rb | 41 |
6 files changed, 68 insertions, 8 deletions
diff --git a/app/assets/javascripts/application-legacy.js b/app/assets/javascripts/application-legacy.js index deaaa66b6..f7c1de95c 100644 --- a/app/assets/javascripts/application-legacy.js +++ b/app/assets/javascripts/application-legacy.js @@ -426,7 +426,7 @@ function showIssueHistory(journal, url) { tab_content.find('.journal').show(); tab_content.find('.journal:not(.has-notes)').hide(); tab_content.find('.journal .wiki').show(); - tab_content.find('.journal .contextual .journal-actions').show(); + tab_content.find('.journal .contextual .journal-actions > *').show(); // always show thumbnails in notes tab var thumbnails = tab_content.find('.journal .thumbnails'); @@ -439,13 +439,15 @@ function showIssueHistory(journal, url) { tab_content.find('.journal:not(.has-details)').hide(); tab_content.find('.journal .wiki').hide(); tab_content.find('.journal .thumbnails').hide(); - tab_content.find('.journal .contextual .journal-actions').hide(); + tab_content.find('.journal .contextual .journal-actions > *').hide(); + // Show reaction button in properties tab + tab_content.find('.journal .contextual .journal-actions .reaction-button-wrapper').show(); break; default: tab_content.find('.journal').show(); tab_content.find('.journal .wiki').show(); tab_content.find('.journal .thumbnails').show(); - tab_content.find('.journal .contextual .journal-actions').show(); + tab_content.find('.journal .contextual .journal-actions > *').show(); } return false; diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 66f81033e..7f1a449fb 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -41,9 +41,9 @@ module JournalsHelper ) end - if journal.notes.present? - links << reaction_button(journal) + links << reaction_button(journal) + if journal.notes.present? if options[:reply_links] url = quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice) links << quote_reply(url, "#journal-#{journal.id}-notes", icon_only: true) diff --git a/app/helpers/reactions_helper.rb b/app/helpers/reactions_helper.rb index 88d7f5c35..97943e71c 100644 --- a/app/helpers/reactions_helper.rb +++ b/app/helpers/reactions_helper.rb @@ -82,7 +82,7 @@ module ReactionsHelper end def reaction_button_wrapper(object, &) - tag.span(data: { 'reaction-button-id': reaction_id_for(object) }, &) + tag.span(class: 'reaction-button-wrapper', data: { 'reaction-button-id': reaction_id_for(object) }, &) end def build_reaction_tooltip(visible_user_names, count) diff --git a/test/helpers/journals_helper_test.rb b/test/helpers/journals_helper_test.rb index 355d5ec6f..b8ecec685 100644 --- a/test/helpers/journals_helper_test.rb +++ b/test/helpers/journals_helper_test.rb @@ -51,6 +51,23 @@ class JournalsHelperTest < Redmine::HelperTest assert_select_in journal_actions, 'a[title=?][class="icon-only icon-edit"]', 'Edit' assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-del"]' assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-copy-link"]' + assert_select_in journal_actions, 'span.reaction-button-wrapper' + end + + def test_render_journal_actions_with_journal_without_notes + User.current = User.find(1) + issue = Issue.find(1) + issue.journals.first.update!(notes: '') + + journals = issue.visible_journals_with_index + + journal_actions = render_journal_actions(issue, journals.first, reply_links: true) + + assert_select_in journal_actions, 'span.reaction-button-wrapper' + assert_select_in journal_actions, 'span.drdn' + + assert_select_in journal_actions, 'a[class="icon-comment"]', false + assert_select_in journal_actions, 'a[class="icon-edit"]', false end def test_journal_thumbnail_attachments_should_be_in_the_same_order_as_the_journal_details diff --git a/test/helpers/reactions_helper_test.rb b/test/helpers/reactions_helper_test.rb index f2eb04b6d..1c5c82418 100644 --- a/test/helpers/reactions_helper_test.rb +++ b/test/helpers/reactions_helper_test.rb @@ -172,7 +172,7 @@ class ReactionsHelperTest < ActionView::TestCase end tooltip = 'Dave Lopper, John Smith, and Redmine Admin' - assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do + assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do href = reaction_path(issue.reaction_detail.user_reaction, object_type: 'Issue', object_id: 1) assert_select 'a.icon.reaction-button.reacted[href=?]', href do @@ -194,7 +194,7 @@ class ReactionsHelperTest < ActionView::TestCase end tooltip = 'Dave Lopper, John Smith, and Redmine Admin' - assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do + assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do href = reactions_path(object_type: 'Issue', object_id: 1) assert_select 'a.icon.reaction-button[href=?]', href do diff --git a/test/system/reactions_test.rb b/test/system/reactions_test.rb index 8cf849320..cd3e2e871 100644 --- a/test/system/reactions_test.rb +++ b/test/system/reactions_test.rb @@ -113,6 +113,47 @@ class ReactionsSystemTest < ApplicationSystemTestCase end end + def test_reaction_button_is_visible_on_property_changes_tab + # Create a journal with no notes + journal_without_notes = Journal.generate!(journalized: issues(:issues_001), notes: '', details: [JournalDetail.new]) + + log_user('jsmith', 'jsmith') + + visit '/issues/1?tab=properties' + + # Scroll to the history content + click_link '#1' + + assert_selector '#tab-properties.selected' + + within('#change-1') do + assert_selector 'a.reaction-button' + + assert_no_selector 'a.icon-comment' + assert_no_selector 'span.drdn' + end + within("#change-#{journal_without_notes.id}") do + assert_selector 'a.reaction-button' + + assert_no_selector '.drdn' + end + + click_link 'History' + + within('#change-1') do + assert_selector 'a.reaction-button' + + assert_selector 'a.icon-comment' + assert_selector 'span.drdn' + end + within("#change-#{journal_without_notes.id}") do + assert_selector 'a.reaction-button' + assert_selector 'span.drdn' + + assert_no_selector 'a.icon-comment' + end + end + private def assert_reaction_add_and_remove(reaction_button, expected_subject) |