<!--
SPDX-FileCopyrightText: 2018-present Tobias Kunze
SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms
-->

{% extends "orga/base.html" %}

{% load i18n %}
{% load rich_text %}
{% load static %}

{% block scripts %}
    <script defer src="{% static "common/js/ui/tabs.js" %}"></script>
{% endblock scripts %}

{% block stylesheets %}
    <link rel="stylesheet" href="{% static "common/css/ui/tabs.css" %}" />
    <link rel="stylesheet" href="{% static "orga/css/ui/plugins.css" %}" />
{% endblock stylesheets %}

{% block extra_title %}{% translate "Plugins" %} :: {% endblock extra_title %}
{% block content %}
    <h2>{% translate "Plugins" %}</h2>

    {% if grouped_plugins %}
        {% include "orga/includes/tablist.html" %}
        <form method="post" class="form-horizontal">
            {% csrf_token %}
            {% for category, plugins in grouped_plugins.items %}
                <section role="tabpanel" id="tabpanel-{{ category.0 }}" aria-labelledby="tab-{{ category.0 }}" tabindex="0" aria-hidden="false">
                    <div class="form-plugins">

                        {% for plugin in plugins %}
                            <div class="card plugin-card">
                                <div class="card-header">
                                    {{ plugin.name }}
                                    {% if plugin.module in plugins_active %}
                                        <button class="btn btn-outline-danger btn-block" name="plugin:{{ plugin.module }}" value="disable">{% translate "Disable" %}</button>
                                    {% else %}
                                        <button class="btn btn-success btn-block" name="plugin:{{ plugin.module }}" value="enable">{% translate "Enable" %}</button>
                                    {% endif %}
                                </div>
                                <ul class="list-group list-group-flush">
                                    <li class="list-group-item">
                                        {% if plugin.author %}
                                            <p class="meta">
                                                {% blocktranslate trimmed with v=plugin.version a=plugin.author %}
                                                    Version {{ v }} by <em>{{ a }}</em>
                                                {% endblocktranslate %}
                                            </p>
                                        {% else %}
                                            <p class="meta">
                                                {% blocktranslate trimmed with v=plugin.version a=plugin.author %}
                                                    Version {{ v }}
                                                {% endblocktranslate %}
                                            </p>
                                        {% endif %}
                                        {{ plugin.description|rich_text }}
                                    </li>
                                </ul>
                            </div>
                        {% endfor %}
                    </div>
                </section>
            {% endfor %}
        </form>
    {% else %}
        <div class="alert alert-info">
            {% translate "This instance does currently not have any plugins installed." %}
        </div>
    {% endif %}
{% endblock content %}
