03_move-changesets-to-its-own-tab_v2.patch

Marius BALTEANU, 2017-07-02 10:56

Download (7.33 KB)

View differences:

app/helpers/issues_helper.rb
548 548
      journals_without_notes = @journals.select{|value| value.notes.blank?}
549 549
      journals_with_notes = @journals.reject{|value| value.notes.blank?}
550
      tabs << {:name => 'history', :label => :label_history, :onclick => 'showIssueHistory("history", this.href)', :partial => 'history', :locals => {:issue => @issue, :journals => @journals}}
550
      tabs << {:name => 'history', :label => :label_history, :onclick => 'showIssueHistory("history", this.href)', :partial => 'issues/tabs/history', :locals => {:issue => @issue, :journals => @journals}}
551 551
      tabs << {:name => 'notes', :label => :label_issue_history_notes, :onclick => 'showIssueHistory("notes", this.href)'} if journals_with_notes.any?
552 552
      tabs << {:name => 'properties', :label => :label_issue_history_properties, :onclick => 'showIssueHistory("properties", this.href)'} if journals_without_notes.any?
553 553
    end
554
    tabs << {:name => 'changesets', :label => :label_associated_revisions, :partial => 'issues/tabs/changesets', :locals => {:changesets => @changesets}} if @changesets.present?
554 555
    tabs
555 556
  end
556 557
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
    <h4><a href="#note-<%= journal.indice %>" class="journal-link">#<%= journal.indice %></a>
11
    <%= avatar(journal.user, :size => "24") %>
12
    <%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
13
    <%= render_private_notes_indicator(journal) %></h4>
14

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

  
35
<% 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
118 118
</div>
119
<% if @changesets.present? %>
120
<div id="issue-changesets">
121
<h3><%=l(:label_associated_revisions)%></h3>
122
<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
123
</div>
124
<% end %>
125

  
126 119
<div id="history">
127 120
<h3><%=l(:label_history)%></h3>
128 121
<%= 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
    <h4><a href="#note-<%= journal.indice %>" class="journal-link">#<%= journal.indice %></a>
11
    <%= avatar(journal.user, :size => "24") %>
12
    <%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
13
    <%= render_private_notes_indicator(journal) %></h4>
14

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

  
35
<% 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
2302 2302
    end
2303 2303
  end
2304
  def test_show_display_changesets_tab_for_issue_with_changesets
2305
    project = Project.find(2)
2306
    issue = Issue.find(3)
2307
    issue.changeset_ids = [102]
2308
    issue.save!
2309

  
2310
    @request.session[:user_id] = 2
2311
    get :show, :params => {:id => 3}
2312

  
2313
    assert_select '#history' do
2314
      assert_select 'div.tabs ul a', 1
2315
      assert_select 'div.tabs a[id=?]', 'tab-changesets', :text => 'Associated revisions'
2316
    end
2317
  end
2318

  
2304 2319
  def test_get_new
2305 2320
    @request.session[:user_id] = 2
2306 2321
    get :new, :params => {