{% load branding i18n %}
{% load context_selection %}

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
        <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="{% site_branding_link %}">
        <img class="openstack-logo" src="{{ STATIC_URL }}dashboard/img/logo.png" alt="{% site_branding %}">
      </a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="navbar-collapse">
      <ul class="nav navbar-nav">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
            {% show_overview %}
            <span class="fa fa-caret-down"></span>
          </a>
          <ul class="dropdown-menu context-selection">

           {% comment %}
             is_multidomain is only available through an assignment tag pulled in through context_selection
           {% endcomment %}
           {% is_multidomain as domain_supported %}
           {% if domain_supported %}
            <li>
              {% show_domain_list %}
            </li>
           {% endif %}
            <li>
              {% show_project_list %}
            </li>

           {% comment %}
             is_multi_region is only available through an assignment tag pulled in through context_selection
           {% endcomment %}
           {% is_multi_region as multi_region %}
           {% if multi_region %}
            <li>
              {% show_region_list %}
            </li>
           {% endif %}
          </ul>
        </li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
            <span class="fa fa-user"></span>
            {{ request.user.username }}
            <span class="fa fa-caret-down"></span>
          </a>
          <ul id="editor_list" class="dropdown-menu dropdown-menu-right">
            <li>
              <a href="{% url 'horizon:settings:user:index' %}">
                <span class="fa fa-cog"></span>
                {% trans "Settings" %}
              </a>
            </li>
            {% if HORIZON_CONFIG.bug_url %}
              <li>
                <a href="{{ HORIZON_CONFIG.bug_url }}" target="_blank">
                  <span class="fa fa-bug"></span>
                  {% trans "Report Bug" %}
                </a>
              </li>
            {% endif %}
            {% if HORIZON_CONFIG.help_url %}
              <li>
                <a href="{{ HORIZON_CONFIG.help_url }}" target="_blank">
                  <span class="fa fa-question-circle"></span>
                  {% trans "Help" %}
                </a>
              </li>
            {% endif %}
            <li class="divider"></li>
            <li>
              <a href="{% url 'logout' %}">
                <span class="fa fa-sign-out"></span>
                {% trans "Sign Out" %}
              </a>
            </li>
          </ul>
        </li>
        <li class="dropdown">
          {% include "horizon/common/_region_selector.html" %}
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
