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

{% comment %}
Copyright (C) 2017-2024  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 %}
  <div class="table-responsive mt-2 mb-2">
    <div class="row float-end mb-2">{% include "./includes/branch-search.html" %}</div>
    <table class="table swh-table swh-table-striped">
      <thead>
        <tr>
          <th>
            <i class="{{ swh_object_icons.branch }} mdi-fw" aria-hidden="true"></i>Name
          </th>
          <th>Target</th>
          <th>Message</th>
          <th>Date</th>
        </tr>
      </thead>
      <tbody>
        {% if displayed_branches|length > 0 %}
          {% for branch in displayed_branches %}
            <tr class="swh-branch-entry swh-tr-hover-highlight">
              <td class="swh-branch-name">
                <a href="{{ branch.directory_url }}">
                  {% if branch.alias %}
                    <i class="{{ swh_object_icons.alias }} mdi-fw" aria-hidden="true"></i>
                  {% else %}
                    <i class="{{ swh_object_icons.branch }} mdi-fw" aria-hidden="true"></i>
                  {% endif %}
                  {{ branch.name }}
                </a>
              </td>
              <td class="swh-branch-target">
                <a href="{{ branch.target_url }}">
                  <i class="{{ swh_object_icons|key_value:branch.target_type }} mdi-fw"
                     aria-hidden="true"
                     title="{{ branch.tooltip }}"></i>{{ branch.target|slice:":7" }}
                </a>
              </td>
              <td class="swh-branch-message swh-table-cell-text-overflow"
                  title="{{ branch.message }}">{{ branch.message }}</td>
              <td class="swh-branch-date">{{ branch.date }}</td>
            </tr>
          {% endfor %}
        {% else %}
          <tr>
            <td>
              {% if search_string %}
                No branch names containing {{ search_string }} have been found!
              {% else %}
                The list of branches is empty!
              {% endif %}
            </td>
          </tr>
        {% endif %}
      </tbody>
    </table>
  </div>
{% endblock swh-browse-content %}

{% 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 swh-browse-after-content %}
