diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-08-17 12:06:31 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-08-17 12:06:31 +0300 |
commit | ee33b3e6e84bb566e84062e70d45c6d84ace4ee7 (patch) | |
tree | 1bb221eb39dcf82de003099a5571c3f0d86b8360 /app | |
parent | 75df5f6c73670def1912150c6f3390ffdfadb17a (diff) |
Use partials for downloading artifacts button
Diffstat (limited to 'app')
-rw-r--r-- | app/views/projects/branches/_branch.html.haml | 30 | ||||
-rw-r--r-- | app/views/projects/buttons/_artifacts.html.haml | 14 | ||||
-rw-r--r-- | app/views/projects/buttons/_download.html.haml | 15 | ||||
-rw-r--r-- | app/views/projects/repositories/_download_archive.html.haml | 15 | ||||
-rw-r--r-- | app/views/projects/tags/_download.html.haml | 15 |
5 files changed, 26 insertions, 63 deletions
diff --git a/app/views/projects/branches/_branch.html.haml b/app/views/projects/branches/_branch.html.haml index 5634abf3641..21ac675ffe0 100644 --- a/app/views/projects/branches/_branch.html.haml +++ b/app/views/projects/branches/_branch.html.haml @@ -27,27 +27,15 @@ = link_to namespace_project_compare_index_path(@project.namespace, @project, from: @repository.root_ref, to: branch.name), class: 'btn btn-default', method: :post, title: "Compare" do Compare - - pipeline = @project.pipelines.latest_successful_for(branch.name) - - if pipeline - - artifacts = pipeline.builds.latest.with_artifacts - - if artifacts.any? - .dropdown.inline.artifacts-btn - %a.btn.dropdown-toggle{ 'data-toggle' => 'dropdown' } - = icon('download') - %span.caret - %span.sr-only - Select Archive Format - %ul.dropdown-menu.dropdown-menu-align-right{ role: 'menu' } - %li.dropdown-header Artifacts - - unless pipeline.latest? - - latest_pipeline = @project.pipeline_for(branch.name) - %li - .unclickable= ci_status_for_statuseable(latest_pipeline) - %li.dropdown-header Previous Artifacts - - artifacts.each do |job| - %li - = link_to latest_succeeded_namespace_project_artifacts_path(@project.namespace, @project, branch.name, 'download', job: job.name), rel: 'nofollow' do - %span Download '#{job.name}' + - if @project.latest_successful_builds_for(branch.name).any? + .dropdown.inline.artifacts-btn + %a.btn.dropdown-toggle{ 'data-toggle' => 'dropdown' } + = icon('download') + %span.caret + %span.sr-only + Select Archive Format + %ul.dropdown-menu.dropdown-menu-align-right{ role: 'menu' } + = render 'projects/buttons/artifacts', project: @project, ref: branch.name - if can_remove_branch?(@project, branch.name) = link_to namespace_project_branch_path(@project.namespace, @project, branch.name), class: 'btn btn-remove remove-row has-tooltip', title: "Delete branch", method: :delete, data: { confirm: "Deleting the '#{branch.name}' branch cannot be undone. Are you sure?", container: 'body' }, remote: true do diff --git a/app/views/projects/buttons/_artifacts.html.haml b/app/views/projects/buttons/_artifacts.html.haml new file mode 100644 index 00000000000..a52677ebf0a --- /dev/null +++ b/app/views/projects/buttons/_artifacts.html.haml @@ -0,0 +1,14 @@ +- pipeline = project.pipelines.latest_successful_for(ref) +- if pipeline + - artifacts = pipeline.builds.latest.with_artifacts + - if artifacts.any? + %li.dropdown-header Artifacts + - unless pipeline.latest? + - latest_pipeline = project.pipeline_for(ref) + %li + .unclickable= ci_status_for_statuseable(latest_pipeline) + %li.dropdown-header Previous Artifacts + - artifacts.each do |job| + %li + = link_to latest_succeeded_namespace_project_artifacts_path(project.namespace, project, ref, 'download', job: job.name), rel: 'nofollow' do + %span Download '#{job.name}' diff --git a/app/views/projects/buttons/_download.html.haml b/app/views/projects/buttons/_download.html.haml index 177946dcd42..5e748c44b08 100644 --- a/app/views/projects/buttons/_download.html.haml +++ b/app/views/projects/buttons/_download.html.haml @@ -14,17 +14,4 @@ %li = link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: @ref, format: 'tar.gz'), rel: 'nofollow' do %span Download tar.gz - - pipeline = @project.pipelines.latest_successful_for(@ref) - - if pipeline - - artifacts = pipeline.builds.latest.with_artifacts - - if artifacts.any? - %li.dropdown-header Artifacts - - unless pipeline.latest? - - latest_pipeline = @project.pipeline_for(@ref) - %li - .unclickable= ci_status_for_statuseable(latest_pipeline) - %li.dropdown-header Previous Artifacts - - artifacts.each do |job| - %li - = link_to latest_succeeded_namespace_project_artifacts_path(@project.namespace, @project, @ref, 'download', job: job.name), rel: 'nofollow' do - %span Download '#{job.name}' + = render 'projects/buttons/artifacts', project: @project, ref: @ref diff --git a/app/views/projects/repositories/_download_archive.html.haml b/app/views/projects/repositories/_download_archive.html.haml index c0a5909d3a6..4f40696a190 100644 --- a/app/views/projects/repositories/_download_archive.html.haml +++ b/app/views/projects/repositories/_download_archive.html.haml @@ -25,17 +25,4 @@ = link_to archive_namespace_project_repository_path(@project.namespace, @project, ref: ref, format: 'tar'), rel: 'nofollow' do %i.fa.fa-download %span Download tar - - pipeline = @project.pipelines.latest_successful_for(ref) - - if pipeline - - artifacts = pipeline.builds.latest.with_artifacts - - if artifacts.any? - %li.dropdown-header Artifacts - - unless pipeline.latest? - - latest_pipeline = @project.pipeline_for(ref) - %li - .unclickable= ci_status_for_statuseable(latest_pipeline) - %li.dropdown-header Previous Artifacts - - artifacts.each do |job| - %li - = link_to latest_succeeded_namespace_project_artifacts_path(@project.namespace, @project, ref, 'download', job: job.name), rel: 'nofollow' do - %span Download '#{job.name}' + = render 'projects/buttons/artifacts', project: @project, ref: ref diff --git a/app/views/projects/tags/_download.html.haml b/app/views/projects/tags/_download.html.haml index 316d03dd12a..6985eb74ca7 100644 --- a/app/views/projects/tags/_download.html.haml +++ b/app/views/projects/tags/_download.html.haml @@ -12,17 +12,4 @@ %li = link_to archive_namespace_project_repository_path(project.namespace, project, ref: ref, format: 'tar.gz'), rel: 'nofollow' do %span Download tar.gz - - pipeline = project.pipelines.latest_successful_for(ref) - - if pipeline - - artifacts = pipeline.builds.latest.with_artifacts - - if artifacts.any? - %li.dropdown-header Artifacts - - unless pipeline.latest? - - latest_pipeline = project.pipeline_for(ref) - %li - .unclickable= ci_status_for_statuseable(latest_pipeline) - %li.dropdown-header Previous Artifacts - - artifacts.each do |job| - %li - = link_to latest_succeeded_namespace_project_artifacts_path(project.namespace, project, ref, 'download', job: job.name), rel: 'nofollow' do - %span Download '#{job.name}' + = render 'projects/buttons/artifacts', project: project, ref: ref |