{% extends "base.html" %}

{% block title %}Manage secrets{% endblock %}

{% block content %}
<h1>Manage secrets</h1>

{% if existing_secrets %}
<table>
  <tr><th>Secret</th><th>Note</th><th>Version</th><th>Last updated</th><th>Updated by</th></tr>
  {% for secret in existing_secrets %}
    <tr>
      <td><strong><a href="{{ urls.path("/-/secrets/") }}{{ secret.name }}">{{ secret.name }}</a></strong></td>
      <td>{{ secret.note }}</td>
      <td>{{ secret.version }}</td>
      <td>{{ secret.updated_at or "" }}</td>
      <td>{{ secret.updated_by or "" }}</td>
    </tr>
  {% endfor %}
</table>
{% endif %}

{% if unset_secrets %}
<p style="margin-top: 2em">The following secret{% if unset_secrets|length == 1 %} has{% else %}s have{% endif %} not been set:</p>
<ul>
  {% for secret in unset_secrets %}
    <li><strong><a href="{{ urls.path("/-/secrets/") }}{{ secret.name }}">{{ secret.name }}</a></strong>
    {% if secret.description_html %} - {{ secret.description_html|safe }}{% endif %}</li>
  {% endfor %}
</ul>
{% endif %}

{% if environment_secrets %}
<p style="margin-top: 2em">The following secret{% if environment_secrets|length == 1 %} is{% else %}s are{% endif %} set using environment variables:</p>
<ul>
  {% for secret in environment_secrets %}
    <li><strong>{{ secret.name }}</a></strong>- {{ secret.description_html|safe }}<br>
      <span style="font-size: 0.8 em">Set by <code>DATASETTE_SECRETS_{{ secret.name }}</code></span></li>
  {% endfor %}
</ul>
{% endif %}

{% endblock %}