{% load static %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Debusine -
            {% block title %}{% endblock %}
        </title>
        <link rel="stylesheet" type="text/css" href="{% static "web/css/debusine.css" %}">
        <link rel="stylesheet" type="text/css" href="{% static "web/vendor/bootstrap/css/bootstrap.min.css" %}">
        <link rel="stylesheet" href="{% static "web/vendor/bootstrap/css/bootstrap-icons.min.css" %}">
    </head>
    <body>
        <nav class="navbar navbar-expand-lg bg-body-tertiary mb-3">
            <div class="container-fluid">
                <a class="navbar-brand" href="{% url 'homepage:homepage' %}">Debusine</a>
                <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 class="navbar-nav me-auto mb-2 mb-lg-0">
                        {% block navbar_left %}
                            <li class="nav-item">
                                <a class="nav-link"
                                   aria-current="page"
                                   href="{% url "workspaces:list" %}">Workspaces</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="{% url "work-requests:list" %}">Work requests</a>
                            </li>
                            {% if user.is_authenticated %}
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle"
                                       href="#"
                                       role="button"
                                       data-bs-toggle="dropdown"
                                       aria-expanded="false">Plumbing</a>
                                    <ul class="dropdown-menu">
                                        <li>
                                            <a class="dropdown-item" href="{% url "artifacts:create" %}">Create artifact</a>
                                        </li>
                                        <li>
                                            <a class="dropdown-item" href="{% url "work-requests:create" %}">Create work request</a>
                                        </li>
                                    </ul>
                                </li>
                            {% endif %}
                        {% endblock %}
                    </ul>
                    <ul class="navbar-nav mb-2 mb-lg-0">
                        {% if user.is_authenticated %}
                            <li class="nav-item dropdown">
                                <a class="nav-link dropdown-toggle"
                                   href="#"
                                   role="button"
                                   data-bs-toggle="dropdown"
                                   aria-expanded="false">{{ user.username }}</a>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a class="dropdown-item" href="{% url "user:token-list" %}">Tokens</a>
                                    </li>
                                    <li>
                                        <hr class="dropdown-divider">
                                    </li>
                                    <li>
                                        <a class="dropdown-item" href="{% url "accounts:logout" %}">Log out</a>
                                    </li>
                                </ul>
                            </li>
                        {% else %}
                            <li class="nav-item">
                                <a class="nav-link" href="{% url "accounts:login" %}">Log in</a>
                            </li>
                        {% endif %}
                    </ul>
                </div>
            </div>
        </nav>
        <div aria-live="polite"
             aria-atomic="true"
             class="position-relative"
             id="user-message-container">
            <div class="toast-container position-absolute top-0 end-0 p-3">
                {% with ERROR=DEFAULT_MESSAGE_LEVELS.ERROR %}
                    {% for message in messages %}
                        <div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
                            <div class="toast-header{% if message.level == ERROR %} bg-danger{% endif %}">
                                {% if message.level == ERROR %}
                                    <span class="bi bi-exclamation-circle"></span>
                                {% else %}
                                    <span class="bi bi-info-circle"></span>
                                {% endif %}
                                <strong class="me-auto">{{ message.level_tag }}</strong>
                                <button type="button"
                                        class="btn-close"
                                        data-bs-dismiss="toast"
                                        aria-label="Close"></button>
                            </div>
                            <div class="toast-body">{{ message }}</div>
                        </div>
                    {% endfor %}
                {% endwith %}
            </div>
        </div>
        <div class="container">
            {% block content %}{% endblock %}
        </div>
        <div class="container">
            <footer class="mt-3 border-top text-muted text-center">
                {% block footer %}
                    <p class="mt-2 mb-0">
                        © 2019-2024 <a href="https://salsa.debian.org/freexian-team/debusine/-/blob/devel/AUTHORS">Debusine Developers</a>
                    </p>
                    <p class="mt-0 mb-0">
                        <a href="https://freexian-team.pages.debian.net/debusine/"
                           target="_blank">Documentation</a> •
                        <a href="https://salsa.debian.org/freexian-team/debusine/-/issues"
                           target="_blank">Bugs</a> •
                        <a href="https://salsa.debian.org/freexian-team/debusine/"
                           target="_blank">Code</a> •
                        <a href="https://freexian-team.pages.debian.net/debusine/howtos/contribute.html"
                           target="_blank">Contributing</a>
                    </p>
                {% endblock %}
            </footer>
        </div>
        <div id="beta-stamp">BETA</div>
        <script src="{% static "web/vendor/bootstrap/js/bootstrap.bundle.min.js" %}"></script>
        <script>
            (function() {
            let toastElList = [].slice.call(document.querySelectorAll('.toast'));
            toastElList.map(function (toastEl) {
                let toast = new bootstrap.Toast(toastEl, {autohide:false});
                toast.show()
            })
            })()
        </script>
    </body>
</html>
