{% extends "web/_base.html" %}
{% load static %}
{% load debusine %}
{% block navbar %}
    <nav class="navbar navbar-expand-lg bg-body-tertiary">
        <div class="container-fluid">
            <ul id="navbar-homepage" class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a id="navbar-homepage-link"
                       class="navbar-brand btn"
                       href="{% url 'homepage:homepage' %}">
                        <img src="{% static 'web/icons/debusine.png' %}"
                             height="25"
                             alt="Homepage"
                             class="d-inline-block align-text-top">
                        {% block navbar_brand_name %}Debusine{% endblock %}
                    </a>
                </li>
            </ul>
            <button class="navbar-toggler"
                    type="button"
                    data-bs-toggle="collapse"
                    data-bs-target="#navbarSupportedContent"
                    aria-controls="navbarSupportedContent"
                    aria-expanded="false"
                    aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul id="navbar-left" class="navbar-nav me-auto mb-2 mb-lg-0">
                    {% block navbar_left %}{% endblock %}
                </ul>
                <ul id="navbar-right" class="navbar-nav mb-2 mb-lg-0">
                    {% if user.is_authenticated %}
                        <li class="nav-item dropdown">
                            <a class="nav-link btn btn-debusine dropdown-toggle"
                               href="#"
                               role="button"
                               data-bs-toggle="dropdown"
                               aria-expanded="false"><span class="bi {% icon "user" %}"></span> {{ user.username }}</a>
                            <ul class="dropdown-menu" id="navbar-user-actions">
                                <li>
                                    <a class="dropdown-item"
                                       href="{% url "user:detail" username=user.username %}">{{ user.get_full_name }}
                                        <br>
                                        <small class="ms-1">{{ user.username }}</small>
                                    </a>
                                </li>
                                <li>
                                    <a class="dropdown-item"
                                       href="{% url "user:token-list" username=user.username %}">Tokens</a>
                                </li>
                                <li>
                                    <a class="dropdown-item"
                                       href="{% url "user:groups" username=user.username %}">Groups</a>
                                </li>
                                <li>
                                    <hr class="dropdown-divider">
                                </li>
                                <li>
                                    <form id="logout-form"
                                          class="dropdown-item"
                                          method="post"
                                          action="{% url "logout" %}">
                                        {% csrf_token %}
                                        <button type="submit">Log out</button>
                                    </form>
                                </li>
                            </ul>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            {% if is_logout_view or is_login_view %}
                                <a class="nav-link btn btn-debusine" href="{% url "login" %}"><span class="bi {% icon 'user' %}"></span> Log in</a>
                            {% else %}
                                <a class="nav-link btn btn-debusine"
                                   href="{% url "login" %}?next={{ request.get_full_path }}"><span class="bi {% icon 'user' %}"></span> Log in</a>
                            {% endif %}
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>
{% endblock %}
</body>
</html>
