- status = pipeline.status
%tr.commit
  %td.commit-link
    = link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id) do
      = ci_status_with_icon(status)


  %td
    .branch-commit
      = link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id) do
        %span ##{pipeline.id}
      - if pipeline.ref
        .icon-container
          = pipeline.tag? ? icon('tag') : icon('code-fork')
        = link_to pipeline.ref, namespace_project_commits_path(@project.namespace, @project, pipeline.ref), class: "monospace branch-name"
        .icon-container
          = custom_icon("icon_commit")
      = link_to pipeline.short_sha, namespace_project_commit_path(@project.namespace, @project, pipeline.sha), class: "commit-id monospace"
      - if pipeline.latest?
        %span.label.label-success.has-tooltip{ title: 'Latest build for this branch' } latest
      - if pipeline.triggered?
        %span.label.label-primary triggered
      - if pipeline.yaml_errors.present?
        %span.label.label-danger.has-tooltip{ title: "#{pipeline.yaml_errors}" } yaml invalid
      - if pipeline.builds.any?(&:stuck?)
        %span.label.label-warning stuck

      %p.commit-title
        - if commit = pipeline.commit
          = author_avatar(commit, size: 20)
          = link_to_gfm truncate(commit.title, length: 60), namespace_project_commit_path(@project.namespace, @project, commit.id), class: "commit-row-message"
        - else
          Cant find HEAD commit for this branch


    - stages_status = pipeline.statuses.latest.stages_status
    - stages.each do |stage|
      %td.stage-cell
        - status = stages_status[stage]
        - tooltip = "#{stage.titleize}: #{status || 'not found'}"
        - if status
          = link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id, anchor: stage), class: "has-tooltip ci-status-icon-#{status}", title: tooltip do
            = ci_icon_for_status(status)
        - else
          .light.has-tooltip{ title: tooltip }
            \-

  %td
    - if pipeline.duration
      %p.duration
        = custom_icon("icon_timer")
        = duration_in_numbers(pipeline.duration)
    - if pipeline.finished_at
      %p.finished-at
        = icon("calendar")
        #{time_ago_with_tooltip(pipeline.finished_at, short_format: true, skip_js: true)}

  %td.pipeline-actions
    .controls.hidden-xs.pull-right
      - artifacts = pipeline.builds.latest.with_artifacts_not_expired
      - actions = pipeline.manual_actions
      - if artifacts.present? || actions.any?
        .btn-group.inline
          - if actions.any?
            .btn-group
              %a.dropdown-toggle.btn.btn-default{type: 'button', 'data-toggle' => 'dropdown'}
                = icon("play")
                %b.caret
              %ul.dropdown-menu.dropdown-menu-align-right
                - actions.each do |build|
                  %li
                    = link_to play_namespace_project_build_path(@project.namespace, @project, build), method: :post, rel: 'nofollow' do
                      = icon("play")
                      %span= build.name.humanize
          - if artifacts.present?
            .btn-group
              %a.dropdown-toggle.btn.btn-default.build-artifacts{type: 'button', 'data-toggle' => 'dropdown'}
                = icon("download")
                %b.caret
              %ul.dropdown-menu.dropdown-menu-align-right
                - artifacts.each do |build|
                  %li
                    = link_to download_namespace_project_build_artifacts_path(@project.namespace, @project, build), rel: 'nofollow' do
                      = icon("download")
                      %span Download '#{build.name}' artifacts

      - if can?(current_user, :update_pipeline, @project)
        .cancel-retry-btns.inline
          - if pipeline.retryable?
            = link_to retry_namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: 'btn has-tooltip', title: "Retry", method: :post do
              = icon("repeat")
          - if pipeline.cancelable?
            = link_to cancel_namespace_project_pipeline_path(@project.namespace, @project, pipeline.id), class: 'btn btn-remove has-tooltip', title: "Cancel", method: :post do
              = icon("remove")