{% extends "wagtailadmin/generic/edit.html" %}
{% load i18n wagtailadmin_tags %}

{% block before_form %}
    {% if site_switcher %}
        <form class="w-mb-8" method="get" id="settings-site-switch" novalidate>
            <label for="{{ site_switcher.site.id_for_label }}">
                {% trans "Site" %}:
            </label>
            {{ site_switcher.site }}
        </form>
    {% elif site_for_header %}
        <div class="w-mb-8">
            {% trans "Site" %}:
            {{ site_for_header.hostname }}
            {% if site_for_header.is_default_site %}[{% trans "default" %}]{% endif %}
        </div>
    {% endif %}
{% endblock %}

{% block form_content %}
    {% if panel %}
        {{ panel.render_form_content }}
    {% else %}
        {{ block.super }}
    {% endif %}

    {% if form.smtp_relay_host and form.smtp_password %}
        <section class="w-panel w-mt-8">
            <div class="w-panel__header">
                <h2 class="w-panel__heading">{% trans "Send test email (save settings before sending)." %}</h2>
            </div>
            <div class="w-panel__content">
                <ul class="fields">
                    <li>
                        <label class="w-block w-font-semibold w-mb-2" for="smtp_test_email">{% trans "Send email to" %}</label>
                        <input
                            class="w-input"
                            type="email"
                            id="smtp_test_email"
                            name="smtp_test_email"
                            value="{{ form.data.smtp_test_email|default:'' }}"
                            placeholder="name@example.com"
                        >
                        <p class="help">{% trans "This field is only for this test and will not be saved." %}</p>
                    </li>
                </ul>
                <button
                    type="submit"
                    class="button button-secondary"
                    formaction="{% url 'newsletter_smtp_test' %}"
                    formmethod="post"
                    formnovalidate
                >
                    {% trans "Send test email" %}
                </button>
            </div>
        </section>
    {% endif %}
{% endblock %}
