From e81ed371a10012c2d09f67b3523c3ba3fd17c7bd Mon Sep 17 00:00:00 2001 From: Katarzyna Kobierska Date: Wed, 10 Aug 2016 13:07:03 +0200 Subject: [PATCH] Change the way paths are generated --- app/controllers/admin/builds_controller.rb | 2 -- app/controllers/projects/builds_controller.rb | 2 -- app/views/admin/builds/index.html.haml | 5 ++--- .../builds/{_builds.html.haml => _tabs.html.haml} | 10 +++++----- app/views/projects/builds/index.html.haml | 5 ++--- 5 files changed, 9 insertions(+), 15 deletions(-) rename app/views/projects/builds/{_builds.html.haml => _tabs.html.haml} (74%) diff --git a/app/controllers/admin/builds_controller.rb b/app/controllers/admin/builds_controller.rb index c4e91d8f869..88f3c0e2fd4 100644 --- a/app/controllers/admin/builds_controller.rb +++ b/app/controllers/admin/builds_controller.rb @@ -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' diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index c6a57ff8cb1..77934ff9962 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -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' diff --git a/app/views/admin/builds/index.html.haml b/app/views/admin/builds/index.html.haml index f0599bd3004..1bf4cb4d124 100644 --- a/app/views/admin/builds/index.html.haml +++ b/app/views/admin/builds/index.html.haml @@ -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? diff --git a/app/views/projects/builds/_builds.html.haml b/app/views/projects/builds/_tabs.html.haml similarity index 74% rename from app/views/projects/builds/_builds.html.haml rename to app/views/projects/builds/_tabs.html.haml index 61542f8a7cc..50894975a88 100644 --- a/app/views/projects/builds/_builds.html.haml +++ b/app/views/projects/builds/_tabs.html.haml @@ -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)) diff --git a/app/views/projects/builds/index.html.haml b/app/views/projects/builds/index.html.haml index 765e239d1de..ec5e33366d1 100644 --- a/app/views/projects/builds/index.html.haml +++ b/app/views/projects/builds/index.html.haml @@ -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)