{% extends "master.html" %}
{% block website %}{{_("openSUSE Accounts")}}{% endblock %}

{% set OPENID = 'https://www.opensuse.org/openid/user/%s' %}

{% block head %}
    <link href="{{ url_for('theme.static', filename='css/chameleon.nodata.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ url_for('theme.static', filename='css/accounts.css') }}" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" type="image/x-icon" href="{{ url_for('theme.static', filename='images/favicons/favicon.ico') }}">
    <link color="#73ba25" href="{{ url_for('theme.static', filename='images/favicons/mask-icon.svg') }}" rel="mask-icon">
{% endblock %}

{% block navbar %}
    <nav class="navbar navbar-expand-md navbar-light bg-light noprint">
        <a class="navbar-brand" href="{{ url_for('root.root') }}/">
             <img src="{{ url_for('theme.static', filename='images/logo/logo-white.svg') }}" class="mr-2" alt="openSUSE">
            <span>{{_("Accounts")}}</span>
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#site-menu">
            <span class="navbar-toggler-icon"></span>
	</button>
        {% if current_user %}
        <div class="collapse navbar-collapse" id="site-menu">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link color-white" href="{{ url_for('.groups') }}">{{_("Groups")}}</a>
                </li>
            </ul>
            <form class="ml-auto"><input id="search" type="search" class="typeahead form-control" autocomplete="off" placeholder="{{_('Search...')}}"></form>
            <ul class="navbar-nav">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <img src="{{ gravatar(current_user.mail if current_user.mail else 'default', 30) }}" class="rounded"/>
                        <span>{{ current_user.username }}</span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
                        <a class="dropdown-item" href="{{ url_for('.user', username=current_user.username) }}">{{_("Profile")}}</a>
                        <a class="dropdown-item" href="{{ url_for('.logout') }}">{{_("Log Out")}}</a>
                    </div>
                </li>
            </ul>
        </div>
        {% else %}
        <div class="mx-auto"></div>
        {% endif %}
    </nav>
    {% with flashes = get_flashed_messages(with_categories=True) %}
        {% if flashes %}
        <div class="container flash-messages fixed-top mt-5">
            {% for category, flash in flashes %}
            <div class="alert alert-{{ category }} alert-dismissible fade show">
                {{ flash }}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            {% endfor %}
        </div>
        {% endif %}
    {% endwith %}
{% endblock %}

{% block bodycontent %}
    <div class="mb-auto">
        {% block content %}{% endblock %}
    </div>
{% endblock %}

{% block footer %}
    <footer class="footer global-footer">
        <div class="container text-center">
            {% set noggin_link %}
                <a href="https://github.com/fedora-infra/noggin">noggin</a>
            {% endset %}
            <div><small>{{_("Powered by %(noggin_link)s", noggin_link=noggin_link)}}</small></div>
            <div>{{ ipa.ipa_version|default('') }}</div>
        </div>
    </footer>
{% endblock %}

{% block scripts %}
    <script nonce="{{ csp_nonce() }}" src="{{ url_for('theme.static', filename='js/jquery/jquery-3.3.1.min.js') }}"></script>
    <script nonce="{{ csp_nonce() }}" defer src="{{ url_for('theme.static', filename='js/chameleon.js') }}"></script>
    {{ super() }}
{% endblock %}

{% macro userlinks() %}
    <li class="list-group-item d-flex justify-content-between align-items-center">
      <strong>{{_("Connect")}}</strong>
      <a href="https://connect.opensuse.org/pg/profile/{{ user.username }}">{{ user.username }}</a>
    </li>
{% endblock %}

{% macro front_page_blurb() %}
<h2 class="display-4">{{_("Welcome to noggin!")}}</h2>
<p class="lead">
    {{_("This is the open source, community self-service portal for FreeIPA. It allows you to do things like create an account, change your password, manage group membership, and more.")}}
</p>
{% endmacro %}

{# an optional macro defining an element to show for editing group details #}
{# typically, it used to link to a ticket tracker for an admin to edit a group #}
{% macro edit_group_details() %}
    {% if current_user_is_sponsor and sponsor_form %}
        <div class="col">
            <a class="btn btn-primary" href="https://progress.opensuse.org/projects/opensuse-admin/issues/new" title="{{_('file an openSUSE Admin ticket to change the details or sponsors of this group')}}">
               {{_("Request Change of Details")}}
            </a>
        </div>
    {% endif %}
{% endmacro %}

{# an optional macro defining an element to show for account disable #}
{# typically, it used to link to a ticket tracker for an admin to perform the disable #}
{% macro request_disable_account() %}
    <div class="col">
        <a class="btn btn-danger" href="https://progress.opensuse.org/projects/opensuse-admin/issues/new" title="{{_('Create a PDR request to disable your account')}}">
            {{_("Request account deletion")}}
        </a>
    </div>
{% endmacro %}
