- @no_container = true
- page_title "Environments"
= render "projects/pipelines/head"

%div{ class: container_class }
  .top-area.adjust
    .col-md-7
      %h3.page-title= @environment.name
    .col-md-5
      .nav-controls
        = render 'projects/environments/terminal_button', environment: @environment
        = render 'projects/environments/external_url', environment: @environment
        = render 'projects/environments/metrics_button', environment: @environment
        - if can?(current_user, :update_environment, @environment)
          = link_to 'Edit', edit_namespace_project_environment_path(@project.namespace, @project, @environment), class: 'btn'
        - if can?(current_user, :create_deployment, @environment) && @environment.can_stop?
          = link_to 'Stop', stop_namespace_project_environment_path(@project.namespace, @project, @environment), data: { confirm: 'Are you sure you want to stop this environment?' }, class: 'btn btn-danger', method: :post

  .environments-container
    - if @deployments.blank?
      .blank-state.blank-state-no-icon
        %h2.blank-state-title
          You don't have any deployments right now.
        %p.blank-state-text
          Define environments in the deploy stage(s) in
          %code .gitlab-ci.yml
          to track deployments here.
        = link_to "Read more", help_page_path("ci/environments"), class: "btn btn-success"
    - else
      .table-holder
        %table.table.ci-table.environments
          %thead
            %tr
              %th ID
              %th Commit
              %th Job
              %th Created
              %th.hidden-xs

          = render @deployments

      = paginate @deployments, theme: 'gitlab'