{% load i18n %}
{% load firstof from future %}

{% comment %}
Partial: App-wide header element
{% endcomment %}

<header class="navbar navbar-default" role="banner" aria-label="main" id="nav">
  <div class="grid-container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav">
        <span class="sr-only">{% trans 'Toggle navigation' %}</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>

      {% include 'brand.html' with class_prefix='navbar' %}
      {% if course_id %}
      <ul class="nav navbar-nav">
        <li>
          <a href="{% url 'courses:home' course_id=course_id %}" class="navbar-link active-course-name">{% firstof course_name course_id %}</a>
        </li>
      </ul>
      {% endif %}
    </div>

    <div class="collapse navbar-collapse" id="main-nav">
      <ul class="nav navbar-nav navbar-right">
        {% if help_url %}
          <li>
            <a id="help" class="navbar-link " data-track-type="click" data-track-event="edx.bi.help.clicked"
               href="{{ help_url }}" target="_blank">{% trans "Help" %}</a>
          </li>
        {% endif %}
        <li class="dropdown">
          <button class="dropdown-toggle active-user navbar-link" data-toggle="dropdown"
             aria-controls="userDropdownMenu" id="userMenu">
            <span class="sr-only">{% trans "Menu for" %}</span>
            <span class="ico-user fa fa-graduation-cap" aria-hidden="true"></span>
            <span class="active-user-name">{{ request.user.username }}</span>
            <span class="ico ico-indicator fa fa-caret-down" aria-hidden="true"></span>
          </button>

          <ul id="userDropdownMenu" class="dropdown-menu active-user-nav" tabindex="-1"
              aria-labelledby="userMenu">
            <li>
              <a class="active-user-nav-logout" href="{% url 'logout' %}">{% trans "Logout" %}</a>
            </li>
          </ul>
        </li>
      </ul>
    </div>
    <!-- / navbar-collapse -->
  </div>
  <!-- / container -->
</header>
<!-- / navbar -->
