<div class="page">
  <header class="page-header">
    <h1 class="page-title"><%= message('project_quality_gate.page') -%></h1>
    <p class="page-description"><%= message('project_quality_gate.page.description') -%></p>
  </header>

  <form id="select-quality-gate" method="POST" action="<%= ApplicationController.root_context -%>/project/set_qualitygate">
    <input type="hidden" name="id" value="<%= @project_id -%>"/>
    <input type="hidden" name="previous_qgate_id" value="<%= @selected_qgate -%>"/>

    <select id="select-qgate" name="qgate_id">
      <option value="" <%= "selected='selected'" unless @selected_qgate -%>><%= message 'project_quality_gate.default_qgate' -%></option>
      <optgroup>
        <%
           qgates = Api::Utils.insensitive_sort(@all_quality_gates) { |qgate| qgate.name }
           qgates.each do |qgate|
        %>
          <option value="<%= qgate.id -%>" <%= "selected='selected'" if @selected_qgate && (@selected_qgate == qgate.id) -%>><%= h qgate.name -%></option>
        <% end %>
      </optgroup>
    </select>

    <%= submit_tag message('update_verb'), :id => "submit-qgate", :disable_with => message('updating') %>
  </form>
</div>
