{# NOTE: Expected to be nested under an <ul> element #}
{% load rules %}
{% load projectroles_tags %}
{% load projectroles_common_tags %}
{% get_django_setting 'PROJECTROLES_KIOSK_MODE' as kiosk_mode %}

{# Responsive replacement for user dropdown #}
{% get_user_links request as dropdown_links %}
{% for link in dropdown_links %}
  <li class="nav-item sodar-navbar-alt-item {% if link.active %}active{% endif %}">
    <a class="nav-link {% if link.name == 'sign-out' %}text-danger{% endif %}
              {% if link.name == 'sign-in' %}text-white{% endif %}"
       href="{{ link.url }}"
       id="sodar-navbar-nav-link-{{ link.name }}">
      <i class="iconify" data-icon="{{ link.icon }}"></i> {{ link.label }}
    </a>
{% endfor %}
{# Actual user dropdown #}

<li class="nav-item sodar-navbar-user-dropdown">
  <a class="nav-link sodar-nav-link-last dropdown-toggle"
     id="sodar-navbar-user-dropdown"
     data-toggle="dropdown">
    {% if request.user.is_superuser %}
      <i class="iconify" data-icon="mdi:shield-account"></i>
    {% elif request.user.is_authenticated %}
      <i class="iconify" data-icon="mdi:user"></i>
    {% else %}
      <i class="iconify" data-icon="mdi:incognito"></i>
    {% endif %}
  </a>
  <div class="dropdown-menu dropdown-menu-right sodar-navbar-user-dropdown">
    <div class="dropdown-header" id="sodar-navbar-user-legend">
      {% if request.user.is_authenticated %}
        {% if request.user.name %}
          {{ request.user.name }}<br />
        {% endif %}
        {{ request.user.username }}
      {% else %}
        Anonymous
      {% endif %}
    </div>
    <div class="dropdown-divider"></div>

    {% get_user_links request as dropdown_links %}
    {% for link in dropdown_links %}
      {% if link.name == 'admin' or link.name == 'sign-out' or link.name == 'sign-in' %}
        <div class="dropdown-divider"></div>
      {% endif %}
      <a class="dropdown-item {% if link.active %}active{% endif %}
                {% if link.name == 'sign-out' %}text-danger{% endif %}
                {% if link.name == 'sign-in' %}text-primary{% endif %}"
         {% if link.url %}href="{{ link.url }}"{% endif %}
         id="sodar-navbar-link-{{ link.name }}">
        <i class="iconify" data-icon="{{ link.icon }}"></i> {{ link.label }}
      </a>
    {% endfor %}
  </div>
</li>
