{% extends "./browse.html" %}

{% comment %}
Copyright (C) 2017-2018  The Software Heritage developers
See the AUTHORS file at the top-level directory of this distribution
License: GNU Affero General Public License version 3, or any later version
See top-level LICENSE file for more information
{% endcomment %}


{% load swh_templatetags %}

{% block swh-browse-content %}
{% if displayed_branches|length > 0 %}
  <div class="table-responsive mt-3 mb-3">
    <table class="table swh-table swh-table-striped">
      <thead>
        <tr>
          <th><i class="{{ swh_object_icons.branch }} fa-fw"></i>Name</th>
          <th>Revision</th>
          <th>Message</th>
          <th>Date</th>
        </tr>
      </thead>
      <tbody>
        {% for branch in displayed_branches %}
          <tr class="swh-branch-entry swh-tr-hover-highlight" data-href="{{ branch.directory_url }}">
            <td class="swh-branch-name">
              <a href="{{ branch.directory_url }}">
                <i class="{{ swh_object_icons.branch }} fa-fw"></i>{{ branch.name }}
              </a>
            </td>
            <td>
              <a href="{{ branch.revision_url }}">
                {{ branch.revision|slice:":7" }}
              </a>
            </td>
            <td class="swh-branch-message swh-table-cell-text-overflow" title="{{ branch.message }}">
              <a href="{{ branch.directory_url }}">
                {{ branch.message }}
              </a>
            </td>
            <td class="swh-branch-date">
              <a href="{{ branch.directory_url }}">
                {{ branch.date }}
              </a>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <script>
    swh.webapp.initTableRowLinks('tr.swh-branch-entry');
  </script>

{% else %}
  <i>The list of branches is empty !</i>
{% endif %}
{% endblock %}

{% block swh-browse-after-content %}
{% if prev_branches_url or next_branches_url %}
  <ul class="pagination justify-content-center">
    {% if prev_branches_url %}
      <li class="page-item"><a class="page-link" href="{{ prev_branches_url }}">Previous</a></li>
    {% else %}
      <li class="page-item disabled"><a class="page-link">Previous</a></li>
    {% endif %}

    {% if next_branches_url %}
      <li class="page-item"><a class="page-link" href="{{ next_branches_url }}">Next</a></li>
    {% else %}
      <li class="page-item disabled"><a class="page-link">Next</a></li>
    {% endif %}
  </ul>
{% endif %}
{% endblock %}
