From 0bd525005ba279eae2733c0c68df280e4fb25b70 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Thu, 13 Oct 2016 14:59:23 -0500 Subject: [PATCH] Move sidebar build class into helper --- app/helpers/builds_helper.rb | 7 +++++++ app/views/projects/builds/_sidebar.html.haml | 4 ++-- app/views/projects/ci/builds/_build.html.haml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 app/helpers/builds_helper.rb diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb new file mode 100644 index 00000000000..b2004b99961 --- /dev/null +++ b/app/helpers/builds_helper.rb @@ -0,0 +1,7 @@ +module BuildsHelper + def sidebar_build_class(build, current_build) + build_class = '' + build_class += ' active' if build == current_build + build_class += ' retried' if build.retried? + end +end diff --git a/app/views/projects/builds/_sidebar.html.haml b/app/views/projects/builds/_sidebar.html.haml index 5ec214a31d0..839abd82bba 100644 --- a/app/views/projects/builds/_sidebar.html.haml +++ b/app/views/projects/builds/_sidebar.html.haml @@ -126,7 +126,7 @@ .builds-container - statuses.each do |build_status| - builds.select{|build| build.status == build_status}.each do |build| - .build-job{class: ('active' if build == @build; 'retried' if build.retried?), data: {stage: build.stage}} + .build-job{class: sidebar_build_class(build, @build), data: {stage: build.stage}} = link_to namespace_project_build_path(@project.namespace, @project, build) do = icon('arrow-right') = ci_icon_for_status(build.status) @@ -136,4 +136,4 @@ - else = build.id - if build.retried? - %i.fa.fa-refresh.has-tooltip{data: { container: 'body', placement: 'bottom' }, title: 'This build was retried'} + %i.fa.fa-refresh.has-tooltip{data: { container: 'body', placement: 'bottom' }, title: 'Build was retried'} diff --git a/app/views/projects/ci/builds/_build.html.haml b/app/views/projects/ci/builds/_build.html.haml index c007f5f2e60..583fd958849 100644 --- a/app/views/projects/ci/builds/_build.html.haml +++ b/app/views/projects/ci/builds/_build.html.haml @@ -37,7 +37,7 @@ = icon('warning', class: 'text-warning has-tooltip', title: 'Build is stuck. Check runners.') - if defined?(retried) && retried - = icon('refresh', class: 'text-warning has-tooltip', title: 'Build was retried.') + = icon('refresh', class: 'text-warning has-tooltip', title: 'Build was retried') .label-container - if build.tags.any?