From cb6f035141d2e7792d9594e5d664d1a305b728cf Mon Sep 17 00:00:00 2001
From: Kamil Trzcinski <ayufan@ayufan.eu>
Date: Wed, 13 Apr 2016 17:05:17 +0200
Subject: [PATCH] Improve pipeline view

---
 app/controllers/projects/pipelines_controller.rb |  5 +++++
 app/views/projects/commit/_ci_commit.html.haml   |  3 +--
 app/views/projects/commit/_commit_box.html.haml  | 11 +++++++++--
 app/views/projects/pipelines/show.html.haml      |  6 ++++++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index b2ee5573bfc..aba64e4a730 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -1,5 +1,6 @@
 class Projects::PipelinesController < Projects::ApplicationController
   before_action :pipeline, except: [:index, :new, :create]
+  before_action :commit, only: [:show]
   before_action :authorize_read_pipeline!
   before_action :authorize_create_pipeline!, only: [:new, :create]
   before_action :authorize_update_pipeline!, only: [:retry, :cancel]
@@ -85,4 +86,8 @@ class Projects::PipelinesController < Projects::ApplicationController
   def pipeline
     @pipeline ||= project.ci_commits.find_by!(id: params[:id])
   end
+
+  def commit
+    @commit ||= @pipeline.commit_data
+  end
 end
diff --git a/app/views/projects/commit/_ci_commit.html.haml b/app/views/projects/commit/_ci_commit.html.haml
index cf101acbb53..782ea341daf 100644
--- a/app/views/projects/commit/_ci_commit.html.haml
+++ b/app/views/projects/commit/_ci_commit.html.haml
@@ -14,8 +14,7 @@
     = pluralize ci_commit.statuses.count(:id), "build"
     - if ci_commit.ref
       for
-      %span.label.label-info
-        = ci_commit.ref
+      = link_to ci_commit.ref, namespace_project_commits_path(@project.namespace, @project, ci_commit.ref), class: "monospace"
     - if defined?(link_to_commit) && link_to_commit
       for commit
       = link_to ci_commit.short_sha, namespace_project_commit_path(@project.namespace, @project, ci_commit.sha), class: "monospace"
diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml
index 0908e830f83..9cb14b6a90f 100644
--- a/app/views/projects/commit/_commit_box.html.haml
+++ b/app/views/projects/commit/_commit_box.html.haml
@@ -1,6 +1,6 @@
 .pull-right
   %div
-    - if @notes_count > 0
+    - if defined?(@notes_count) && @notes_count > 0
       %span.btn.disabled.btn-grouped
         %i.fa.fa-comment
         = @notes_count
@@ -42,7 +42,14 @@
   - @commit.parents.each do |parent|
     = link_to parent.short_id, namespace_project_commit_path(@project.namespace, @project, parent), class: "monospace"
 
-- if @commit.status
+- if defined?(pipeline) && pipeline
+  .pull-right
+    = link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline), class: "ci-status ci-#{pipeline.status}" do
+      = ci_icon_for_status(pipeline.status)
+      pipeline:
+      = ci_label_for_status(pipeline.status)
+
+- elsif @commit.status
   .pull-right
     = link_to builds_namespace_project_commit_path(@project.namespace, @project, @commit.id), class: "ci-status ci-#{@commit.status}" do
       = ci_icon_for_status(@commit.status)
diff --git a/app/views/projects/pipelines/show.html.haml b/app/views/projects/pipelines/show.html.haml
index 9f33e2ad624..8a2e14d8d87 100644
--- a/app/views/projects/pipelines/show.html.haml
+++ b/app/views/projects/pipelines/show.html.haml
@@ -1,3 +1,9 @@
 - page_title "Pipeline"
+
 = render "header_title"
+.prepend-top-default
+  - if @commit
+    = render "projects/commit/commit_box", pipeline: @pipeline
+  %div.block-connector
+
 = render "projects/commit/ci_commit", ci_commit: @pipeline
-- 
GitLab