Skip to content
代码片段 群组 项目
提交 421afe88 编辑于 作者: Miguel Rincon's avatar Miguel Rincon 提交者: Stan Hu
浏览文件

Migrate from ci_label_for_status in template

This change migrates from ci_label_for_status to detailed_status in
template and make the method private to prevent it from being reused.
上级 777298a5
No related branches found
No related tags found
无相关合并请求
...@@ -9,27 +9,6 @@ ...@@ -9,27 +9,6 @@
# #
module Ci module Ci
module StatusHelper module StatusHelper
def ci_label_for_status(status)
if detailed_status?(status)
return status.label
end
label = case status
when 'success'
'passed'
when 'success-with-warnings'
'passed with warnings'
when 'manual'
'waiting for manual action'
when 'scheduled'
'waiting for delayed job'
else
status
end
translation = "CiStatusLabel|#{label}"
s_(translation)
end
def ci_status_for_statuseable(subject) def ci_status_for_statuseable(subject)
status = subject.try(:status) || 'not found' status = subject.try(:status) || 'not found'
status.humanize status.humanize
...@@ -110,11 +89,34 @@ def render_status_with_link(status, path = nil, type: _('pipeline'), tooltip_pla ...@@ -110,11 +89,34 @@ def render_status_with_link(status, path = nil, type: _('pipeline'), tooltip_pla
end end
end end
private
def detailed_status?(status) def detailed_status?(status)
status.respond_to?(:text) && status.respond_to?(:text) &&
status.respond_to?(:group) && status.respond_to?(:group) &&
status.respond_to?(:label) && status.respond_to?(:label) &&
status.respond_to?(:icon) status.respond_to?(:icon)
end end
def ci_label_for_status(status)
if detailed_status?(status)
return status.label
end
label = case status
when 'success'
'passed'
when 'success-with-warnings'
'passed with warnings'
when 'manual'
'waiting for manual action'
when 'scheduled'
'waiting for delayed job'
else
status
end
translation = "CiStatusLabel|#{label}"
s_(translation)
end
end end
end end
...@@ -45,11 +45,12 @@ ...@@ -45,11 +45,12 @@
= gl_loading_icon(inline: true, css_class: 'gl-vertical-align-middle') = gl_loading_icon(inline: true, css_class: 'gl-vertical-align-middle')
- if can?(current_user, :read_pipeline, @last_pipeline) - if can?(current_user, :read_pipeline, @last_pipeline)
- status = @last_pipeline.detailed_status(current_user)
.well-segment.pipeline-info .well-segment.pipeline-info
.js-commit-pipeline-status{ data: { full_path: @project.full_path, iid: @last_pipeline.iid, graphql_resource_etag: graphql_etag_pipeline_path(@last_pipeline) } } .js-commit-pipeline-status{ data: { full_path: @project.full_path, iid: @last_pipeline.iid, graphql_resource_etag: graphql_etag_pipeline_path(@last_pipeline) } }
#{ _('Pipeline') } #{ _('Pipeline') }
= link_to "##{@last_pipeline.id}", project_pipeline_path(@project, @last_pipeline.id) = link_to "##{@last_pipeline.id}", project_pipeline_path(@project, @last_pipeline.id)
= ci_label_for_status(@last_pipeline.status) = status&.label
- if @last_pipeline.stages_count.nonzero? - if @last_pipeline.stages_count.nonzero?
#{ n_(s_('Pipeline|with stage'), s_('Pipeline|with stages'), @last_pipeline.stages_count) } #{ n_(s_('Pipeline|with stage'), s_('Pipeline|with stages'), @last_pipeline.stages_count) }
.js-commit-pipeline-mini-graph{ data: { stages: @last_pipeline_stages.to_json.html_safe, full_path: @project.full_path, iid: @last_pipeline.iid, graphql_resource_etag: graphql_etag_pipeline_path(@last_pipeline) } } .js-commit-pipeline-mini-graph{ data: { stages: @last_pipeline_stages.to_json.html_safe, full_path: @project.full_path, iid: @last_pipeline.iid, graphql_resource_etag: graphql_etag_pipeline_path(@last_pipeline) } }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册