{# -*- coding: utf-8 -*-

  This file is part of Invenio.
  Copyright (C) 2015-2018 CERN.

  Invenio is free software; you can redistribute it and/or modify it
  under the terms of the MIT License; see LICENSE file for more details.
#}
{%- if config.ACCOUNTS %}
  {%- if not current_user.is_authenticated %}
    <form>
      <a href="{{ url_for_security('login', next=request.path) }}"
         class="ui button">
        <i class="sign-in icon"></i>
        {{ _('Log in') }}</a>
      {% if security.registerable %}
        <a href="{{ url_for_security('register') }}" class="ui button orange">
          <i class="icons">
            <i class="edit outline icon"></i>
          </i> {{ _('Sign up') }}
        </a>{% endif %}
    </form>
  {%- else %}
    {%- if config.USERPROFILES %}

      <!-- <div class="ui simple pointing dropdown link item"> -->
      <div class="ui buttons">
        <a class="ui button"
           href="{{ url_for('invenio_userprofiles.profile') }}">
          <i class="user icon"></i> {{ current_user.email }}
        </a>

        <div class="ui dropdown icon button">
          <i class="dropdown icon"></i>
          <div class="menu">
            {%- for item in current_menu.submenu('settings').children if item.visible %}
              <div class="item"><a style="color:black;"
                                   href="{{ item.url }}">{{ item.text|safe }}</a>
              </div>
              <div class="divider"></div>
            {%- endfor %}
            <div class="item"><a style="color:black;"
                                 href="{{ url_for_security('logout') }}"><i
                    class="sign-out icon"></i>
              {{ _('Log out') }}</a></div>
          </div>
        </div>
      </div>

    {%- else %}
      <a href=" {{ url_for_security('logout') }}" class="ui button"><i
              class="sign-out icon"></i> {{ _('Log out') }}</a>
    {%- endif %}
  {%- endif %}
{%- endif %}
