51087cfa1a
Add a download buttons for Build Artifacts ## What does this MR do? This MR adds a download buttons for build artifacts of latest succesful pipeline in: - dashboard of project, - branches and tags views, - and tree viewer Implement #4255 ## What are the relevant issue numbers? Closes #4255, Closes #14419 ## Screenshots ### Project main ![](/uploads/29ee2154a214416059a875f2715d4fa3/Screen_Shot_2016-08-24_at_8.00.31_PM.png) ### Branches ![](/uploads/9220c593288370986fbc1d42a1425ef7/Screen_Shot_2016-08-24_at_8.02.01_PM.png) ### Tags ![](/uploads/a843e8103221fea475a0cf9d62a1999d/Screen_Shot_2016-08-24_at_8.03.32_PM.png) ### Source Tree ![](/uploads/63cd3c8c91b6f427c166dc90d8e3c059/Screen_Shot_2016-08-24_at_8.04.56_PM.png) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [x] Download buttons - [x] Models - [x] Routes - [x] Projects::ArtifactsController - [x] API - Tests - Rails - [x] Project#builds_for - [x] branch name with slashes - [x] only success builds - [x] only latest builds - [x] feature tests for download buttons - API - [x] branch name with slashes - [x] only success builds - [x] only latest builds - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5142
87 lines
2.5 KiB
Ruby
87 lines
2.5 KiB
Ruby
module CiStatusHelper
|
|
def ci_status_path(pipeline)
|
|
project = pipeline.project
|
|
builds_namespace_project_commit_path(project.namespace, project, pipeline.sha)
|
|
end
|
|
|
|
def ci_status_with_icon(status, target = nil)
|
|
content = ci_icon_for_status(status) + ' '.html_safe + ci_label_for_status(status)
|
|
klass = "ci-status ci-#{status}"
|
|
if target
|
|
link_to content, target, class: klass
|
|
else
|
|
content_tag :span, content, class: klass
|
|
end
|
|
end
|
|
|
|
def ci_label_for_status(status)
|
|
case status
|
|
when 'success'
|
|
'passed'
|
|
when 'success_with_warnings'
|
|
'passed with warnings'
|
|
else
|
|
status
|
|
end
|
|
end
|
|
|
|
def ci_status_for_statuseable(subject)
|
|
status = subject.try(:status) || 'not found'
|
|
status.humanize
|
|
end
|
|
|
|
def ci_icon_for_status(status)
|
|
icon_name =
|
|
case status
|
|
when 'success'
|
|
'icon_status_success'
|
|
when 'success_with_warnings'
|
|
'icon_status_warning'
|
|
when 'failed'
|
|
'icon_status_failed'
|
|
when 'pending'
|
|
'icon_status_pending'
|
|
when 'running'
|
|
'icon_status_running'
|
|
when 'play'
|
|
'icon_play'
|
|
when 'created'
|
|
'icon_status_created'
|
|
else
|
|
'icon_status_cancel'
|
|
end
|
|
|
|
custom_icon(icon_name)
|
|
end
|
|
|
|
def render_commit_status(commit, tooltip_placement: 'auto left')
|
|
project = commit.project
|
|
path = builds_namespace_project_commit_path(project.namespace, project, commit)
|
|
render_status_with_link('commit', commit.status, path, tooltip_placement: tooltip_placement)
|
|
end
|
|
|
|
def render_pipeline_status(pipeline, tooltip_placement: 'auto left')
|
|
project = pipeline.project
|
|
path = namespace_project_pipeline_path(project.namespace, project, pipeline)
|
|
render_status_with_link('pipeline', pipeline.status, path, tooltip_placement: tooltip_placement)
|
|
end
|
|
|
|
def no_runners_for_project?(project)
|
|
project.runners.blank? &&
|
|
Ci::Runner.shared.blank?
|
|
end
|
|
|
|
def render_status_with_link(type, status, path = nil, tooltip_placement: 'auto left', cssclass: '', container: 'body')
|
|
klass = "ci-status-link ci-status-icon-#{status.dasherize} #{cssclass}"
|
|
title = "#{type.titleize}: #{ci_label_for_status(status)}"
|
|
data = { toggle: 'tooltip', placement: tooltip_placement, container: container }
|
|
|
|
if path
|
|
link_to ci_icon_for_status(status), path,
|
|
class: klass, title: title, data: data
|
|
else
|
|
content_tag :span, ci_icon_for_status(status),
|
|
class: klass, title: title, data: data
|
|
end
|
|
end
|
|
end
|