diff --git a/app/views/projects/commits/_parallel_view.html.haml b/app/views/projects/commits/_parallel_view.html.haml index 80f5be98f2f..3bbe8b4baaf 100644 --- a/app/views/projects/commits/_parallel_view.html.haml +++ b/app/views/projects/commits/_parallel_view.html.haml @@ -1,38 +1,18 @@ / Side-by-side diff view -- old_lines, new_lines = parallel_diff_lines(project, @commit, diff, file) -- num_lines = old_lines.length - %div.text-file %table - - num_lines.times do |index| - - new_line = new_lines[index] - - old_line = old_lines[index] - %tr.line_holder.parallel - -# For old line - - if old_line.type == :file_created - %td.old_line= old_line.num - %td.line_content.parallel= "File was created" - - elsif old_line.type == :deleted - %td.old_line.old= old_line.num - %td.line_content{class: "parallel noteable_line old #{old_line.code}", "line_code" => old_line.code}= old_line.content - - else old_line.type == :no_change - %td.old_line= old_line.num - %td.line_content.parallel= old_line.content - - -# For new line - - if new_line.type == :file_deleted - %td.new_line= new_line.num - %td.line_content.parallel= "File was deleted" - - elsif new_line.type == :added - %td.new_line.new= new_line.num - %td.line_content{class: "parallel noteable_line new #{new_line.code}", "line_code" => new_line.code}= new_line.content - - else new_line.type == :no_change - %td.new_line= new_line.num - %td.line_content.parallel= new_line.content - - - if @reply_allowed - - comments1 = @line_notes.select { |n| n.line_code == old_line.code }.sort_by(&:created_at) - - comments2 = @line_notes.select { |n| n.line_code == new_line.code }.sort_by(&:created_at) - - unless comments1.empty? and comments2.empty? - = render "projects/notes/diff_notes_with_reply_parallel", notes1: comments1, notes2: comments2 - + - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line, e| + %tr.line_holder.parallel{ id: line_code, class: "#{type}" } + - if type != 'match' + %td.old_line + = link_to raw(type == "new" ? " " : line_old), "##{line_code}", id: line_code + - if type == 'old' + %td.line_content{class: "parallel noteable_line old #{line_code}", "line_code" => line_code}= line + - else + %td.line_content.parallel= line + %td.new_line{data: {linenumber: line_new}} + = link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code + - if type == 'new' + %td.line_content.parallel{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= line + - else + %td.line_content.parallel= line