summaryrefslogtreecommitdiff
path: root/app/views/projects/diffs/_parallel_view.html.haml
blob: 51f207dce949ac8ffc13536db5fc855cd953d009 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/ Side-by-side diff view
%div.text-file.diff-wrap-lines.code.file-content.js-syntax-highlight
  %table
    - diff_file.parallel_diff_lines.each do |line|
      - left = line[:left]
      - right = line[:right]
      %tr.line_holder.parallel
        - if left[:type] == 'match'
          = render "projects/diffs/match_line_parallel", { line: left[:text],
          line_old: left[:number], line_new: right[:number] }
        - elsif left[:type] == 'nonewline'
          %td.old_line.diff-line-num
          %td.line_content.parallel.match= left[:text]
          %td.new_line.diff-line-num
          %td.line_content.parallel.match= left[:text]
        - else
          %td.old_line.diff-line-num{id: left[:line_code], class: [left[:type], ('empty-cell' unless left[:number])]}
            = link_to raw(left[:number]), "##{left[:line_code]}", id: left[:line_code]
            - if !@diff_notes_disabled && can?(current_user, :create_note, @project)
              = link_to_new_diff_note(left[:line_code], left[:position], 'old')
          %td.line_content.parallel.noteable_line{class: [left[:type], left[:line_code], ('empty-cell' if left[:text].empty?)], data: { line_code: left[:line_code], position: left[:position].to_json }}= diff_line_content(left[:text])

          - if right[:type] == 'new'
            - new_line_class = 'new'
            - new_line_code = right[:line_code]
            - new_position = right[:position]
          - else
            - new_line_class = nil
            - new_line_code = left[:line_code]
            - new_position = left[:position]

          %td.new_line.diff-line-num{id: new_line_code, class: [new_line_class, ('empty-cell' unless right[:number])], data: { linenumber: right[:number] }}
            = link_to raw(right[:number]), "##{new_line_code}", id: new_line_code
            - if !@diff_notes_disabled && can?(current_user, :create_note, @project)
              = link_to_new_diff_note(new_line_code, new_position, 'new')
          %td.line_content.parallel.noteable_line{class: [new_line_class, new_line_code, ('empty-cell' if right[:text].empty?)], data: { line_code: new_line_code, position: new_position.to_json }}= diff_line_content(right[:text])

      - unless @diff_notes_disabled
        - notes_left, notes_right = organize_comments(left, right)
        - if notes_left.present? || notes_right.present?
          = render "projects/notes/diff_notes_with_reply_parallel", notes_left: notes_left, notes_right: notes_right