{% macro auth() %}
  <div class="row">
    <span class="label">Your username:</span>
    <input type="text" name="username"/>
  </div>
  
  <div class="row">
    <span class="label">Your password:</span>
    <input type="password" name="passwd"/>
  </div>
{% endmacro %}

{% macro cancel_pending_build(cancel_url, authz, short=False, id='all') %}
  {% if not short or not authz.needAuthForm('cancelPendingBuild') %}
    <form method="post" action="{{ cancel_url }}" class='command cancelbuild'
               {{ 'style="display:inline"' if short else '' }}>
      {% if not short %}
        {% if on_all %}
          <p>To cancel all builds, fill out the following fields and
            push the 'Cancel' button</p>
        {% else %}
          <p>To cancel this build, fill out the following fields and
            push the 'Cancel' button</p>
        {% endif %}
      {% endif %}
      
      {% if authz.needAuthForm('cancelPendingBuild') %}
        {{ auth() }}
      {% elif not short %}
        <p>To cancel individual builds, click the 'Cancel' buttons above.</p>
      {% endif %}
      
      <input type="hidden" name="id" value="{{ id }}" />
      <input type="submit" value="Cancel" />
    </form>
  {% endif %}
{% endmacro %}

{% macro stop_build(stop_url, authz, on_all=False, short=False, label="Build") %}
  {% if not short or not authz.needAuthForm('stopBuild') %}
    <form method="post" action="{{ stop_url }}" class='command stopbuild'
               {{ 'style="display:inline"' if short else '' }}>
      {% if not short %}
        {% if on_all %}
          <p>To stop all builds, fill out the following fields and
          push the <i>Stop {{label}}</i> button</p>
        {% else %}
          <p>To stop this build, fill out the following fields and
          push the <i>Stop {{label}}</i> button</p>
        {% endif %}
      {% endif %}
      
      {% if authz.needAuthForm('stopBuild') %}
        {{ auth() }}
      {% endif %}
      
      {% if not short %}
        <div class="row">
          <span class="label">Reason:</span>
          <input type="text" name="comments"/>
        </div>
      {% endif %}
  
      <input type="submit" value="Stop {{ label }}" />
    </form>
  {% endif %}
{% endmacro %}

{% macro force_build(force_url, authz, on_all=False) %}
 <form method="post" action="{{ force_url }}" class="command forcebuild">  

  {% if on_all %}
     <p>To force a build on <strong>all Builders</strong>, fill out the following fields
          and push the 'Force Build' button</p>
  {% else %}
     <p>To force a build, fill out the following fields and
        push the 'Force Build' button</p>
  {% endif %}
  
  {% if authz.needAuthForm('forceBuild') %}
    {{ auth() }}
  {% else %}
  <div class="row">
    <span class="label">
      Your name:
    </span>
    <input type="text" name="username"/>
  </div>
  {% endif %}
  
  <div class="row">
     <span class="label">Reason for build:</span>
     <input type='text' name='comments' />
  </div>
  <div class="row">
     <span class="label">Branch to build:</span>
     <input type='text' name='branch' />
  </div>
  <div class="row">
     <span class="label">Revision to build:</span>
     <input type='text' name='revision' />
  </div>
  {% for i in range(1,4) %}
  <div class="row">
     Property {{ i }}
     <span class="label">Name:</span>
     <span class="field"><input type="text" name="property{{ i }}name" /></span>
     <span class="label">Value:</span>
     <span class="field"><input type="text" name="property{{ i }}value" /></span>
  </div>
  {% endfor %}
  
  <input type="submit" value="Force Build" /> 
 </form>
{% endmacro %}

{% macro graceful_shutdown(shutdown_url, authz) %}
  <form method="post" action="{{ shutdown_url }}" class='command graceful_shutdown'>
  
  <p>To cause this slave to shut down gracefully when it is idle,
    push the 'Graceful Shutdown' button</p>
    
  {% if authz.needAuthForm('gracefulShutdown') %}
    {{ auth() }}
  {% endif %}
  
  <input type="submit" value="Graceful Shutdown" /> 
 </form>
{% endmacro %}

{% macro ping_builder(ping_url, authz) %}
  <form method="post" action="{{ ping_url }}" class='command ping_builder'>
    <p>To ping the buildslave(s), push the 'Ping' button</p>
  
  {% if authz.needAuthForm('gracefulShutdown') %}
    {{ auth() }}
  {% endif %}
  
    <input type="submit" value="Ping Builder" />
  </form>
{% endmacro %}

{% macro rebuild_build(rebuild_url, authz, exactly, ss) %}
 <form method="post" action="{{ rebuild_url }}" class="command rebuild">  
  
    {% if exactly %}
      <p>This tree was built from a specific set of
          source files, and can be rebuilt exactly</p>
    {% else %}
      <p>This tree was built from the most recent revision
      {% if ss.branch %}
        (along branch {{ ss.branch }})
      {% endif %}            
      and thus it might not be possible to rebuild it
      exactly. <br/>Any changes that have been committed 
      after this build was started <b>will</b> be 
      included in a rebuild.</p>
    {% endif %}


  {% if on_all %}
     <p>To force a build on <strong>all Builders</strong>, fill out the following fields
          and push the 'Force Build' button</p>
  {% else %}
     <p>To force a build, fill out the following fields and
        push the 'Force Build' button</p>
  {% endif %}
  
  {% if authz.needAuthForm('forceBuild') %}
    {{ auth() }}
  {% endif %}
   <div class="row">
     <span class="label">Reason for re-running build:</span>
     <input type='text' name='comments' />
   </div>       
   <input type="submit" value="Rebuild" />
 </form>
{% endmacro %}

