{% extends "layout.html" %}
{% import "partials/resourcenav.html" as rnav with context %}

{% block title %}
<title>
  {{ owner.canonical_name }}/{{ ml.name }} archives &mdash; {{site}}
</title>
{% endblock %}

{% block body %}
{% set fluid = view in ["archives", "patches"] %}
{{ rnav.project_nav(ml, projects, fluid=fluid) }}
<div class="header-tabbed resource-nav">
  {% if fluid %}
  <div class="container-fluid">
  {% else %}
  <div class="container">
  {% endif %}
    {% block tabs %}
    {% macro link(path, title) %}
    <a
      class="nav-link {% if view == title %}active{% endif %}"
      href="{{ path }}">{{ title }}</a>
    {% endmacro %}

    {% if len(projects) == 1 and projects[0].name != ml.name %}
    <h3>{{ml.name}}</h3>
    {% endif %}

    <ul class="nav nav-tabs">
      {% if ml.visibility != Visibility.PUBLIC %}
      <li
        class="nav-item nav-text vis-{{ml.visibility.value.lower()}}"
        {% if ml.visibility == Visibility.UNLISTED %}
        title="This tracker is only visible to those who know the URL."
        {% elif ml.visibility == Visibility.PRIVATE %}
        title="This tracker is only visible to those who were invited to view it."
        {% endif %}
      >
        {% if ml.visibility == Visibility.UNLISTED %}
        Unlisted
        {% elif ml.visibility == Visibility.PRIVATE %}
        Private
        {% endif %}
      </li>
      {% endif %}
      <li class="nav-item">
        {{link(url_for("archives.archive",
          owner_name=owner.canonical_name,
          list_name=ml.name),
          "archive" if view == "archive" else "archives")}}
      </li>
      {% if ListAccess.browse in access %}
      <li class="nav-item">
        {{link(url_for("patches.patchlist",
          owner_name=owner.canonical_name,
          list_name=ml.name),
          "patch" if view == "patch" else "patches")}}
      </li>
      {% endif %}

      {% set posting_address = post_address(ml) %}
      {% if posting_address %}
      {% if ListAccess.post in access %}
      <li class="nav-item">
        <a
          class="nav-link {% if view == "post" %}active{% endif %}"
          {% if posting_address.startswith("mailto:") %}
          href="{{posting_address}}"
          {% else %}
          href="mailto:{{posting_address}}"
          {% endif %}
        >new post</a>
      </li>
      {% endif %}
      {% endif %}
      {% if current_user.id == ml.owner_id %}
      <li class="nav-item">
        {{link(url_for("settings.info_GET",
          owner_name=ml.owner.canonical_name,
          list_name=ml.name), "settings")}}
      </li>
      {% endif %}
    </ul>
    {% endblock %}
  </div>
</div>
{% block content %}{% endblock %}
{% endblock %}
