2013-11-27 08:00:14 +00:00
|
|
|
/ Side-by-side diff view
|
2017-06-12 18:43:21 +00:00
|
|
|
|
2016-12-23 09:37:12 +00:00
|
|
|
.text-file.diff-wrap-lines.code.js-syntax-highlight{ data: diff_view_data }
|
2014-04-24 08:49:01 +00:00
|
|
|
%table
|
2016-01-20 13:51:56 +00:00
|
|
|
- diff_file.parallel_diff_lines.each do |line|
|
2016-01-14 13:52:08 +00:00
|
|
|
- left = line[:left]
|
|
|
|
- right = line[:right]
|
2017-03-08 16:07:26 +00:00
|
|
|
- last_line = right.new_pos if right
|
2017-03-31 23:39:14 +00:00
|
|
|
- discussions_left, discussions_right = parallel_diff_discussions(left, right, diff_file)
|
2016-07-01 05:09:56 +00:00
|
|
|
%tr.line_holder.parallel
|
2016-07-20 22:18:18 +00:00
|
|
|
- if left
|
2017-01-18 22:40:34 +00:00
|
|
|
- case left.type
|
|
|
|
- when 'match'
|
2016-07-21 18:44:12 +00:00
|
|
|
= diff_match_line left.old_pos, nil, text: left.text, view: :parallel
|
2017-03-13 20:09:43 +00:00
|
|
|
- when 'old-nonewline', 'new-nonewline'
|
2017-01-18 22:40:34 +00:00
|
|
|
%td.old_line.diff-line-num
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.line_content.match.left-side= left.text
|
2016-07-20 22:18:18 +00:00
|
|
|
- else
|
|
|
|
- left_line_code = diff_file.line_code(left)
|
|
|
|
- left_position = diff_file.position(left)
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.old_line.diff-line-num.js-avatar-container{ class: left.type, data: { linenumber: left.old_pos } }
|
2017-06-12 18:43:21 +00:00
|
|
|
= add_diff_note_button(left_line_code, left_position, 'old')
|
2017-01-23 00:07:41 +00:00
|
|
|
%a{ href: "##{left_line_code}", data: { linenumber: left.old_pos } }
|
2017-03-31 02:34:14 +00:00
|
|
|
- discussion_left = discussions_left.try(:first)
|
2017-03-09 08:53:47 +00:00
|
|
|
- if discussion_left && discussion_left.resolvable?
|
2017-03-08 16:07:26 +00:00
|
|
|
%diff-note-avatars{ "discussion-id" => discussion_left.id }
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.line_content.parallel.noteable_line.left-side{ id: left_line_code, class: left.type }= diff_line_content(left.text)
|
2016-01-14 13:52:08 +00:00
|
|
|
- else
|
2016-07-20 22:18:18 +00:00
|
|
|
%td.old_line.diff-line-num.empty-cell
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.line_content.parallel.left-side
|
2014-09-12 16:43:44 +00:00
|
|
|
|
2016-07-20 22:18:18 +00:00
|
|
|
- if right
|
2017-01-18 22:40:34 +00:00
|
|
|
- case right.type
|
|
|
|
- when 'match'
|
2016-07-21 18:44:12 +00:00
|
|
|
= diff_match_line nil, right.new_pos, text: left.text, view: :parallel
|
2017-03-13 20:09:43 +00:00
|
|
|
- when 'old-nonewline', 'new-nonewline'
|
2017-01-18 22:40:34 +00:00
|
|
|
%td.new_line.diff-line-num
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.line_content.match.right-side= right.text
|
2014-09-12 16:43:44 +00:00
|
|
|
- else
|
2016-07-20 22:18:18 +00:00
|
|
|
- right_line_code = diff_file.line_code(right)
|
|
|
|
- right_position = diff_file.position(right)
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.new_line.diff-line-num.js-avatar-container{ class: right.type, data: { linenumber: right.new_pos } }
|
2017-06-12 18:43:21 +00:00
|
|
|
= add_diff_note_button(right_line_code, right_position, 'new')
|
2017-01-23 00:07:41 +00:00
|
|
|
%a{ href: "##{right_line_code}", data: { linenumber: right.new_pos } }
|
2017-03-31 02:34:14 +00:00
|
|
|
- discussion_right = discussions_right.try(:first)
|
2017-03-09 08:53:47 +00:00
|
|
|
- if discussion_right && discussion_right.resolvable?
|
2017-03-08 16:07:26 +00:00
|
|
|
%diff-note-avatars{ "discussion-id" => discussion_right.id }
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.line_content.parallel.noteable_line.right-side{ id: right_line_code, class: right.type }= diff_line_content(right.text)
|
2016-07-20 22:18:18 +00:00
|
|
|
- else
|
|
|
|
%td.old_line.diff-line-num.empty-cell
|
2017-09-28 14:55:25 +00:00
|
|
|
%td.line_content.parallel.right-side
|
2014-09-12 16:43:44 +00:00
|
|
|
|
2017-03-31 02:34:14 +00:00
|
|
|
- if discussions_left || discussions_right
|
|
|
|
= render "discussions/parallel_diff_discussion", discussions_left: discussions_left, discussions_right: discussions_right
|
2017-05-15 17:10:29 +00:00
|
|
|
- if !diff_file.new_file? && !diff_file.deleted_file? && diff_file.diff_lines.any?
|
2017-01-18 21:03:12 +00:00
|
|
|
- last_line = diff_file.diff_lines.last
|
2017-01-24 23:53:25 +00:00
|
|
|
- if last_line.new_pos < total_lines
|
|
|
|
%tr.line_holder.parallel
|
|
|
|
= diff_match_line last_line.old_pos, last_line.new_pos, bottom: true, view: :parallel
|