debian-mirror-gitlab/app/views/projects/diffs/_parallel_view.html.haml

53 lines
2.7 KiB
Text
Raw Normal View History

2015-04-26 12:48:37 +05:30
/ Side-by-side diff view
2017-09-10 17:25:29 +05:30
2019-07-07 11:18:12 +05:30
.text-file{ data: diff_view_data }
2019-09-04 21:01:54 +05:30
%table.diff-wrap-lines.code.code-commit.js-syntax-highlight
2016-01-29 22:53:50 +05:30
- diff_file.parallel_diff_lines.each do |line|
- left = line[:left]
- right = line[:right]
2017-08-17 22:00:37 +05:30
- discussions_left, discussions_right = parallel_diff_discussions(left, right, diff_file)
2015-04-26 12:48:37 +05:30
%tr.line_holder.parallel
2016-09-13 17:45:13 +05:30
- if left
2017-08-17 22:00:37 +05:30
- case left.type
- when 'match'
2016-09-13 17:45:13 +05:30
= diff_match_line left.old_pos, nil, text: left.text, view: :parallel
2017-08-17 22:00:37 +05:30
- when 'old-nonewline', 'new-nonewline'
%td.old_line.diff-line-num
2018-03-17 18:26:18 +05:30
%td.line_content.match.left-side= left.text
2016-09-13 17:45:13 +05:30
- else
- left_line_code = diff_file.line_code(left)
- left_position = diff_file.position(left)
2018-03-17 18:26:18 +05:30
%td.old_line.diff-line-num.js-avatar-container{ class: left.type, data: { linenumber: left.old_pos } }
2017-09-10 17:25:29 +05:30
= add_diff_note_button(left_line_code, left_position, 'old')
2017-08-17 22:00:37 +05:30
%a{ href: "##{left_line_code}", data: { linenumber: left.old_pos } }
2019-07-07 11:18:12 +05:30
%td.line_content.parallel.left-side{ id: left_line_code, class: left.type }= diff_line_content(left.rich_text)
2016-01-29 22:53:50 +05:30
- else
2016-09-13 17:45:13 +05:30
%td.old_line.diff-line-num.empty-cell
2018-03-17 18:26:18 +05:30
%td.line_content.parallel.left-side
2015-04-26 12:48:37 +05:30
2016-09-13 17:45:13 +05:30
- if right
2017-08-17 22:00:37 +05:30
- case right.type
- when 'match'
2016-09-13 17:45:13 +05:30
= diff_match_line nil, right.new_pos, text: left.text, view: :parallel
2017-08-17 22:00:37 +05:30
- when 'old-nonewline', 'new-nonewline'
%td.new_line.diff-line-num
2018-03-17 18:26:18 +05:30
%td.line_content.match.right-side= right.text
2015-04-26 12:48:37 +05:30
- else
2016-09-13 17:45:13 +05:30
- right_line_code = diff_file.line_code(right)
- right_position = diff_file.position(right)
2018-03-17 18:26:18 +05:30
%td.new_line.diff-line-num.js-avatar-container{ class: right.type, data: { linenumber: right.new_pos } }
2017-09-10 17:25:29 +05:30
= add_diff_note_button(right_line_code, right_position, 'new')
2017-08-17 22:00:37 +05:30
%a{ href: "##{right_line_code}", data: { linenumber: right.new_pos } }
2019-07-07 11:18:12 +05:30
%td.line_content.parallel.right-side{ id: right_line_code, class: right.type }= diff_line_content(right.rich_text)
2016-09-13 17:45:13 +05:30
- else
%td.old_line.diff-line-num.empty-cell
2018-03-17 18:26:18 +05:30
%td.line_content.parallel.right-side
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
- if discussions_left || discussions_right
= render "discussions/parallel_diff_discussion", discussions_left: discussions_left, discussions_right: discussions_right
2017-09-10 17:25:29 +05:30
- if !diff_file.new_file? && !diff_file.deleted_file? && diff_file.diff_lines.any?
2017-08-17 22:00:37 +05:30
- last_line = diff_file.diff_lines.last
- 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