## mako
<%page expression_filter="h"/>
<%namespace name='static' file='static_content.html'/>

## This template should not use the target student's details when masquerading, see TNL-4895
<%
self.real_user = getattr(user, 'real_user', user)
%>

<%!
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from openedx.core.djangoapps.user_api.accounts.image_helpers import get_profile_image_urls_for_user
%>
% if uses_bootstrap:
    <li class="nav-item nav-item-hidden-collapsed">
        <a href="${reverse('dashboard')}" class="menu-title">
            <span class="sr-only">${_("Dashboard for:")}</span>
            <% profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium'] %>
            <img class="user-image-frame" src="${profile_image_url}" alt="">
        </a>
    </li>
    <li class="nav-item dropdown mt-2 nav-item-hidden-collapsed">
        <% username = self.real_user.username %>
        <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">${username}</a>
        <ul class="dropdown-menu dropdown-menu-right" id="${_("Usermenu")}" aria-labelledby="dropdownMenuLink" tabindex="-1">
            <a class="dropdown-item" href="${reverse('dashboard')}">${_("Dashboard")}</a>
            <a class="dropdown-item" href="${reverse('account_settings')}">${_("Account")}</a>
            <a class="dropdown-item" href="${reverse('logout')}">${_("Sign Out")}</a>
        </ul>
    </li>
    <li class="nav-item nav-item-open-collapsed-only collapse"><a href="${reverse('dashboard')}">${_("Dashboard")}</a></li>
    <li class="nav-item nav-item-open-collapsed-only"><a href="${reverse('account_settings')}">${_("Account")}</a></li>
    <li class="nav-item nav-item-open-collapsed-only"><a href="${reverse('logout')}">${_("Sign Out")}</a></li>
% elif uses_pattern_library:
    <div class="wrapper-user-menu dropdown-menu-container logged-in js-header-user-menu">
        <a href="${reverse('dashboard')}" class="menu-title">
            <span class="sr-only">${_("Dashboard for:")}</span>
            <%
            username = self.real_user.username
            profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium']
            %>
            <img class="menu-image" src="${profile_image_url}" alt="">
            ${username}
        </a>
        <div role="group" aria-label="User menu" class="user-menu">
            <button type="button" class="menu-button button-more has-dropdown js-dropdown-button" aria-expanded="false" aria-controls="${_("Usermenu")}">
                  <span class="icon fa fa-caret-down" aria-hidden="true"></span>
                  <span class="sr-only">${_("Usermenu dropdown")}</span>
            </button>
            <ul class="dropdown-menu list-divided is-hidden" id="${_("Usermenu")}" tabindex="-1">
                <%block name="navigation_dropdown_menu_links" >
                    <li class="dropdown-item item has-block-link"><a href="${reverse('dashboard')}" role="menuitem" class="action dropdown-menuitem">${_("Dashboard")}</a></li>
                    <li class="dropdown-item item has-block-link"><a href="${reverse('account_settings')}" role="menuitem" class="action dropdown-menuitem">${_("Account")}</a></li>
                </%block>
                <li class="dropdown-item item has-block-link"><a href="${reverse('logout')}" role="menuitem" class="action dropdown-menuitem">${_("Sign Out")}</a></li>
            </ul>
        </div>
    </div>
% else:
    <ol class="user">
        <li class="primary">
            <a href="${reverse('dashboard')}" class="user-link">
                <span class="sr">${_("Dashboard for:")}</span>
                <%
                username = self.real_user.username
                profile_image_url = get_profile_image_urls_for_user(self.real_user)['medium']
                %>
                <img class="user-image-frame" src="${profile_image_url}" alt="">
                <div class="label-username">${username}</div>
            </a>
        </li>
        <li class="primary">
            <div class="user-menu">
                <button class="user-dropdown" aria-expanded="false" aria-haspopup="true">
                    <span class="sr">${_("More options")}</span>
                    <span class="fa fa-sort-desc" aria-hidden="true"></span>
                </button>
                <ul class="user-dropdown-menu" aria-label="More Options" role="menu">
                    ${navigation_dropdown_menu_links()}
                    <li class="item"><a href="${reverse('logout')}" role="menuitem" class="user-dropdown-menuitem">${_("Sign Out")}</a></li>
                </ul>
            </div>
        </li>
    </ol>
% endif
