{% extends 'base.twig' %}

{% block content %}
<div id="mail-content" class="responsive-tabs">
  <ul class="nav nav-tabs" role="tablist">
    {% if mailcow_cc_role == 'admin' %}
    <li class="nav-item dropdown" role="presentation">
      <a class="nav-link dropdown-toggle active" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.domains }}</a>
      <ul class="dropdown-menu">
        <li><button class="dropdown-item" aria-selected="false" aria-controls="tab-domains" role="tab" data-bs-toggle="tab" data-bs-target="#tab-domains">{{ lang.mailbox.domains }}</button></li>
        <li><button class="dropdown-item" aria-selected="false" aria-controls="tab-templates-domains" role="tab" data-bs-toggle="tab" data-bs-target="#tab-templates-domains">{{ lang.mailbox.templates }}</button></li>
      </ul>
    </li>
    {% else %}
    <li class="nav-item" role="presentation"><button class="nav-link" aria-controls="tab-domains" role="tab" data-bs-toggle="tab" data-bs-target="#tab-domains">{{ lang.mailbox.domains }}</button></li>
    {% endif %}
    {% if mailcow_cc_role == 'admin' %}
    <li class="nav-item dropdown" role="presentation">
      <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.mailboxes }}</a>
      <ul class="dropdown-menu">
        <li><button class="dropdown-item" aria-selected="false" aria-controls="tab-mailboxes" role="tab" data-bs-toggle="tab" data-bs-target="#tab-mailboxes">{{ lang.mailbox.mailboxes }}</button></li>
        <li><button class="dropdown-item" aria-selected="false" aria-controls="tab-templates-mbox" role="tab" data-bs-toggle="tab" data-bs-target="#tab-templates-mbox">{{ lang.mailbox.templates }}</button></li>
      </ul>
    </li>
    {% else %}
    <li class="nav-item" role="presentation"><button class="nav-link" aria-controls="tab-mailboxes" role="tab" data-bs-toggle="tab" data-bs-target="#tab-mailboxes">{{ lang.mailbox.mailboxes }}</button></li>
    {% endif %}
    <li class="nav-item" role="presentation"><button class="nav-link" aria-controls="tab-resources" role="tab" data-bs-toggle="tab" data-bs-target="#tab-resources">{{ lang.mailbox.resources }}</button></li>
    <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#">{{ lang.mailbox.aliases }}</a>
      <ul class="dropdown-menu">
        <li role="presentation"><button class="dropdown-item" aria-selected="false" aria-controls="tab-mbox-aliases" role="tab" data-bs-toggle="tab" data-bs-target="#tab-mbox-aliases">{{ lang.mailbox.aliases }}</button></li>
        <li role="presentation"><button class="dropdown-item" aria-selected="false" aria-controls="tab-domain-aliases" role="tab" data-bs-toggle="tab" data-bs-target="#tab-domain-aliases">{{ lang.mailbox.domain_aliases }}</button></li>
      </ul>
    </li>
    <li class="nav-item" role="presentation"><button class="nav-link" aria-selected="false" aria-controls="tab-syncjobs" role="tab" data-bs-toggle="tab" data-bs-target="#tab-syncjobs">{{ lang.mailbox.sync_jobs }}</button></li>
    <li class="nav-item" role="presentation"><button class="nav-link" aria-selected="false" aria-controls="tab-filters" role="tab" data-bs-toggle="tab" data-bs-target="#tab-filters">{{ lang.mailbox.filters }}</button></li>
    <li class="nav-item" role="presentation"><button class="nav-link" aria-selected="false" aria-controls="tab-bcc" role="tab" data-bs-toggle="tab" data-bs-target="#tab-bcc">{{ lang.mailbox.address_rewriting }}</button></li>
    <li class="nav-item" role="presentation"{% if mailcow_cc_role != 'admin' %} class="d-none"{% endif %}><button class="nav-link" aria-selected="false" aria-controls="tab-tls-policy" role="tab" data-bs-toggle="tab" data-bs-target="#tab-tls-policy">{{ lang.mailbox.tls_policy_maps }}</button></li>
  </ul>

  <div class="row">
    <div class="col-md-12">
      <div class="tab-content" style="padding-top:20px">
        {% include 'mailbox/tab-domains.twig' %}
        {% if mailcow_cc_role == 'admin' %}
        {% include 'mailbox/tab-templates-domains.twig' %}
        {% endif %}
        {% include 'mailbox/tab-mailboxes.twig' %}
        {% if mailcow_cc_role == 'admin' %}
        {% include 'mailbox/tab-templates-mbox.twig' %}
        {% endif %}
        {% include 'mailbox/tab-resources.twig' %}
        {% include 'mailbox/tab-domain-aliases.twig' %}
        {% include 'mailbox/tab-mbox-aliases.twig' %}
        {% include 'mailbox/tab-syncjobs.twig' %}
        {% include 'mailbox/tab-filters.twig' %}
        {% include 'mailbox/tab-bcc.twig' %}
        {% include 'mailbox/tab-tls-policy.twig' %}
      </div> <!-- /tab-content -->
    </div> <!-- /col-md-12 -->
  </div> <!-- /row -->
</div>

{% include 'modals/mailbox.twig' %}

<script type='text/javascript'>
  var acl = '{{ acl_json|raw }}';
  var lang = {{ lang_mailbox|raw }};
  var lang_rl = {{ lang_rl|raw }};
  var lang_edit = {{ lang_edit|raw }};
  var lang_datatables = {{ lang_datatables|raw }};
  var csrf_token = '{{ csrf_token }}';
  var pagination_size = Math.trunc('{{ pagination_size }}');
  var role = '{{ role }}';
  var is_dual = {{ is_dual }};
  var ALLOW_ADMIN_EMAIL_LOGIN = {{ allow_admin_email_login }};
</script>
{% endblock %}
