- page_title "Builds"
= render "header_title"

.project-issuable-filter
  .controls
    - if can?(current_user, :manage_builds, @project)
      .pull-left.hidden-xs
        - if @all_builds.running_or_pending.any?
          = link_to 'Cancel running', cancel_all_namespace_project_builds_path(@project.namespace, @project), data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post

  %ul.center-top-menu
    %li{class: ('active' if @scope.nil?)}
      = link_to project_builds_path(@project) do
        All
        %span.badge.js-totalbuilds-count
          = number_with_delimiter(@all_builds.count(:id))

    %li{class: ('active' if @scope == 'running')}
      = link_to project_builds_path(@project, scope: :running) do
        Running
        %span.badge.js-running-count
          = number_with_delimiter(@all_builds.running_or_pending.count(:id))

    %li{class: ('active' if @scope == 'finished')}
      = link_to project_builds_path(@project, scope: :finished) do
        Finished
        %span.badge.js-running-count
          = number_with_delimiter(@all_builds.finished.count(:id))

.gray-content-block
  #{(@scope || 'running').capitalize} builds from this project

%ul.content-list
  - if @builds.blank?
    %li
      .nothing-here-block No builds to show
  - else
    .table-holder
      %table.table.builds
        %thead
          %tr
            %th Status
            %th Build ID
            %th Commit
            %th Ref
            %th Stage
            %th Name
            %th Duration
            %th Finished at
            %th

        - @builds.each do |build|
          = render 'projects/commit_statuses/commit_status', commit_status: build, commit_sha: true, stage: true, allow_retry: true

    = paginate @builds, theme: 'gitlab'
