{% extends '../layout-growi/base/layout.html' %}


{% block html_title %}{{ customTitle(t('API Settings')) }}{% endblock %}


{% block content_header %}
<div class="header-wrap">
  <header id="page-header">
  <h1 id="admin-title" class="title">{{ t('API Settings') }}</h1>
  </header>
</div>
{% endblock %}

{% block content_main %}
<div class="content-main">

  <ul class="nav nav-tabs">
    <li><a href="/me"><i class="icon-user"></i> {{ t('User Information') }}</a></li>
    {% if isEnabledPassport() %}
    <li><a href="/me/external-accounts"><i class="icon-share-alt"></i> {{ t('External Accounts') }}</a></li>
    {% endif %}
    <li><a href="/me/password"><i class="icon-lock"></i> {{ t('Password Settings') }}</a></li>
    <li class="active"><a href="/me/apiToken"><i class="icon-paper-plane"></i> {{ t('API Settings') }}</a></li>
  </ul>

  <div class="tab-content">

  {% set message = req.flash('successMessage') %}
  {% if message.length %}
  <div class="alert alert-success m-t-10">
    {{ message }}
  </div>
  {% endif %}

  {% if req.form.errors.length > 0 %}
  <div class="alert alert-danger m-t-10">
    <ul>
    {% for error in req.form.errors %}
      <li>{{ error }}</li>
    {% endfor %}
    </ul>
  </div>
  {% endif %}

  <div class="form-box m-t-20">

    <form action="/me/apiToken" method="post" class="form-horizontal" role="form">
    <fieldset>
      <legend>{{ t('API Token Settings') }}</legend>
      <div class="form-group {% if not user.password %}has-error{% endif %}">
        <label for="" class="col-xs-3 control-label">{{ t('Current API Token') }}</label>
        <div class="col-xs-6">
          {% if user.apiToken %}
            <input class="form-control" type="text" value="{{ user.apiToken }}">
          {% else %}
          <p class="form-control-static">
            {{ t('page_me_apitoken.notice.apitoken_issued') }}
          </p>
          {% endif %}
        </div>
      </div>

      <div class="form-group">
        <div class="col-xs-offset-3 col-xs-9">

          <p class="alert alert-warning">
            {{ t('page_me_apitoken.notice.update_token1') }}<br>
            {{ t('page_me_apitoken.notice.update_token2') }}
          </p>

          <button type="submit" value="1" name="apiTokenForm[confirm]" class="btn btn-primary">{{ t('Update API Token') }}</button>
        </div>
      </div>

    </fieldset>
    </form>
  </div>


  </div>
</div>
{% endblock content_main %}

{% block content_footer %}
{% endblock %}

{% block layout_footer %}
{% endblock %}
