{% extends 'layout/dialog_base.html' if request.is_xhr else 'layout/admin_page.html' %}

{% from 'forms/_form.html' import form_header, form_rows, form_footer, form_fieldset %}

{% block title %}{{ plugin.title }}{% endblock %}

{% block subtitle %}
    {%- if not form -%}
        {% trans %}Plugin Details{% endtrans %}
    {%- else -%}
        {% trans %}Plugin Settings{% endtrans %}
    {%- endif -%}
{% endblock %}

{% block description %}{{ plugin.description }}{% endblock %}

{% block content %}
    {% if not form %}
        {% trans %}This plugin does not have any settings.{% endtrans %}
    {% else %}
        {{ form_header(form) }}
        {% if form._fieldsets %}
            {% for legend, fields in form._fieldsets %}
                {% call form_fieldset(legend) %}
                    {{ form_rows(form, fields=fields) }}
                {% endcall %}
            {% endfor %}
        {% else %}
            {{ form_rows(form, widget_attrs=plugin.settings_form_field_opts) }}
        {% endif %}
        {% call form_footer(form) %}
            <input class="i-button big highlight" type="submit" value="{% trans %}Save{% endtrans %}">
            <a href="{{ back_url }}" class="i-button big" data-button-back>{% trans %}Cancel{% endtrans %}</a>
        {% endcall %}
    {% endif %}

    {{ template_hook('plugin-details', plugin=plugin) }}
{% endblock %}
