<h2 class="page-header well">
    <a class="h2 text-primitive" href="{{group_url(project.group)}}">{{project.group.display_name}}</a>
    » <a class="h2 text-primitive" href="{{project_url(project)}}">{{project.display_name}}</a>
    » {% include "squad/_unfinished_build.jinja2" %} <a class="h2 text-primary" href="{{build_url(build)}}">{{ _('Build %s') % build.version }}</a>
</h2>

{% if build.patch_source and build.patch_id %}
<div class="well">
    <div class="row">
      <div id="patchsource_text" class="col-md-11">
      {% if build.patch_url %}
        {{ _('Build was started by') }} <a href="{{ build.patch_url }}">{{ build.patch_url }}</a>.
      {% else %}
        {{ _('Build was started by') }} {{ _('change') }} {{ build.patch_id }} {{ _('from') }} {{ build.patch_source.url }}.
      {% endif %}
      </div>
    </div>
</div>
{% endif %}

{% if project.can_submit_testjobs(user) %}
<div class="highlight-row">
  <div class="alert alert-info annotation-alert">
    <div class="row">
      <div id="annotation_text" class="col-md-11 annotation-text-col {% if not build.annotation %}hidden{% endif %}">
        {% if build.annotation %}
        <strong>{{ _('Annotation:') }}</strong>
        {{ build.annotation.description }}
        {% endif %}
      </div>
      <div class="col-md-1">
        <a href="#" data-toggle="modal" data-target="#annotation_modal">
          <button id="annotation_button" type="submit" class="btn btn-primary">{% if build.annotation %}{{ _('Update') }}{% else %}{{ _('Add annotation') }}{% endif %}</button>
        </a>
      </div>
    </div>
  </div>
</div>
{% endif %}

<ul class="page-header nav nav-pills build-nav-header">
    {% with url_name=request.resolver_match.url_name %}

    <li role="presentation" {% if url_name == 'build' %}class="active"{% endif %}>
        <a href="{{build_url(build)}}">
            {{ _('Build summary') }}
        </a>
    </li>
    <li role="presentation" {% if url_name == 'tests' or url_name == 'test_history' %}class="active"{% endif %}>
        <a href="{{build_section_url(build, 'tests')}}">
            {{ _('All test results') }}
        </a>
    </li>
    <li role="presentation" {% if url_name == 'build_metadata' %}class="active"{% endif %}>
        <a href="{{build_section_url(build, 'build_metadata')}}">
        {{ _('Metadata') }}
        </a>
    </li>
    {% if build.test_jobs.count() %}
    <li role="presentation" {% if url_name == 'testjobs' %}class="active"{% endif %}>
        <a href="{{build_section_url(build, 'testjobs')}}">
            {{ _('Test jobs') }}
        {% for i in build|filter_jobs %}
        <span class="badge badge-{{ i.0 }}" data-toggle="tooltip" data-placement="top" title="{{ i.0 }}">{{ i.1 }}</span>
        {% endfor %}
        </a>
    </li>
    {% endif %}
    {% if project.writable_by(user) and build.callbacks.count() %}
    <li role="presentation" {% if url_name == 'build_callbacks' %}class="active"{% endif %}>
        <a href="{{build_section_url(build, 'build_callbacks')}}">
            {{ _('Callbacks') }}
        </a>
    </li>
    {% endif %}
    {% if project.writable_by(user) %}
    <li role="presentation" {% if url_name == 'build_settings' %}class="active"{% endif %}>
        <a href="{{build_section_url(build, 'build_settings')}}">
            {{ _('Build Settings') }}
        </a>
    </li>
    {% endif %}

    {% endwith %}
    <a href="{{next_build_url(build)}}" class="btn btn-default pull-right" data-toggle="tooltip" data-placement="bottom" title="Next Build"><i class='fa fa-chevron-right'>&nbsp;</i></a>
    <a href="{{back_to_latest_build_url(build)}}" class="btn btn-default pull-right" data-toggle="tooltip" data-placement="bottom" title="Latest Build"><i class='fa fa-arrow-circle-up '>&nbsp;</i></a>
    <a href="{{previous_build_url(build)}}" class="btn btn-default pull-right" data-toggle="tooltip" data-placement="bottom" title="Previous Build"><i class='fa fa-chevron-left'>&nbsp;</i></a>

</ul>

<!-- Modal HTML -->
<div id="annotation_modal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">{{ _('Build annotation') }}</h4>
      </div>
      <form class="well" id="annotation_form" ng-controller="AnnotationController" ng-submit="updateAnnotation('{{ build.id }}')" ng-init="{% if build.annotation%}annotation_id={{ build.annotation.id }}{% endif %}">
        <div class="modal-body">
          <div class="row">
            <div class="col-md-2">
              <label for="description">{{ _('Description:') }}</label>
            </div>
            <div class="col-md-10">
              <input name="description" class="annotation-description" ng-model="description" placeholder="Annotation description" ng-init="description='{% if build.annotation %}{{ build.annotation.description }}{% endif %}'" />
            </div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">{{ _('Close') }}</button>
        <button class="btn btn-primary">{{ _('Save') }}</button>
      </div>
      </form>
    </div>
  </div>
</div>
