Project

General

Profile

Feature #42630 » Allow-reactions-to-journals-with-only-property-changes.patch

Katsuya HIDAKA, 2025-05-16 12:16

View differences:

app/assets/javascripts/application-legacy.js
426 426
      tab_content.find('.journal').show();
427 427
      tab_content.find('.journal:not(.has-notes)').hide();
428 428
      tab_content.find('.journal .wiki').show();
429
      tab_content.find('.journal .contextual .journal-actions').show();
429
      tab_content.find('.journal .contextual .journal-actions > *').show();
430 430

  
431 431
      // always show thumbnails in notes tab
432 432
      var thumbnails = tab_content.find('.journal .thumbnails');
......
439 439
      tab_content.find('.journal:not(.has-details)').hide();
440 440
      tab_content.find('.journal .wiki').hide();
441 441
      tab_content.find('.journal .thumbnails').hide();
442
      tab_content.find('.journal .contextual .journal-actions').hide();
442
      tab_content.find('.journal .contextual .journal-actions > *').hide();
443
      // Show reaction button in properties tab
444
      tab_content.find('.journal .contextual .journal-actions .reaction-button-wrapper').show();
443 445
      break;
444 446
    default:
445 447
      tab_content.find('.journal').show();
446 448
      tab_content.find('.journal .wiki').show();
447 449
      tab_content.find('.journal .thumbnails').show();
448
      tab_content.find('.journal .contextual .journal-actions').show();
450
      tab_content.find('.journal .contextual .journal-actions > *').show();
449 451
  }
450 452

  
451 453
  return false;
app/helpers/journals_helper.rb
41 41
                               )
42 42
    end
43 43

  
44
    if journal.notes.present?
45
      links << reaction_button(journal)
44
    links << reaction_button(journal)
46 45

  
46
    if journal.notes.present?
47 47
      if options[:reply_links]
48 48
        url = quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice)
49 49
        links << quote_reply(url, "#journal-#{journal.id}-notes", icon_only: true)
app/helpers/reactions_helper.rb
82 82
  end
83 83

  
84 84
  def reaction_button_wrapper(object, &)
85
    tag.span(data: { 'reaction-button-id': reaction_id_for(object) }, &)
85
    tag.span(class: 'reaction-button-wrapper', data: { 'reaction-button-id': reaction_id_for(object) }, &)
86 86
  end
87 87

  
88 88
  def build_reaction_tooltip(visible_user_names, count)
test/helpers/journals_helper_test.rb
51 51
    assert_select_in journal_actions, 'a[title=?][class="icon-only icon-edit"]', 'Edit'
52 52
    assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-del"]'
53 53
    assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-copy-link"]'
54
    assert_select_in journal_actions, 'span.reaction-button-wrapper'
55
  end
56

  
57
  def test_render_journal_actions_with_journal_without_notes
58
    User.current = User.find(1)
59
    issue = Issue.find(1)
60
    issue.journals.first.update!(notes: '')
61

  
62
    journals = issue.visible_journals_with_index
63

  
64
    journal_actions = render_journal_actions(issue, journals.first, reply_links: true)
65

  
66
    assert_select_in journal_actions, 'span.reaction-button-wrapper'
67
    assert_select_in journal_actions, 'span.drdn'
68

  
69
    assert_select_in journal_actions, 'a[class="icon-comment"]', false
70
    assert_select_in journal_actions, 'a[class="icon-edit"]', false
54 71
  end
55 72

  
56 73
  def test_journal_thumbnail_attachments_should_be_in_the_same_order_as_the_journal_details
test/helpers/reactions_helper_test.rb
172 172
    end
173 173
    tooltip = 'Dave Lopper, John Smith, and Redmine Admin'
174 174

  
175
    assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do
175
    assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do
176 176
      href = reaction_path(issue.reaction_detail.user_reaction, object_type: 'Issue', object_id: 1)
177 177

  
178 178
      assert_select 'a.icon.reaction-button.reacted[href=?]', href do
......
194 194
    end
195 195
    tooltip = 'Dave Lopper, John Smith, and Redmine Admin'
196 196

  
197
    assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do
197
    assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do
198 198
      href = reactions_path(object_type: 'Issue', object_id: 1)
199 199

  
200 200
      assert_select 'a.icon.reaction-button[href=?]', href do
test/system/reactions_test.rb
113 113
    end
114 114
  end
115 115

  
116
  def test_reaction_button_is_visible_on_property_changes_tab
117
    # Create a journal with no notes
118
    journal_without_notes = Journal.generate!(journalized: issues(:issues_001), notes: '', details: [JournalDetail.new])
119

  
120
    log_user('jsmith', 'jsmith')
121

  
122
    visit '/issues/1?tab=properties'
123

  
124
    # Scroll to the history content
125
    click_link '#1'
126

  
127
    assert_selector '#tab-properties.selected'
128

  
129
    within('#change-1') do
130
      assert_selector 'a.reaction-button'
131

  
132
      assert_no_selector 'a.icon-comment'
133
      assert_no_selector 'span.drdn'
134
    end
135
    within("#change-#{journal_without_notes.id}") do
136
      assert_selector 'a.reaction-button'
137

  
138
      assert_no_selector '.drdn'
139
    end
140

  
141
    click_link 'History'
142

  
143
    within('#change-1') do
144
      assert_selector 'a.reaction-button'
145

  
146
      assert_selector 'a.icon-comment'
147
      assert_selector 'span.drdn'
148
    end
149
    within("#change-#{journal_without_notes.id}") do
150
      assert_selector 'a.reaction-button'
151
      assert_selector 'span.drdn'
152

  
153
      assert_no_selector 'a.icon-comment'
154
    end
155
  end
156

  
116 157
  private
117 158

  
118 159
  def assert_reaction_add_and_remove(reaction_button, expected_subject)
(24-24/26)