Change the way paths are generated

This commit is contained in:
Katarzyna Kobierska 2016-08-10 13:07:03 +02:00
parent 516b2a1275
commit e81ed371a1
5 changed files with 9 additions and 15 deletions

View file

@ -5,8 +5,6 @@ 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'

View file

@ -10,8 +10,6 @@ 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'

View file

@ -4,9 +4,8 @@
%div{ class: container_class }
.top-area
- scopes = [:all, :pending, :running, :finished]
- paths = scopes.zip(scopes.map { |scope| admin_builds_path(scope: scope) }).to_h
= render "projects/builds/builds", paths: paths
- build_path = ->(scope) { admin_builds_path(scope: scope) }
= render "projects/builds/tabs", build_path: build_path
.nav-controls
- if @all_builds.running_or_pending.any?

View file

@ -1,24 +1,24 @@
%ul.nav-links
%li{class: ('active' if @scope.nil? || @scope == 'all')}
= link_to paths[:all] do
%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 paths[:pending] do
= 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 paths[:running] do
= 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 paths[:finished] do
= link_to build_path[:finished] do
Finished
%span.badge
= number_with_delimiter(@all_builds.finished.count(:id))

View file

@ -4,9 +4,8 @@
%div{ class: container_class }
.top-area
- scopes = [:all, :pending, :running, :finished]
- paths = scopes.zip(scopes.map { |scope| project_builds_path(@project, scope: scope) }).to_h
= render "builds", paths: paths
- build_path = ->(scope) { project_builds_path(@project, scope: scope) }
= render "tabs", build_path: build_path
.nav-controls
- if can?(current_user, :update_build, @project)