diff options
Diffstat (limited to 'app/views/projects/diffs')
-rw-r--r-- | app/views/projects/diffs/_email_line.html.haml | 21 | ||||
-rw-r--r-- | app/views/projects/diffs/_file_header.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/diffs/_line.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/diffs/_text_file.html.haml | 36 |
4 files changed, 56 insertions, 5 deletions
diff --git a/app/views/projects/diffs/_email_line.html.haml b/app/views/projects/diffs/_email_line.html.haml new file mode 100644 index 00000000000..dfff143196c --- /dev/null +++ b/app/views/projects/diffs/_email_line.html.haml @@ -0,0 +1,21 @@ +-# This template is used when rendering diffs in email notifications +-# Called inside: app/views/notify/repository_push_email.html.haml +-# app/views/notify/_note_email.html.haml + +%tr.line_holder{ class: line.type } + - case line.type + - when 'match' + = diff_match_line line.old_pos, line.new_pos, text: line.text + - when 'old-nonewline', 'new-nonewline' + %td.old_line.diff-line-num + %td.new_line.diff-line-num + %td.line_content.match= line.text + - else + %td.old_line.diff-line-num{ class: line.type, data: { linenumber: line.old_pos } } + = diff_link_number(line.type, "new", line.old_pos) + + %td.new_line.diff-line-num{ class: line.type, data: { linenumber: line.new_pos } } + = diff_link_number(line.type, "old", line.new_pos) + + %td.line_content{ class: line.type }< + %pre= line.rich_text diff --git a/app/views/projects/diffs/_file_header.html.haml b/app/views/projects/diffs/_file_header.html.haml index d1792826522..afca27c5430 100644 --- a/app/views/projects/diffs/_file_header.html.haml +++ b/app/views/projects/diffs/_file_header.html.haml @@ -36,5 +36,5 @@ #{diff_file.a_mode} → #{diff_file.b_mode} - if diff_file.stored_externally? && diff_file.external_storage == :lfs - %span.badge.label-lfs.gl-mr-2 LFS + = gl_badge_tag(_('LFS'), variant: :neutral) diff --git a/app/views/projects/diffs/_line.html.haml b/app/views/projects/diffs/_line.html.haml index de7f9eba158..330e2f564c9 100644 --- a/app/views/projects/diffs/_line.html.haml +++ b/app/views/projects/diffs/_line.html.haml @@ -1,3 +1,5 @@ +-# This file is deprecated in favour of inline rendering: +-# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57237 - plain = local_assigns.fetch(:plain, false) - discussions = local_assigns.fetch(:discussions, nil) - line_code = diff_file.line_code(line) diff --git a/app/views/projects/diffs/_text_file.html.haml b/app/views/projects/diffs/_text_file.html.haml index bf946b0ce73..6e7e0244721 100644 --- a/app/views/projects/diffs/_text_file.html.haml +++ b/app/views/projects/diffs/_text_file.html.haml @@ -4,10 +4,38 @@ %a.show-suppressed-diff.cursor-pointer.js-show-suppressed-diff= _("Changes suppressed. Click to show.") %table.text-file.diff-wrap-lines.code.code-commit.js-syntax-highlight.commit-diff{ data: diff_view_data, class: too_big ? 'hide' : '' } - = render partial: "projects/diffs/line", - collection: diff_file.highlighted_diff_lines, - as: :line, - locals: { diff_file: diff_file, discussions: @grouped_diff_discussions } + - if Feature.enabled?(:inline_haml_diff_line_rendering, @project, default_enabled: :yaml) + - diff_file.highlighted_diff_lines.each do |line| + - line_code = diff_file.line_code(line) + + %tr.line_holder{ class: line.type, id: line_code } + - case line.type + - when 'match' + = diff_match_line line.old_pos, line.new_pos, text: line.text + - when 'old-nonewline', 'new-nonewline' + %td.old_line.diff-line-num + %td.new_line.diff-line-num + %td.line_content.match= line.text + - else + %td.old_line.diff-line-num{ class: "#{line.type} js-avatar-container", data: { linenumber: line.old_pos } } + = add_diff_note_button(line_code, diff_file.position(line), line.type) + %a{ href: "##{line_code}", data: { linenumber: diff_link_number(line.type, "new", line.old_pos) } } + + %td.new_line.diff-line-num{ class: line.type, data: { linenumber: line.new_pos } } + %a{ href: "##{line_code}", data: { linenumber: diff_link_number(line.type, "old", line.new_pos) } } + + %td.line_content{ class: line.type }< + = diff_line_content(line.rich_text) + + - if line.discussable? && @grouped_diff_discussions.present? && @grouped_diff_discussions[line_code] + - line_discussions = @grouped_diff_discussions[line_code] + = render "discussions/diff_discussion", discussions: line_discussions, expanded: line_discussions.any?(&:expanded?) + + - else + = render partial: "projects/diffs/line", + collection: diff_file.highlighted_diff_lines, + as: :line, + locals: { diff_file: diff_file, discussions: @grouped_diff_discussions } - if !diff_file.new_file? && !diff_file.deleted_file? && diff_file.highlighted_diff_lines.any? - last_line = diff_file.highlighted_diff_lines.last |