Commit 90a32f9d authored by Lukas 'Eipi' Eipert's avatar Lukas 'Eipi' Eipert

Improve size of rendered job trace

Currently in collapsible job traces _each_ line is wrapped in a span and
every line is prepended with another span in order to indent that part
of the job log.

We are now merging both and fix the CSS in order to show them properly
indented.
parent 141b26f6
Pipeline #73697626 failed with stages
in 48 minutes and 37 seconds
......@@ -127,6 +127,7 @@
.section-header ~ .section.line {
margin-left: $gl-padding;
display: block;
}
}
......
......@@ -131,9 +131,9 @@ module Gitlab
def on_109(_) set_bg_color(9, 'l') end
attr_accessor :offset, :n_open_tags, :fg_color, :bg_color, :style_mask, :sections, :lineno_in_section
attr_accessor :offset, :n_open_tags, :fg_color, :bg_color, :style_mask, :sections, :lineno_in_section, :prev_config
STATE_PARAMS = [:offset, :n_open_tags, :fg_color, :bg_color, :style_mask, :sections, :lineno_in_section].freeze
STATE_PARAMS = [:offset, :n_open_tags, :fg_color, :bg_color, :style_mask, :sections, :lineno_in_section, :prev_config].freeze
def convert(stream, new_state)
reset_state
......@@ -194,15 +194,12 @@ module Gitlab
end
def handle_new_line
current_config = @sections + [@bg_color, @fg_color]
write_in_tag %{<br/>}
if @sections.any?
css_classes = %w[section line] + sections.map { |section| "s_#{section}" }
write_raw %{<span class="#{css_classes.join(' ')}"></span>}
end
@lineno_in_section += 1
ensure_open_new_tag
close_open_tags if @prev_config != current_config
@prev_config = current_config
end
def handle_section(scanner)
......@@ -309,7 +306,13 @@ module Gitlab
if @sections.any?
css_classes << "section"
css_classes << "js-section-header section-header" if @lineno_in_section == 0
css_classes << if @lineno_in_section == 0
"js-section-header section-header"
else
"line"
end
css_classes += sections.map { |section| "js-s-#{section}" }
end
......@@ -359,6 +362,7 @@ module Gitlab
def reset
@fg_color = nil
@bg_color = nil
@prev_config = [@fg_color, @bg_color]
@style_mask = 0
end
......
......@@ -232,12 +232,11 @@ describe Gitlab::Ci::Ansi2html do
let(:text) { "#{section_start}Some text#{section_end}" }
it 'prints light red' do
text = "#{section_start}\e[91mHello\e[0m\n#{section_end}"
text = "#{section_start}\e[91mHello\e[0m\nLine 1\nLine 2\nLine 3\n#{section_end}"
header = %{<span class="term-fg-l-red section js-section-header section-header js-s-#{class_name(section_name)}">Hello</span>}
line_break = %{<span class="section js-section-header section-header js-s-#{class_name(section_name)}"><br/></span>}
line = %{<span class="section line s_#{class_name(section_name)}"></span>}
empty_line = %{<span class="section js-s-#{class_name(section_name)}"></span>}
html = "#{section_start_html}#{header}#{line_break}#{line}#{empty_line}#{section_end_html}"
output_line = %{<span class="section line js-s-#{class_name(section_name)}">Line 1<br/>Line 2<br/>Line 3<br/></span>}
html = "#{section_start_html}#{header}#{line_break}#{output_line}#{section_end_html}"
expect(convert_html(text)).to eq(html)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment