{% extends "base.html" %}
{% load static %}

{% block title %}Older releases — {{ sub_product.name }} — {{ main_product.name }}{% endblock %}
{% block meta_description %}Archived releases for {{ sub_product.name }}.{% endblock %}

{% block content %}

<section class="page-hero" aria-labelledby="versions-heading">
  <div class="page-hero-blobs" aria-hidden="true">
    <div class="blob blob--1"></div>
    <div class="blob blob--2"></div>
  </div>
  <div class="container">
    <nav class="breadcrumb" aria-label="Breadcrumb">
      <ol class="breadcrumb-list" role="list">
        <li><a href="{% url 'pages:home' %}">Home</a></li>
        <li aria-hidden="true" class="breadcrumb-sep">›</li>
        <li><a href="{% url 'products:overview' %}">Products</a></li>
        <li aria-hidden="true" class="breadcrumb-sep">›</li>
        <li><a href="{{ main_product.get_absolute_url }}">{{ main_product.name }}</a></li>
        <li aria-hidden="true" class="breadcrumb-sep">›</li>
        <li><a href="{{ sub_product.get_absolute_url }}">{{ sub_product.name }}</a></li>
        <li aria-hidden="true" class="breadcrumb-sep">›</li>
        <li aria-current="page">Older releases</li>
      </ol>
    </nav>
    <div class="page-hero-content">
      <div class="section-badge">{{ sub_product.name }}</div>
      <h1 class="page-hero-title" id="versions-heading">Older releases</h1>
      <p class="page-hero-subtitle">Archived versions of this module.</p>
    </div>
  </div>
</section>

<section class="section versions-archive-section">
  <div class="container">
    {% if not archive_versions %}
    <p class="versions-empty glass-card">There are no archived releases for this module.</p>
    {% elif distribution_installable %}
    <div class="versions-table-wrap glass-card fade-in">
      <table class="versions-table">
        <thead>
          <tr>
            <th scope="col">Version</th>
            {% for fname, label, icon in archive_specs %}
            <th scope="col">{{ label }}</th>
            {% endfor %}
          </tr>
        </thead>
        <tbody>
          {% for row in archive_rows_installable %}
          <tr>
            <th scope="row">{{ row.version_obj.version }}</th>
            {% for cell in row.cells %}
            <td>
              {% if cell.url %}
                {% if cell.icon %}
                <a href="{{ cell.url }}" class="versions-table-link">
                  <img src="{% static cell.icon %}" alt="" width="22" height="22" class="versions-table-icon" aria-hidden="true" />
                  <span class="sr-only">{{ cell.label }}</span>
                </a>
                {% else %}
                <a href="{{ cell.url }}" class="versions-table-text-link" rel="noopener noreferrer">Source</a>
                {% endif %}
              {% else %}
              <span class="versions-na">—</span>
              {% endif %}
            </td>
            {% endfor %}
          </tr>
          {% if row.version_obj.release_notes %}
          <tr class="versions-notes-row">
            <td colspan="{{ archive_specs|length|add:1 }}">
              <span class="versions-notes-label">Notes</span>
              <p class="versions-notes-body">{{ row.version_obj.release_notes }}</p>
            </td>
          </tr>
          {% endif %}
          {% endfor %}
        </tbody>
      </table>
    </div>
    {% else %}
    <ul class="versions-package-list" role="list">
      {% for ver in archive_versions %}
      <li class="versions-package-card glass-card fade-in">
        <div class="versions-package-head">
          <span class="download-version">v{{ ver.version }}</span>
          {% if ver.package_resource_url %}
          <a href="{{ ver.package_resource_url }}" class="btn-ghost btn--sm" target="_blank" rel="noopener noreferrer">Open</a>
          {% endif %}
        </div>
        {% if ver.release_notes %}
        <p class="versions-notes-body">{{ ver.release_notes }}</p>
        {% endif %}
      </li>
      {% endfor %}
    </ul>
    {% endif %}
  </div>
</section>

{% endblock %}
