From 696a7084010315078c38507cccabb236bb3d794a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 23 Oct 2015 17:32:52 +0200 Subject: Move rendering CI status to helper Signed-off-by: Dmitriy Zaporozhets --- app/helpers/ci_status_helper.rb | 7 +++++++ app/views/projects/commits/_commit.html.haml | 3 +-- app/views/projects/merge_requests/_merge_request.html.haml | 4 +--- app/views/shared/projects/_project.html.haml | 4 +--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index dbd1e26fa79..ceafe5e8c91 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -42,4 +42,11 @@ module CiStatusHelper icon(icon_name) end + + def render_ci_status(ci_commit) + link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", + title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do + ci_status_icon(ci_commit) + end + end end diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index cddd5aa3a83..b7998dd12c1 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -18,8 +18,7 @@ .pull-right - if ci_commit - = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}" do - = ci_status_icon(ci_commit) + = render_ci_status(ci_commit)   = link_to commit.short_id, namespace_project_commit_path(project.namespace, project, commit), class: "commit_short_id" diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index a285d5d660e..300a3715292 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -8,9 +8,7 @@ = link_to_label(label, project: merge_request.project) .pull-right.light - if ci_commit - = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", - title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do - = ci_status_icon(ci_commit) + = render_ci_status(ci_commit) - if merge_request.merged? %span %i.fa.fa-check diff --git a/app/views/shared/projects/_project.html.haml b/app/views/shared/projects/_project.html.haml index aee839b44e7..c36995b94d7 100644 --- a/app/views/shared/projects/_project.html.haml +++ b/app/views/shared/projects/_project.html.haml @@ -21,9 +21,7 @@ .project-controls - if ci && !project.empty_repo? && project.commit - if ci_commit = project.ci_commit(project.commit.sha) - = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", - title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do - = ci_status_icon(ci_commit) + = render_ci_status(ci_commit)   - if stars %span -- cgit v1.2.1