Commit 8495a310 authored by James Fargher's avatar James Fargher

Merge branch '342747-hide-empty-row-if-no-badge' into 'master'

Hide badge row if there are no pipeline badges

See merge request gitlab-org/gitlab!72538
parents aaa154be bef25878
...@@ -67,6 +67,17 @@ module Ci ...@@ -67,6 +67,17 @@ module Ci
] ]
end end
def has_pipeline_badges?(pipeline)
pipeline.child? ||
pipeline.latest? ||
pipeline.merge_train_pipeline? ||
pipeline.has_yaml_errors? ||
pipeline.failure_reason? ||
pipeline.auto_devops_source? ||
pipeline.detached_merge_request_pipeline? ||
pipeline.stuck?
end
private private
def warning_markdown(pipeline) def warning_markdown(pipeline)
......
...@@ -17,45 +17,46 @@ ...@@ -17,45 +17,46 @@
- if @pipeline.queued_duration - if @pipeline.queued_duration
= "(queued for #{time_interval_in_words(@pipeline.queued_duration)})" = "(queued for #{time_interval_in_words(@pipeline.queued_duration)})"
.well-segment.qa-pipeline-badges - if has_pipeline_badges?(@pipeline)
.icon-container .well-segment.qa-pipeline-badges
= sprite_icon('flag') .icon-container
- if @pipeline.child? = sprite_icon('flag')
%span.js-pipeline-child.badge.badge-pill.gl-badge.sm.badge-primary.has-tooltip{ title: s_("Pipelines|This is a child pipeline within the parent pipeline") } - if @pipeline.child?
= s_('Pipelines|Child pipeline') %span.js-pipeline-child.badge.badge-pill.gl-badge.sm.badge-primary.has-tooltip{ title: s_("Pipelines|This is a child pipeline within the parent pipeline") }
= surround '(', ')' do = s_('Pipelines|Child pipeline')
= link_to s_('Pipelines|parent'), pipeline_path(@pipeline.triggered_by_pipeline), class: 'text-white text-underline' = surround '(', ')' do
- if @pipeline.latest? = link_to s_('Pipelines|parent'), pipeline_path(@pipeline.triggered_by_pipeline), class: 'text-white text-underline'
%span.js-pipeline-url-latest.badge.badge-pill.gl-badge.sm.badge-success.has-tooltip{ title: _("Latest pipeline for the most recent commit on this branch") } - if @pipeline.latest?
latest %span.js-pipeline-url-latest.badge.badge-pill.gl-badge.sm.badge-success.has-tooltip{ title: _("Latest pipeline for the most recent commit on this branch") }
- if @pipeline.merge_train_pipeline? latest
%span.js-pipeline-url-train.badge.badge-pill.gl-badge.sm.badge-info.has-tooltip{ title: _("This is a merge train pipeline") } - if @pipeline.merge_train_pipeline?
train %span.js-pipeline-url-train.badge.badge-pill.gl-badge.sm.badge-info.has-tooltip{ title: _("This is a merge train pipeline") }
- if @pipeline.has_yaml_errors? train
%span.js-pipeline-url-yaml.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.yaml_errors } - if @pipeline.has_yaml_errors?
yaml invalid %span.js-pipeline-url-yaml.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.yaml_errors }
- if @pipeline.failure_reason? yaml invalid
%span.js-pipeline-url-failure.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.failure_reason } - if @pipeline.failure_reason?
error %span.js-pipeline-url-failure.badge.badge-pill.gl-badge.sm.badge-danger.has-tooltip{ title: @pipeline.failure_reason }
- if @pipeline.auto_devops_source? error
- popover_title_text = html_escape(_('This pipeline makes use of a predefined CI/CD configuration enabled by %{b_open}Auto DevOps.%{b_close}')) % { b_open: '<b>'.html_safe, b_close: '</b>'.html_safe } - if @pipeline.auto_devops_source?
- popover_content_url = help_page_path('topics/autodevops/index.md') - popover_title_text = html_escape(_('This pipeline makes use of a predefined CI/CD configuration enabled by %{b_open}Auto DevOps.%{b_close}')) % { b_open: '<b>'.html_safe, b_close: '</b>'.html_safe }
- popover_content_text = _('Learn more about Auto DevOps') - popover_content_url = help_page_path('topics/autodevops/index.md')
%a.js-pipeline-url-autodevops.badge.badge-pill.gl-badge.sm.badge-info.autodevops-badge{ href: "#", tabindex: "0", role: "button", data: { container: "body", - popover_content_text = _('Learn more about Auto DevOps')
toggle: "popover", %a.js-pipeline-url-autodevops.badge.badge-pill.gl-badge.sm.badge-info.autodevops-badge{ href: "#", tabindex: "0", role: "button", data: { container: "body",
placement: "top", toggle: "popover",
html: "true", placement: "top",
triggers: "focus", html: "true",
title: "<div class='gl-font-weight-normal gl-line-height-normal'>#{popover_title_text}</div>", triggers: "focus",
content: "<a href='#{popover_content_url}' target='_blank' rel='noopener noreferrer nofollow'>#{popover_content_text}</a>", title: "<div class='gl-font-weight-normal gl-line-height-normal'>#{popover_title_text}</div>",
} } content: "<a href='#{popover_content_url}' target='_blank' rel='noopener noreferrer nofollow'>#{popover_content_text}</a>",
Auto DevOps } }
- if @pipeline.detached_merge_request_pipeline? Auto DevOps
%span.js-pipeline-url-mergerequest.badge.badge-pill.gl-badge.sm.badge-info.has-tooltip{ title: _('Pipelines for merge requests are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for Pipelines for Merged Results.') } - if @pipeline.detached_merge_request_pipeline?
detached %span.js-pipeline-url-mergerequest.badge.badge-pill.gl-badge.sm.badge-info.has-tooltip{ title: _('Pipelines for merge requests are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for Pipelines for Merged Results.') }
- if @pipeline.stuck? detached
%span.js-pipeline-url-stuck.badge.badge-pill.gl-badge.sm.badge-warning - if @pipeline.stuck?
stuck %span.js-pipeline-url-stuck.badge.badge-pill.gl-badge.sm.badge-warning
stuck
.well-segment.branch-info .well-segment.branch-info
.icon-container.commit-icon .icon-container.commit-icon
......
...@@ -71,4 +71,26 @@ RSpec.describe Ci::PipelinesHelper do ...@@ -71,4 +71,26 @@ RSpec.describe Ci::PipelinesHelper do
it { expect(has_gitlab_ci?).to eq(result) } it { expect(has_gitlab_ci?).to eq(result) }
end end
end end
describe 'has_pipeline_badges?' do
let(:pipeline) { create(:ci_empty_pipeline) }
subject { helper.has_pipeline_badges?(pipeline) }
context 'when pipeline has a badge' do
before do
pipeline.drop!(:config_error)
end
it 'shows pipeline badges' do
expect(subject).to eq(true)
end
end
context 'when pipeline has no badges' do
it 'shows pipeline badges' do
expect(subject).to eq(false)
end
end
end
end 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