{% extends "coprs/detail.html" %}
{% from "_helpers.html" import build_href, package_href %}
{% from "coprs/detail/_builds_forms.html" import copr_build_form_rebuild with context %}
{% from "coprs/detail/_describe_source.html" import describe_source %}

{% set add_build_tab = "rebuild" %}

{%block project_breadcrumb %}
<li>
  <a href="{{ url_builds }}">Builds</a>
</li>
<li>
  <a href="{{ build_href(build) }}">
  {{build.id}}
  </a>
</li>
<li class="active">
  Resubmit
</li>
{%endblock%}


{% block detail_body %}
<div class="row">
  <div class="col-sm-12">
    <h2> Resubmit build {{ build.id }}  </h2>
    <p> Resubmitting a build will rebuild the same sources again. </p>

    {% if allow_user_ssh %}
      <h3>SSH access to the builder</h3>
      <p>
        You will obtain a SSH access to the builder to easily debug your
        package within the Copr infrastructure.
        <br>
        Check your <code>backend.log</code> for instructions on how
        to connect to the builder.
        <br>
        After connecting, run <code>copr-builder help</code> for instructions on
        how to work with the builder.
        <br>
        There is a limit for max 2 builders wih SSH access per user. The rest of
        builds will remain in the <code>pending</code> state until a slot is freed.
      </p>
    {% endif %}

    <h3> Original Build Details </h3>
    <dl class="dl-horizontal">
      <dt> Package:</dt>
      <dd>
        {% if build.package %}
          <a href="{{ package_href(build.package) }}">
            {{ build.package.name }}
          </a>
        {% else %}
             -
        {% endif %}
      </dd>
      <dt> Version:</dt>
      <dd>
        {% if build.pkg_version %}
            {{ build.pkg_version}}
        {% else %}
             -
        {% endif %}
      </dd>
      {{ describe_source(build.source_type_text, build.source_json_dict) }}
    </dl>

    {{ copr_build_form_rebuild(form, 'coprs_ns.copr_new_build_rebuild',
       copr, build, allow_user_ssh) }}
  </div>
</div>
{% endblock %}
