BigW Consortium Gitlab

_parallel_view.html.haml 2.19 KB
Newer Older
1
/ Side-by-side diff view
2
%div.text-file.diff-wrap-lines
3
  %table
4
    - parallel_diff(diff_file, index).each do |line|
5 6 7
      - type_left = line[0]
      - line_number_left = line[1]
      - line_content_left = line[2]
8
      - line_code_left = line[3]
9 10 11 12
      - type_right = line[4]
      - line_number_right = line[5]
      - line_content_right = line[6]
      - line_code_right = line[7]
13

14
      %tr.line_holder.parallel
15
        - if type_left == 'match'
16
          = render "projects/diffs/match_line_parallel", { line: line_content_left,
Marin Jankovski committed
17 18
          line_old: line_number_left, line_new: line_number_right }
        - elsif type_left ==  'old' || type_left.nil?
19 20
          %td.old_line{id: line_code_left, class: "#{type_left}"}
            = link_to raw(line_number_left), "##{line_code_left}", id: line_code_left
21
            - if @comments_allowed && can?(current_user, :create_note, @project)
22
              = link_to_new_diff_note(line_code_left, 'old')
23
            %td.line_content{class: "parallel noteable_line #{type_left} #{line_code_left}", "line_code" => line_code_left }= raw line_content_left
24 25 26

          - if type_right == 'new'
            - new_line_class = 'new'
27
            - new_line_code = line_code_right
28 29
          - else
            - new_line_class = nil
30
            - new_line_code = line_code_left
31 32 33

          %td.new_line{id: new_line_code, class: "#{new_line_class}", data: { linenumber: line_number_right }}
            = link_to raw(line_number_right), "##{new_line_code}", id: new_line_code
34
            - if @comments_allowed && can?(current_user, :create_note, @project)
35
              = link_to_new_diff_note(line_code_right, 'new')
36 37 38
            %td.line_content.parallel{class: "noteable_line #{new_line_class} #{new_line_code}", "line_code" => new_line_code}= raw line_content_right

      - if @reply_allowed
39 40
        - comments_left, comments_right = organize_comments(type_left, type_right, line_code_left, line_code_right)
        - if comments_left.present? || comments_right.present?
41
          = render "projects/notes/diff_notes_with_reply_parallel", notes_left: comments_left, notes_right: comments_right
42

43
- if diff_file.diff.diff.blank? && diff_file.mode_changed?
44 45
  .file-mode-changed
    File mode changed