Commit 516b2a12 authored by Katarzyna Kobierska's avatar Katarzyna Kobierska

Add partial to admin builds and project builds

parent 6b88cc64
...@@ -5,6 +5,8 @@ class Admin::BuildsController < Admin::ApplicationController ...@@ -5,6 +5,8 @@ class Admin::BuildsController < Admin::ApplicationController
@builds = @all_builds.order('created_at DESC') @builds = @all_builds.order('created_at DESC')
@builds = @builds =
case @scope case @scope
when 'all'
@builds
when 'pending' when 'pending'
@builds.pending.reverse_order @builds.pending.reverse_order
when 'running' when 'running'
......
...@@ -10,6 +10,8 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -10,6 +10,8 @@ class Projects::BuildsController < Projects::ApplicationController
@builds = @all_builds.order('created_at DESC') @builds = @all_builds.order('created_at DESC')
@builds = @builds =
case @scope case @scope
when 'all'
@builds
when 'pending' when 'pending'
@builds.pending.reverse_order @builds.pending.reverse_order
when 'running' when 'running'
......
...@@ -4,26 +4,9 @@ ...@@ -4,26 +4,9 @@
%div{ class: container_class } %div{ class: container_class }
.top-area .top-area
%ul.nav-links - scopes = [:all, :pending, :running, :finished]
%li{class: ('active' if @scope.nil?)} - paths = scopes.zip(scopes.map { |scope| admin_builds_path(scope: scope) }).to_h
= link_to admin_builds_path do = render "projects/builds/builds", paths: paths
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))
.nav-controls .nav-controls
- if @all_builds.running_or_pending.any? - if @all_builds.running_or_pending.any?
......
%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))
...@@ -4,30 +4,9 @@ ...@@ -4,30 +4,9 @@
%div{ class: container_class } %div{ class: container_class }
.top-area .top-area
%ul.nav-links - scopes = [:all, :pending, :running, :finished]
%li{class: ('active' if @scope.nil?)} - paths = scopes.zip(scopes.map { |scope| project_builds_path(@project, scope: scope) }).to_h
= link_to project_builds_path(@project) do = render "builds", paths: paths
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))
.nav-controls .nav-controls
- if can?(current_user, :update_build, @project) - if can?(current_user, :update_build, @project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment