diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-08-05 11:34:57 +0200 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-09-13 09:05:07 +0200 |
commit | 516b2a12758aa1ddd947c32a14d0088df193402c (patch) | |
tree | 1d38f5ba4721417672966bdc3edf6a244efc1f7e | |
parent | 6b88cc6469a08db12aee8f5b0f8ef581bd491265 (diff) | |
download | gitlab-ce-516b2a12758aa1ddd947c32a14d0088df193402c.tar.gz |
Add partial to admin builds and project builds
-rw-r--r-- | app/controllers/admin/builds_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/builds_controller.rb | 2 | ||||
-rw-r--r-- | app/views/admin/builds/index.html.haml | 23 | ||||
-rw-r--r-- | app/views/projects/builds/_builds.html.haml | 24 | ||||
-rw-r--r-- | app/views/projects/builds/index.html.haml | 27 |
5 files changed, 34 insertions, 44 deletions
diff --git a/app/controllers/admin/builds_controller.rb b/app/controllers/admin/builds_controller.rb index 88f3c0e2fd4..c4e91d8f869 100644 --- a/app/controllers/admin/builds_controller.rb +++ b/app/controllers/admin/builds_controller.rb @@ -5,6 +5,8 @@ class Admin::BuildsController < Admin::ApplicationController @builds = @all_builds.order('created_at DESC') @builds = case @scope + when 'all' + @builds when 'pending' @builds.pending.reverse_order when 'running' diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 77934ff9962..c6a57ff8cb1 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -10,6 +10,8 @@ class Projects::BuildsController < Projects::ApplicationController @builds = @all_builds.order('created_at DESC') @builds = case @scope + when 'all' + @builds when 'pending' @builds.pending.reverse_order when 'running' diff --git a/app/views/admin/builds/index.html.haml b/app/views/admin/builds/index.html.haml index 3d77634d8fa..f0599bd3004 100644 --- a/app/views/admin/builds/index.html.haml +++ b/app/views/admin/builds/index.html.haml @@ -4,26 +4,9 @@ %div{ class: container_class } .top-area - %ul.nav-links - %li{class: ('active' if @scope.nil?)} - = link_to admin_builds_path do - All - %span.badge.js-totalbuilds-count= @all_builds.count(:id) - - %li{class: ('active' if @scope == 'pending')} - = link_to admin_builds_path(scope: :pending) do - Pending - %span.badge= number_with_delimiter(@all_builds.pending.count(:id)) - - %li{class: ('active' if @scope == 'running')} - = link_to admin_builds_path(scope: :running) do - Running - %span.badge= number_with_delimiter(@all_builds.running.count(:id)) - - %li{class: ('active' if @scope == 'finished')} - = link_to admin_builds_path(scope: :finished) do - Finished - %span.badge= number_with_delimiter(@all_builds.finished.count(:id)) + - scopes = [:all, :pending, :running, :finished] + - paths = scopes.zip(scopes.map { |scope| admin_builds_path(scope: scope) }).to_h + = render "projects/builds/builds", paths: paths .nav-controls - if @all_builds.running_or_pending.any? diff --git a/app/views/projects/builds/_builds.html.haml b/app/views/projects/builds/_builds.html.haml new file mode 100644 index 00000000000..61542f8a7cc --- /dev/null +++ b/app/views/projects/builds/_builds.html.haml @@ -0,0 +1,24 @@ +%ul.nav-links + %li{class: ('active' if @scope.nil? || @scope == 'all')} + = link_to paths[:all] do + All + %span.badge.js-totalbuilds-count + = number_with_delimiter(@all_builds.count(:id)) + + %li{class: ('active' if @scope == 'pending')} + = link_to paths[:pending] do + Pending + %span.badge + = number_with_delimiter(@all_builds.pending.count(:id)) + + %li{class: ('active' if @scope == 'running')} + = link_to paths[:running] do + Running + %span.badge + = number_with_delimiter(@all_builds.running.count(:id)) + + %li{class: ('active' if @scope == 'finished')} + = link_to paths[:finished] do + Finished + %span.badge + = number_with_delimiter(@all_builds.finished.count(:id)) diff --git a/app/views/projects/builds/index.html.haml b/app/views/projects/builds/index.html.haml index 2af625f69cd..765e239d1de 100644 --- a/app/views/projects/builds/index.html.haml +++ b/app/views/projects/builds/index.html.haml @@ -4,30 +4,9 @@ %div{ class: container_class } .top-area - %ul.nav-links - %li{class: ('active' if @scope.nil?)} - = link_to project_builds_path(@project) do - All - %span.badge.js-totalbuilds-count - = number_with_delimiter(@all_builds.count(:id)) - - %li{class: ('active' if @scope == 'pending')} - = link_to project_builds_path(@project, scope: :pending) do - Pending - %span.badge - = number_with_delimiter(@all_builds.pending.count(:id)) - - %li{class: ('active' if @scope == 'running')} - = link_to project_builds_path(@project, scope: :running) do - Running - %span.badge - = number_with_delimiter(@all_builds.running.count(:id)) - - %li{class: ('active' if @scope == 'finished')} - = link_to project_builds_path(@project, scope: :finished) do - Finished - %span.badge - = number_with_delimiter(@all_builds.finished.count(:id)) + - scopes = [:all, :pending, :running, :finished] + - paths = scopes.zip(scopes.map { |scope| project_builds_path(@project, scope: scope) }).to_h + = render "builds", paths: paths .nav-controls - if can?(current_user, :update_build, @project) |