Skip to content
Snippets Groups Projects
Commit e81ed371 authored by Katarzyna Kobierska's avatar Katarzyna Kobierska
Browse files

Change the way paths are generated

parent 516b2a12
Branches
Tags
No related merge requests found
Loading
@@ -5,8 +5,6 @@ class Admin::BuildsController < Admin::ApplicationController
Loading
@@ -5,8 +5,6 @@ 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'
Loading
Loading
Loading
@@ -10,8 +10,6 @@ class Projects::BuildsController < Projects::ApplicationController
Loading
@@ -10,8 +10,6 @@ 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'
Loading
Loading
Loading
@@ -4,9 +4,8 @@
Loading
@@ -4,9 +4,8 @@
%div{ class: container_class } %div{ class: container_class }
   
.top-area .top-area
- scopes = [:all, :pending, :running, :finished] - build_path = ->(scope) { admin_builds_path(scope: scope) }
- paths = scopes.zip(scopes.map { |scope| admin_builds_path(scope: scope) }).to_h = render "projects/builds/tabs", build_path: build_path
= render "projects/builds/builds", paths: paths
   
.nav-controls .nav-controls
- if @all_builds.running_or_pending.any? - if @all_builds.running_or_pending.any?
Loading
Loading
%ul.nav-links %ul.nav-links
%li{class: ('active' if @scope.nil? || @scope == 'all')} %li{class: ('active' if @scope.nil?)}
= link_to paths[:all] do = link_to build_path[nil] do
All All
%span.badge.js-totalbuilds-count %span.badge.js-totalbuilds-count
= number_with_delimiter(@all_builds.count(:id)) = number_with_delimiter(@all_builds.count(:id))
   
%li{class: ('active' if @scope == 'pending')} %li{class: ('active' if @scope == 'pending')}
= link_to paths[:pending] do = link_to build_path[:pending] do
Pending Pending
%span.badge %span.badge
= number_with_delimiter(@all_builds.pending.count(:id)) = number_with_delimiter(@all_builds.pending.count(:id))
   
%li{class: ('active' if @scope == 'running')} %li{class: ('active' if @scope == 'running')}
= link_to paths[:running] do = link_to build_path[:running] do
Running Running
%span.badge %span.badge
= number_with_delimiter(@all_builds.running.count(:id)) = number_with_delimiter(@all_builds.running.count(:id))
   
%li{class: ('active' if @scope == 'finished')} %li{class: ('active' if @scope == 'finished')}
= link_to paths[:finished] do = link_to build_path[:finished] do
Finished Finished
%span.badge %span.badge
= number_with_delimiter(@all_builds.finished.count(:id)) = number_with_delimiter(@all_builds.finished.count(:id))
Loading
@@ -4,9 +4,8 @@
Loading
@@ -4,9 +4,8 @@
   
%div{ class: container_class } %div{ class: container_class }
.top-area .top-area
- scopes = [:all, :pending, :running, :finished] - build_path = ->(scope) { project_builds_path(@project, scope: scope) }
- paths = scopes.zip(scopes.map { |scope| project_builds_path(@project, scope: scope) }).to_h = render "tabs", build_path: build_path
= render "builds", paths: paths
   
.nav-controls .nav-controls
- if can?(current_user, :update_build, @project) - if can?(current_user, :update_build, @project)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment