0003-move-changesets-to-its-own-tab.patch

Marius BALTEANU, 2019-06-20 08:19

Download (8.5 KB)

View differences:

app/helpers/issues_helper.rb
553 553
      journals_without_notes = @journals.select{|value| value.notes.blank?}
554 554
      journals_with_notes = @journals.reject{|value| value.notes.blank?}
555 555

  
556
      tabs << {:name => 'history', :label => :label_history, :onclick => 'showIssueHistory("history", this.href)', :partial => 'history', :locals => {:issue => @issue, :journals => @journals}}
556
      tabs << {:name => 'history', :label => :label_history, :onclick => 'showIssueHistory("history", this.href)', :partial => 'issues/tabs/history', :locals => {:issue => @issue, :journals => @journals}}
557 557
      tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any?
558 558
      tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any?
559 559
    end
560
    tabs << {:name => 'changesets', :label => :label_associated_revisions, :partial => 'issues/tabs/changesets', :locals => {:changesets => @changesets}} if @changesets.present?
560 561
    tabs
561 562
  end
562 563
end
app/views/issues/_history.html.erb
1
<%
2
  issue = tab[:locals][:issue]
3
  journals = tab[:locals][:journals]
4
%>
5

  
6
<% reply_links = issue.notes_addable? -%>
7
<% for journal in journals %>
8
  <div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
9
    <div id="note-<%= journal.indice %>">
10
    <div class="contextual">
11
      <span class="journal-actions"><%= render_journal_actions(issue, journal, :reply_links => reply_links) %></span>
12
      <a href="#note-<%= journal.indice %>" class="journal-link">#<%= journal.indice %></a>
13
    </div>
14
    <h4>
15
      <%= avatar(journal.user) %>
16
      <%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
17
      <%= render_private_notes_indicator(journal) %>
18
    </h4>
19

  
20
    <% if journal.details.any? %>
21
    <ul class="details">
22
      <% details_to_strings(journal.visible_details).each do |string| %>
23
       <li><%= string %></li>
24
      <% end %>
25
    </ul>
26
    <% if Setting.thumbnails_enabled? && (thumbnail_attachments = journal_thumbnail_attachments(journal)).any? %>
27
      <div class="thumbnails">
28
        <% thumbnail_attachments.each do |attachment| %>
29
          <div><%= thumbnail_tag(attachment) %></div>
30
        <% end %>
31
      </div>
32
    <% end %>
33
    <% end %>
34
    <%= render_notes(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %>
35
    </div>
36
  </div>
37
  <%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
38
<% end %>
39

  
40
<% heads_for_wiki_formatter if User.current.allowed_to?(:edit_issue_notes, issue.project) || User.current.allowed_to?(:edit_own_issue_notes, issue.project) %>
app/views/issues/show.html.erb
122 122

  
123 123
<%= render partial: 'action_menu_edit' if User.current.wants_comments_in_reverse_order? %>
124 124

  
125
<% if @changesets.present? %>
126
<div id="issue-changesets">
127
<h3><%=l(:label_associated_revisions)%></h3>
128
<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
129
</div>
130
<% end %>
131

  
132
<%= render partial: 'action_menu_edit' if User.current.wants_comments_in_reverse_order? %>
133

  
134 125
<div id="history">
135 126
<h3><%=l(:label_history)%></h3>
136 127
<%= render_tabs issue_history_tabs, params[:tab] ? params[:tab] : 'notes' %>
app/views/issues/tabs/_changesets.html.erb
1
<% tab[:locals][:changesets].each do |changeset| %>
2
  <div id="changeset-<%= changeset.id %>" class="changeset journal">
3
    <h4>
4
      <%= avatar(changeset.user, :size => "24") %>
5
      <%= authoring changeset.committed_on, changeset.author, :label => :label_added_time_by %>
6
    </h4>
7
    <p><%= link_to_revision(changeset, changeset.repository,
8
                        :text => "#{l(:label_revision)} #{changeset.format_identifier}") %>
9
    <% if changeset.filechanges.any? && User.current.allowed_to?(:browse_repository, changeset.project) %>
10
    (<%= link_to(l(:label_diff),
11
           :controller => 'repositories',
12
           :action => 'diff',
13
           :id     => changeset.project,
14
           :repository_id => changeset.repository.identifier_param,
15
           :path   => "",
16
           :rev    => changeset.identifier) %>)
17
    <% end %></p>
18

  
19
    <div class="wiki changeset-comments">
20
      <%= format_changeset_comments changeset %>
21
    </div>
22
  </div>
23
  <%= call_hook(:view_issues_history_changeset_bottom, { :changeset => changeset }) %>
24
<% end %>
app/views/issues/tabs/_history.html.erb
1
<%
2
  issue = tab[:locals][:issue]
3
  journals = tab[:locals][:journals]
4
%>
5

  
6
<% reply_links = issue.notes_addable? -%>
7
<% for journal in journals %>
8
  <div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
9
    <div id="note-<%= journal.indice %>">
10
    <div class="contextual">
11
      <span class="journal-actions"><%= render_journal_actions(issue, journal, :reply_links => reply_links) %></span>
12
      <a href="#note-<%= journal.indice %>" class="journal-link">#<%= journal.indice %></a>
13
    </div>
14
    <h4>
15
      <%= avatar(journal.user) %>
16
      <%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
17
      <%= render_private_notes_indicator(journal) %>
18
    </h4>
19

  
20
    <% if journal.details.any? %>
21
    <ul class="details">
22
      <% details_to_strings(journal.visible_details).each do |string| %>
23
       <li><%= string %></li>
24
      <% end %>
25
    </ul>
26
    <% if Setting.thumbnails_enabled? && (thumbnail_attachments = journal_thumbnail_attachments(journal)).any? %>
27
      <div class="thumbnails">
28
        <% thumbnail_attachments.each do |attachment| %>
29
          <div><%= thumbnail_tag(attachment) %></div>
30
        <% end %>
31
      </div>
32
    <% end %>
33
    <% end %>
34
    <%= render_notes(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %>
35
    </div>
36
  </div>
37
  <%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
38
<% end %>
39

  
40
<% heads_for_wiki_formatter if User.current.allowed_to?(:edit_issue_notes, issue.project) || User.current.allowed_to?(:edit_own_issue_notes, issue.project) %>
test/functional/issues_controller_test.rb
2513 2513
    end
2514 2514
  end
2515 2515

  
2516
  def test_show_display_changesets_tab_for_issue_with_changesets
2517
    project = Project.find(2)
2518
    issue = Issue.find(3)
2519
    issue.changeset_ids = [102]
2520
    issue.save!
2521

  
2522
    @request.session[:user_id] = 2
2523
    get :show, :params => {:id => 3}
2524

  
2525
    assert_select '#history' do
2526
      assert_select 'div.tabs ul a', 1
2527
      assert_select 'div.tabs a[id=?]', 'tab-changesets', :text => 'Associated revisions'
2528
    end
2529
  end
2530

  
2516 2531
  def test_get_new
2517 2532
    @request.session[:user_id] = 2
2518 2533
    get :new, :params => {
2519
-