{#
 * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
 <info@champs-libres.coop> / <http://www.champs-libres.coop>
 *
 * This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
#}

<li class="nav-item dropdown btn btn-primary nav-user">
    <a id="menu-user"
        class="nav-link dropdown-toggle"
        type="button"
        data-bs-toggle="dropdown"
        aria-haspopup="true"
        aria-expanded="false">

        {{ 'Welcome' | trans }}<br/>

        {% if app.user %}
            <b>
                {{ app.user.username }}
                {{ render(controller('Chill\\MainBundle\\Controller\\UIController::showNotificationUserCounterAction')) }}
            </b>
        {% endif %}
        {% if is_granted('IS_IMPERSONATOR') %}
            <i class="fa fa-wrench fa-lg" title="Impersonate mode"></i>
        {% endif %}

    </a>
    <div class="dropdown-menu dropdown-menu-end dropdown-menu-dark" aria-labelledby="menu-user">

        {% for menu in menus %}
            {% if is_granted('IS_IMPERSONATOR') and menu.name == 'Logout' %}
            <a class="dropdown-item list-group-item bg-dark text-white"
                href="{{ path('chill_crud_admin_user_index', {'_switch_user': '_exit'}) }}">
                {{ 'Exit impersonation'|trans }}
            </a>
            {% else %}
            <a class="dropdown-item list-group-item bg-dark text-white"
                href="{{ menu.uri }}">{{ menu.label|trans }}
                {% if menu.extras.icon is defined %}
                    <i class="fa fa-{{ menu.extras.icon }} fa-lg"></i>
                {% endif %}
            </a>
            {% endif %}
        {% endfor %}

    </div>
</li>
