{% load i18n %}
{% load static %}
{% load tz %}

    <!-- PatternFly Horizontal Nav -->
    <nav class="navbar navbar-default navbar-pf" role="navigation" id="navbar" data-defaultpagesize="{{ SETTINGS.DEFAULT_PAGE_SIZE }}">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-1">
                <span class="sr-only">{% trans "Toggle navigation" %}</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/" target="_parent">
                <img src="{% static 'images/kiwi_h20.png' %}" alt="Kiwi TCMS" />
            </a>
        </div>
        <div class="collapse navbar-collapse navbar-collapse-1">
            <ul class="nav navbar-nav navbar-utility">

                <li class="dropdown" style="float:right">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <span class="pficon pficon-user"></span>
                        {% if user.is_authenticated %}{{ user }}{% else %}{% trans "Welcome Guest" %}{% endif %}
                        <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                    {% if user.is_authenticated %}
                        <li>
                            <a href="{% url "testruns-search" %}?default_tester={{ user.username }}" target="_parent">{% trans "My Test Runs" %}</a>
                        </li>

                        <li>
                            <a href="{% url "plans-search" %}?author__username__startswith={{ user.username }}" target="_parent">{% trans "My Test Plans" %}</a>
                        </li>

                        <li class="divider"></li>

                        <li>
                            <a href="{% url "tcms-profile" user.username %}" target="_parent">{% trans "My profile" %}</a>
                        </li>

                        <li>
                            <a href="{% url "admin:password_change" %}" target="_parent">{% trans "Change password" %}</a>
                        </li>

                        <li class="divider"></li>

                        <li>
                            <a href="{% url "tcms-logout" %}" target="_parent">{% trans "Logout" %}</a>
                        </li>
                    {% else %}
                        <li>
                            <a href="{% url "tcms-login" %}" target="_parent">{% trans "Login" %}</a>
                        </li>

                        <li class="divider"></li>

                        <li>
                            <a href="{% url "tcms-register" %}" target="_parent">{% trans "Register" %}</a>
                        </li>
                    {% endif %}
                    </ul>
                </li>

                <li class="dropdown" style="float:right">
                    <a class="nav-item-iconic" id="horizontalDropdownMenuHelp" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                        <span title="{% trans 'Help' %}" class="fa pficon-help"></span>
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="horizontalDropdownMenuHelp">
                        {% for link in SETTINGS.HELP_MENU_ITEMS %}
                        <li><a href="{{ link.0 }}" target="_parent">{{ link.1 }}</a></li>
                        {% endfor %}
                        <li class="divider"></li>
                        <li><a target="_parent" href="https://github.com/kiwitcms/Kiwi/blob/master/CHANGELOG.rst#change-log">Version {{ SETTINGS.KIWI_VERSION }}</a></li>
                    </ul>
                </li>


                <li class="dropdown" style="float:right">
                    <a class="nav-item-iconic" id="horizontalDropdownMenuLang" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                        <span title="{% trans 'Language' %}" class="fa fa-globe"></span>
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="horizontalDropdownMenuLang">
                        <li><a target="_parent" href="https://crowdin.com/project/kiwitcms">{% trans "Supported languages" %}</a></li>
                        <li><a target="_parent" href="https://github.com/kiwitcms/Kiwi/issues/new?title=Request+new+language:+...&body=Please+enable+...+language+in+Crowdin">{% trans "Request new language" %}</a></li>

                        <li class="divider"></li>
                        {% get_current_language as LANGUAGE_CODE %}
                        <li>
                            <a target="_parent" href="{% url 'translation-mode' %}?next={{ request.path }}{% if LANGUAGE_CODE != 'eo' %}&language=eo{% endif %}">
                                {% trans "Translation mode" %}
                                <span class="fa {% if LANGUAGE_CODE != 'eo' %}fa-toggle-on{% else %}fa-toggle-off{% endif %}"></span>
                            </a>
                        </li>
                        <li><a target="_parent" href="https://kiwitcms.readthedocs.io/en/latest/contribution.html#translation">{% trans "Translation guide" %}</a></li>
                    </ul>
                </li>

                <li style="float:right">
                    <a>
                        <span class="fa fa-clock-o">
                            {% get_current_timezone as TIME_ZONE %}
                            {{ SERVER_TIME }} {{ TIME_ZONE }}
                        </span>
                    </a>
                </li>
            </ul>

            <ul class="nav navbar-nav navbar-primary">
                {% include "menu_items.html" with menu_items=SETTINGS.MENU_ITEMS %}
            </ul>
        </div>
    </nav>
