{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}

{% load i18n %}
{% load extras %}

{% block toolbar %}

  <section class="toolbar">
    <div class="btn-toolbar" role="toolbar">

      {% include "clients-button.html" with clients=app_info.clients enabled=is_enabled %}

      {% if app_info.donation_url %}
        <a target="_blank" rel="noopener noreferrer"
           class="btn btn-default button-secondary button-donate" role="button"
           href="{{ app_info.donation_url }}">
          {% icon 'heart' %}
          {% trans "Donate" %}
          {% icon 'external-link' %}
        </a>
      {% endif %}

      {% if has_diagnostics or has_logs or show_uninstall or has_backup_restore %}
        <!-- Single button -->
        <div class="btn-group button-secondary dropdown">
          <button type="button" class="btn btn-default dropdown-toggle"
                  data-bs-toggle="dropdown" aria-haspopup="true"
                  aria-expanded="false" id="id_extra_actions_button">
            {% icon 'cog' %}
          </button>
          <div class="dropdown-menu" aria-labelledby="id_extra_actions_button">
            {% if has_diagnostics %}
              {% include "diagnostics_button.html" with app_id=app_id enabled=is_enabled %}
            {% endif %}
            {% if has_logs %}
              <a class="dropdown-item view-logs-item"
                 href="{% url 'logs' app_id=app_id %}"
                 title="{% trans "View Logs" %}">
                {% trans "View Logs" %}
              </a>
            {% endif %}
            {% if has_backup_restore %}
              <a class="dropdown-item backup-item"
                 href="{% url 'backups:create' app_id=app_id %}"
                 title="{% trans "Backup" %}">
                {% trans "Backup" %}
              </a>
              <a class="dropdown-item restore-item"
                 href="{% url 'backups:index' %}"
                 title="{% trans "Restore" %}">
                {% trans "Restore" %}
              </a>
            {% endif %}
            {% if show_rerun_setup %}
              <form class="form form-rerun-setup-button" method="post"
                    action="{% url 'rerun-setup' app_id=app_id %}">
                {% csrf_token %}
                <input type="submit" class="dropdown-item no-running-status"
                       name="rerun-setup" value="{% trans "Re-run setup" %}"/>
              </form>
            {% endif %}
            {% if show_uninstall %}
              <a class="dropdown-item uninstall-item"
                 href="{% url 'uninstall' app_id=app_id %}"
                 title="{% trans "Uninstall" %}">
                {% trans "Uninstall" %}
              </a>
            {% endif %}
          </div>
        </div>
      {% endif %}

    </div>
    <div class="toolbar-collapsed-content">
      {% include "clients.html" with clients=app_info.clients enabled=is_enabled %}
    </div>
  </section>

{% endblock toolbar %}
