summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarzyna Kobierska <kkobierska@gmail.com>2016-09-07 15:27:48 +0200
committerKatarzyna Kobierska <kkobierska@gmail.com>2016-09-13 09:05:07 +0200
commit80c86bcc5b778306825e7650ccaa3c01bfd75ac0 (patch)
tree092aff77d635586a3229cc8f91fa775808cedc45
parent27c3a87194a3a29c06cf8a2dd489d28ca0b552ab (diff)
downloadgitlab-ce-80c86bcc5b778306825e7650ccaa3c01bfd75ac0.tar.gz
Create shared partial for project and admin builds
-rw-r--r--app/views/admin/builds/_build.html.haml80
-rw-r--r--app/views/admin/builds/index.html.haml2
-rw-r--r--app/views/projects/builds/_table.html.haml6
-rw-r--r--app/views/projects/builds/index.html.haml4
-rw-r--r--app/views/shared/builds/_build.html.haml (renamed from app/views/projects/ci/builds/_build.html.haml)23
-rw-r--r--app/views/shared/builds/_tabs.html.haml24
6 files changed, 46 insertions, 93 deletions
diff --git a/app/views/admin/builds/_build.html.haml b/app/views/admin/builds/_build.html.haml
deleted file mode 100644
index 2b6ad068c57..00000000000
--- a/app/views/admin/builds/_build.html.haml
+++ /dev/null
@@ -1,80 +0,0 @@
-- project = build.project
-%tr.build.commit
- %td.status
- = ci_status_with_icon(build.status)
-
- %td
- .branch-commit
- - if can?(current_user, :read_build, build.project)
- = link_to namespace_project_build_url(build.project.namespace, build.project, build) do
- %span.build-link ##{build.id}
- - else
- %span.build-link ##{build.id}
-
- - if build.ref
- .icon-container
- = build.tag? ? icon('tag') : icon('code-fork')
- = link_to build.ref, namespace_project_commits_path(build.project.namespace, build.project, build.ref), class: "monospace branch-name"
- - else
- .light none
- .icon-container
- = custom_icon("icon_commit")
-
- = link_to build.short_sha, namespace_project_commit_path(build.project.namespace, build.project, build.sha), class: "monospace commit-id"
- - if build.stuck?
- %i.fa.fa-warning.text-warning
-
- .label-container
- - if build.tags.any?
- - build.tags.each do |tag|
- %span.label.label-primary
- = tag
- - if build.try(:trigger_request)
- %span.label.label-info triggered
- - if build.try(:allow_failure)
- %span.label.label-danger allowed to fail
-
- %td
- - if project
- = link_to project.name_with_namespace, admin_namespace_project_path(project.namespace, project)
-
- %td
- - if build.try(:runner)
- = runner_link(build.runner)
- - else
- .light none
-
- %td
- = build.stage
-
- %td
- = build.name
-
- %td
- - if build.duration
- %p.duration
- = custom_icon("icon_timer")
- = duration_in_numbers(build.duration)
-
- - if build.finished_at
- %p.finished-at
- = icon("calendar")
- %span #{time_ago_with_tooltip(build.finished_at)}
-
- %td.coverage
- - if defined?(coverage) && coverage
- - if build.try(:coverage)
- #{build.coverage}%
-
- %td
- .pull-right
- - if can?(current_user, :read_build, project) && build.artifacts?
- = link_to download_namespace_project_build_artifacts_path(build.project.namespace, build.project, build), title: 'Download artifacts', class: 'btn btn-build' do
- %i.fa.fa-download
- - if can?(current_user, :update_build, build.project)
- - if build.active?
- = link_to cancel_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Cancel', class: 'btn btn-build' do
- %i.fa.fa-remove.cred
- - elsif defined?(allow_retry) && allow_retry && build.retryable?
- = link_to retry_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Retry', class: 'btn btn-build' do
- %i.fa.fa-refresh
diff --git a/app/views/admin/builds/index.html.haml b/app/views/admin/builds/index.html.haml
index 7dba77d2dee..7d84172bd2e 100644
--- a/app/views/admin/builds/index.html.haml
+++ b/app/views/admin/builds/index.html.haml
@@ -5,7 +5,7 @@
.top-area
- build_path = ->(scope) { admin_builds_path(scope: scope) }
- = render "shared/builds_tabs", build_path: build_path, all_builds: @all_builds, scope: @scope
+ = render "shared/builds/tabs", build_path: build_path, all_builds: @all_builds, scope: @scope
.nav-controls
- if @all_builds.running_or_pending.any?
diff --git a/app/views/projects/builds/_table.html.haml b/app/views/projects/builds/_table.html.haml
index 9e4fd9b767b..a4cd9596d68 100644
--- a/app/views/projects/builds/_table.html.haml
+++ b/app/views/projects/builds/_table.html.haml
@@ -1,3 +1,4 @@
+- admin = false unless admin
- if builds.blank?
%li
.nothing-here-block No builds to show
@@ -20,9 +21,8 @@
%th
- if admin
- - builds.each do |build|
- = render "admin/builds/build", build: build
+ = render partial: "shared/builds/build", collection: builds, as: :build, locals: { commit_sha: true, ref: true, stage: true, allow_retry: true, runner: true, admin: true }
- else
- = render builds, commit_sha: true, ref: true, stage: true, allow_retry: true, coverage: project.build_coverage_enabled?
+ = render partial: "shared/builds/build", collection: builds, as: :build, locals: {commit_sha: true, ref: true, stage: true, allow_retry: true, coverage: project.build_coverage_enabled? }
= paginate builds, theme: 'gitlab'
diff --git a/app/views/projects/builds/index.html.haml b/app/views/projects/builds/index.html.haml
index f1b3fd1bcea..d2fc2ae34fe 100644
--- a/app/views/projects/builds/index.html.haml
+++ b/app/views/projects/builds/index.html.haml
@@ -5,7 +5,7 @@
%div{ class: container_class }
.top-area
- build_path = ->(scope) { project_builds_path(@project, scope: scope) }
- = render "shared/builds_tabs", build_path: build_path, all_builds: @all_builds, scope: @scope
+ = render "shared/builds/tabs", build_path: build_path, all_builds: @all_builds, scope: @scope
.nav-controls
- if can?(current_user, :update_build, @project)
@@ -20,4 +20,4 @@
%span CI Lint
%ul.content-list.builds-content-list
- = render "table", builds: @builds, project: @project, admin: false
+ = render "table", builds: @builds, project: @project
diff --git a/app/views/projects/ci/builds/_build.html.haml b/app/views/shared/builds/_build.html.haml
index 3ab64aff282..a5f38d0ce95 100644
--- a/app/views/projects/ci/builds/_build.html.haml
+++ b/app/views/shared/builds/_build.html.haml
@@ -1,3 +1,7 @@
+- admin = false unless admin
+- if admin
+ - project = build.project
+
%tr.build.commit
%td.status
- if can?(current_user, :read_build, build)
@@ -9,9 +13,9 @@
.branch-commit
- if can?(current_user, :read_build, build)
= link_to namespace_project_build_url(build.project.namespace, build.project, build) do
- %span ##{build.id}
+ %span.build-link ##{build.id}
- else
- %span ##{build.id}
+ %span.build-link ##{build.id}
- if defined?(ref) && ref
- if build.ref
@@ -45,6 +49,11 @@
- if build.manual?
%span.label.label-info manual
+ - if admin
+ %td
+ - if project
+ = link_to project.name_with_namespace, admin_namespace_project_path(project.namespace, project)
+
- if defined?(runner) && runner
%td
- if build.try(:runner)
@@ -53,8 +62,7 @@
.light none
%td
- - if defined?(stage) && stage
- = build.stage
+ = build.stage
%td
= build.name
@@ -64,13 +72,14 @@
%p.duration
= custom_icon("icon_timer")
= duration_in_numbers(build.duration)
+
- if build.finished_at
%p.finished-at
= icon("calendar")
%span #{time_ago_with_tooltip(build.finished_at)}
- - if defined?(coverage) && coverage
- %td.coverage
+ %td.coverage
+ - if defined?(coverage) && coverage
- if build.try(:coverage)
#{build.coverage}%
@@ -87,6 +96,6 @@
- if build.retryable?
= link_to retry_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Retry', class: 'btn btn-build' do
= icon('repeat')
- - elsif build.playable?
+ - elsif build.playable? && !admin
= link_to play_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Play', class: 'btn btn-build' do
= custom_icon('icon_play')
diff --git a/app/views/shared/builds/_tabs.html.haml b/app/views/shared/builds/_tabs.html.haml
new file mode 100644
index 00000000000..9c3173f7a1a
--- /dev/null
+++ b/app/views/shared/builds/_tabs.html.haml
@@ -0,0 +1,24 @@
+%ul.nav-links
+ %li{class: ('active' if scope.nil?)}
+ = link_to build_path[nil] do
+ All
+ %span.badge.js-totalbuilds-count
+ = number_with_delimiter(all_builds.count(:id))
+
+ %li{class: ('active' if scope == 'pending')}
+ = link_to build_path[:pending] do
+ Pending
+ %span.badge
+ = number_with_delimiter(all_builds.pending.count(:id))
+
+ %li{class: ('active' if scope == 'running')}
+ = link_to build_path[:running] do
+ Running
+ %span.badge
+ = number_with_delimiter(all_builds.running.count(:id))
+
+ %li{class: ('active' if scope == 'finished')}
+ = link_to build_path[:finished] do
+ Finished
+ %span.badge
+ = number_with_delimiter(all_builds.finished.count(:id))