{# -*- 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.
#}

{%- extends config.OAUTHCLIENT_SETTINGS_TEMPLATE %}

{% from "invenio_oauthclient/_macros.html" import render_field, form_errors %}

{% set panel_title = _("Linked accounts") %}
{% set panel_icon = "fa fa-link" %}

{% block settings_body %}
<div class="panel-body">
    {% block oauth_body_text %}
    <p>{{ _('Tired of entering password for %(sitename)s every time you sign in? Set up single sign-on with one or more of the services below:',
            sitename=config.THEME_SITENAME) }}</p>
    {% endblock oauth_body_text %}
</div>
<ul class="list-group">
    {%- for s in services %}
    <li class="list-group-item">
      {% block oauth_controls scoped %}
      <div class="pull-right">
          {%- if s.account -%}
          <a href="{{url_for('invenio_oauthclient.disconnect', remote_app=s.appid)}}" class="btn btn-default btn-xs"><i class="fa fa-times-circle"></i> {{ _('Disconnect') }}</a>
          {%- else -%}
          <a href="{{url_for('invenio_oauthclient.login', remote_app=s.appid)}}" class="btn btn-default btn-xs"><i class="fa fa-link"></i> {{ _('Connect') }}</a>
          {%- endif -%}
      </div>
      {% endblock oauth_controls %}
      {% if s.icon %}<i class="{{s.icon}}"></i>{% endif %}
      {{s.title}}
      {% if s.account %}<i class="fa fa-check text-success"></i>{% endif %}
      <br/>
      <small class="text-muted">{{s.description}}</small>
    </li>
    {%- endfor %}
</ul>
{% endblock %}
