mirror of
https://github.com/gitlabhq/gitlabhq.git
synced 2025-08-01 16:46:16 +00:00
Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
- @directions.each do |direction|
|
||||
%button
|
||||
%button.rd-expand-lines-button{ type: "button" }
|
||||
= helpers.sprite_icon(icon_name(direction))
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
- if @diff_hunk.header
|
||||
%tr
|
||||
%td{ colspan: '2' }= render RapidDiffs::Viewers::Text::ExpandLinesComponent.new(directions: @diff_hunk.expand_directions)
|
||||
%td= @diff_hunk.header_text
|
||||
%tr.rd-hunk-header.rd-hunk-header-inline
|
||||
%td.rd-hunk-header-buttons{ colspan: '2' }= render RapidDiffs::Viewers::Text::ExpandLinesComponent.new(directions: @diff_hunk.expand_directions)
|
||||
%td.rd-hunk-header-content= @diff_hunk.header_text
|
||||
|
||||
- @diff_hunk.lines.each do |line|
|
||||
%tr
|
||||
%tr.rd-hunk-lines.rd-hunk-lines-inline
|
||||
= render RapidDiffs::Viewers::Text::LineNumberComponent.new(diff_file: @diff_file, line: line, position: :old)
|
||||
= render RapidDiffs::Viewers::Text::LineNumberComponent.new(diff_file: @diff_file, line: line, position: :new)
|
||||
%td= line.text_content
|
||||
= render RapidDiffs::Viewers::Text::LineNumberComponent.new(diff_file: @diff_file, line: line, position: :new, border: :right)
|
||||
= render RapidDiffs::Viewers::Text::LineContentComponent.new(line: line, position: nil)
|
||||
|
@ -1,8 +1,8 @@
|
||||
%table
|
||||
%table.rd-text-view-root
|
||||
%thead.gl-sr-only
|
||||
%tr
|
||||
- column_titles.each do |title|
|
||||
%th= title
|
||||
%tbody
|
||||
%tbody.rd-text-view-content
|
||||
- @diff_file.viewer_hunks.each do |hunk|
|
||||
= render RapidDiffs::Viewers::Text::InlineHunkComponent.new(diff_hunk: hunk, diff_file: @diff_file)
|
||||
|
@ -0,0 +1 @@
|
||||
%td.rd-line-content{ data: { change: change_type, position: @position }, tabindex: '-1' }= @line.text_content if @line
|
@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RapidDiffs
|
||||
module Viewers
|
||||
module Text
|
||||
class LineContentComponent < ViewComponent::Base
|
||||
def initialize(line:, position:)
|
||||
@line = line
|
||||
@position = position
|
||||
end
|
||||
|
||||
def change_type
|
||||
return unless @line
|
||||
|
||||
return 'added' if @line.added?
|
||||
|
||||
'removed' if @line.removed?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
- if visible?
|
||||
%td{ id: id, data: { legacy_id: legacy_id } }
|
||||
= link_to line_number, "##{id}", { data: { line_number: line_number } }
|
||||
%td.rd-line-number{ id: id, class: border_class, data: { legacy_id: legacy_id, change: change_type } }
|
||||
= link_to '', "##{id}", { class: 'rd-line-link', data: { line_number: line_number }, aria: { label: s_('Line number %{number}').html_safe % { number: line_number } } }
|
||||
- else
|
||||
%td
|
||||
%td.rd-line-number{ class: border_class, data: { change: change_type } }
|
||||
|
@ -4,10 +4,11 @@ module RapidDiffs
|
||||
module Viewers
|
||||
module Text
|
||||
class LineNumberComponent < ViewComponent::Base
|
||||
def initialize(diff_file:, line:, position:)
|
||||
def initialize(diff_file:, line:, position:, border: nil)
|
||||
@diff_file = diff_file
|
||||
@line = line
|
||||
@position = position
|
||||
@border = border
|
||||
end
|
||||
|
||||
def id
|
||||
@ -22,7 +23,24 @@ module RapidDiffs
|
||||
@diff_file.line_code(@line)
|
||||
end
|
||||
|
||||
def change_type
|
||||
return unless @line
|
||||
|
||||
return 'added' if @line.added?
|
||||
|
||||
'removed' if @line.removed?
|
||||
end
|
||||
|
||||
def border_class
|
||||
case @border
|
||||
when :right then 'rd-line-number-border-right'
|
||||
when :both then 'rd-line-number-border-both'
|
||||
end
|
||||
end
|
||||
|
||||
def visible?
|
||||
return false unless @line
|
||||
|
||||
case @position
|
||||
when :old then !@line.added?
|
||||
when :new then !@line.removed?
|
||||
|
@ -1,16 +1,12 @@
|
||||
- if @diff_hunk.header
|
||||
%tr
|
||||
- 2.times do
|
||||
%td= render RapidDiffs::Viewers::Text::ExpandLinesComponent.new(directions: @diff_hunk.expand_directions)
|
||||
%td= @diff_hunk.header_text
|
||||
%tr.rd-hunk-header.rd-hunk-header-parallel
|
||||
- 2.times do |index|
|
||||
%td.rd-hunk-header-buttons= render RapidDiffs::Viewers::Text::ExpandLinesComponent.new(directions: @diff_hunk.expand_directions)
|
||||
%td.rd-hunk-header-content{ data: { position: index == 0 ? :old : :new }, tabindex: '-1' }= @diff_hunk.header_text
|
||||
|
||||
- @diff_hunk.parallel_lines.each do |pair|
|
||||
%tr
|
||||
- [pair[:left], pair[:right]].each_with_index do |line, index|
|
||||
- if line
|
||||
- position = index == 0 ? :old : :new
|
||||
= render RapidDiffs::Viewers::Text::LineNumberComponent.new(diff_file: @diff_file, line: line, position: position)
|
||||
%td= line.text_content
|
||||
- else
|
||||
%td
|
||||
%td
|
||||
%tr.rd-hunk-lines.rd-hunk-lines-parallel
|
||||
- sides(pair).each do |side|
|
||||
- line, position = side.values_at(:line, :position)
|
||||
= render RapidDiffs::Viewers::Text::LineNumberComponent.new(diff_file: @diff_file, **side)
|
||||
= render RapidDiffs::Viewers::Text::LineContentComponent.new(line: line, position: position)
|
||||
|
@ -8,6 +8,21 @@ module RapidDiffs
|
||||
@diff_hunk = diff_hunk
|
||||
@diff_file = diff_file
|
||||
end
|
||||
|
||||
def sides(line_pair)
|
||||
[
|
||||
{
|
||||
line: line_pair[:left],
|
||||
position: :old,
|
||||
border: :right
|
||||
},
|
||||
{
|
||||
line: line_pair[:right],
|
||||
position: :new,
|
||||
border: :both
|
||||
}
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,8 @@
|
||||
%table
|
||||
%table.rd-text-view-root
|
||||
%thead.gl-sr-only
|
||||
%tr
|
||||
- column_titles.each do |title|
|
||||
%th= title
|
||||
%tbody
|
||||
%tbody.rd-text-view-content
|
||||
- @diff_file.viewer_hunks.each do |hunk|
|
||||
= render RapidDiffs::Viewers::Text::ParallelHunkComponent.new(diff_hunk: hunk, diff_file: @diff_file)
|
||||
|
Reference in New Issue
Block a user