{% extends "web/_base_debusine.html" %}
{% load static %}
{% load debusine %}
{# Disable the "Debusine" string next to the homepage icon #}
{% block navbar_brand_name %}{% endblock %}
{# Implement a navigation bar with scope / workspace / etc. #}
{% block navbar_left %}
    {% if workspace %}
        {% ui workspace as workspaceui %}
        {% if other_workspaces %}
            <li class="nav-item dropdown" id="nav-workspaces">
                <div class="btn-group">
                    {{ workspaceui.place.as_nav }}
                    <a class="nav-link btn btn-debusine dropdown-toggle dropdown-toggle-split"
                       href="#"
                       role="button"
                       data-bs-toggle="dropdown"
                       aria-expanded="false">
                        <span class="visually-hidden">Toggle Dropdown</span>
                    </a>
                    <ul class="dropdown-menu">
                        {% for other_workspace in other_workspaces %}
                            <li>
                                <a class="dropdown-item" href="{{ other_workspace.get_absolute_url }}">{{ other_workspace.name }}</a>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            </li>
        {% else %}
            <li class="nav-item" id="nav-workspaces">
                <a class="nav-link btn btn-debusine"
                   href="{{ workspace.get_absolute_url }}">
                    <span class="bi {% icon "workspace" %}"></span> {{ workspace.name }}</a>
            </li>
        {% endif %}
        <li class="nav-item" id="nav-workflows">
            {% if workflow_templates %}
                <div class="btn-group">
                    <a class="nav-link btn btn-debusine"
                       href="{% url "workspaces:workflows:list" wname=workspace.name %}"><span class="bi {% icon "workflow" %}"></span> Workflows</a>
                    <a class="nav-link btn btn-debusine dropdown-toggle dropdown-toggle-split"
                       href="#"
                       role="button"
                       data-bs-toggle="dropdown"
                       aria-expanded="false">
                        <span class="visually-hidden">Toggle Dropdown</span>
                    </a>
                    <ul class="dropdown-menu">
                        {% for workflow_template in workflow_templates %}
                            <li>
                                <a class="dropdown-item"
                                   href="{% url "workspaces:workflows:list" wname=workspace.name %}?filter-workflow_templates={{ workflow_template.name }}">{{ workflow_template.name }}</a>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
            {% else %}
                <a class="nav-link btn btn-debusine"
                   href="{% url "workspaces:workflows:list" wname=workspace.name %}"><span class="bi {% icon "workflow" %}"></span> Workflows</a>
            {% endif %}
        </li>
        <li class="nav-item dropdown" id="nav-collections">
            <div class="btn-group">
                <a class="nav-link btn btn-debusine"
                   href="{% url "workspaces:collections:list" wname=workspace.name %}"><span class="bi {% icon "collections" %}"></span> Collections</a>
                <a class="nav-link btn btn-debusine dropdown-toggle dropdown-toggle-split"
                   href="#"
                   role="button"
                   data-bs-toggle="dropdown"
                   aria-expanded="false">
                    <span class="visually-hidden">Toggle Dropdown</span>
                </a>
                <ul class="dropdown-menu">
                    {% for collection in workspace_collections %}
                        <li>
                            <a class="dropdown-item" href="{{ collection.get_absolute_url }}">{{ collection }}</a>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-debusine dropdown-toggle"
               href="#"
               id="navbar-plumbing-actions"
               role="button"
               data-bs-toggle="dropdown"
               aria-expanded="false">Plumbing</a>
            <ul class="dropdown-menu">
                <li>
                    <a class="dropdown-item"
                       href="{% url "workspaces:work-requests:list" wname=workspace.name %}">Work requests</a>
                </li>
                <li>
                    <a id="nav-task-configuration-inspector"
                       class="dropdown-item"
                       href="{% url "workspaces:task_configuration_inspector" wname=workspace.name %}">Task configuration inspector</a>
                </li>
            </ul>
        </li>
    {% endif %}
{% endblock %}
