{% extends "sentry/projects/manage.html" %}

{% load crispy_forms_tags %}
{% load i18n %}
{% load sentry_helpers %}

{% block title %}{% trans "Edit API Key" %} | {{ block.super }}{% endblock %}

{% block inner %}
    <div class="page-header">
        <h2>{% trans "Edit API Key" %}</h2>
    </div>
    <form class="form-stacked" action="" method="post">
        {% csrf_token %}

        {{ form|as_crispy_errors }}

        <fieldset>
            <legend>Details</legend>
            {{ form.label|as_crispy_field }}
            <div class="control-group">
                <label>{% trans "Owner" %}</label>
                <div class="controls">
                    {% if key.user %}{{ key.user }}{% else %}&mdash;{% endif %}
                </div>
            </div>
            <div class="control-group">
                <label>{% trans "Created" %}</label>
                <div class="controls">
                    {{ key.date_added|timesince }}
                </div>
            </div>
        </fieldset>

        <fieldset>
            <legend>Credentials</legend>
            <p>{% blocktrans %}Your credentials are bound to public and secret key (though both should be considered semi-secret). Different clients will require different credentials, so make sure you check the documentation before plugging things in.{% endblocktrans %}</p>
            <div class="control-group">
                <label>{% trans "DSN" %}</label>
                <div class="controls">
                    <code class="clippy">{{ key.dsn_private }}</code>
                </div>
            </div>
            <div class="control-group">
                <label>{% trans "DSN (Public)" %}</label>
                <div class="help-text">{% blocktrans with 'https://github.com/getsentry/raven-js' as link %}Use your public DSN with insecure clients such as <a href="{{ link }}">raven-js</a>.{% endblocktrans %}</div>
                <div class="controls">
                    <code class="clippy">{{ key.dsn_public }}</code>
                </div>
            </div>
            <div class="control-group">
                <label>{% trans "Public Key" %}</label>
                <div class="controls">
                    <code class="clippy">{{ key.public_key }}</code>
                </div>
            </div>
            <div class="control-group">
                <label>{% trans "Secret Key" %}</label>
                <div class="controls">
                    <code class="clippy">{{ key.secret_key }}</code>
                </div>
            </div>
            <div class="control-group">
                <label>{% trans "Project ID" %}</label>
                <div class="controls">
                    <code class="clippy">{{ key.project_id }}</code>
                </div>
            </div>
        </fieldset>

        <fieldset>
            <legend>Permissions</legend>
            <p>Permissions are fairly wide reaching
            {{ form.roles|as_crispy_field }}
        </fieldset>

        <div class="form-actions">
            <button type="submit" class="btn btn-primary">{% trans "Save Changes" %}</button>
        </div>
    </form>
{% endblock %}
