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

{% load i18n %}
{% load sentry_helpers %}
{% load sentry_plugins %}

{% block title %}{% trans "Release Tracking" %} | {{ block.super }}{% endblock %}

{% block main %}
  <h2>{% trans "Release Tracking" %}</h2>

  <p>Configure release tracking for this project to automatically record new releases of your application.</p>

  <div class="box">
    <div class="box-header">
      <h3>{% trans "Client Configuration" %}</h3>
    </div>
    <div class="box-content with-padding">
      <p>Start by binding the <code>release</code> attribute in your application:</p>

      <pre>// See SDK documentation for language specific usage.
Raven.config('your dsn', {
  release: '0e4fdef81448dcfa0e16ecc4433ff3997aa53572'
});</pre>

      <p>This will annotate each event with the version of your application, as well as
        automatically create a release entity in the system the first time it's seen.<p>

      <p>In addition you may configure a release hook (or use our API) to push a release
        and include additional metadata with it.</p>
    </div>
  </div>

  <div class="box">
    <div class="box-header">
      <h3>{% trans "Token" %}</h3>
    </div>
    <div class="box-content with-padding">
      <form method="POST">
        {% csrf_token %}
          <p>Your token is a unique secret which is used to generate deploy hook URLs. If a service becomes compromised, you should regenerate the token and re-configure any deploy hooks with the newly generated URL.</p>
          <p>
            <code style="display:inline-block" class="auto-select">{{ token }}</code>
            <button type="submit" class="btn btn-sm btn-danger" name="op" value="regenerate-token">Regenerate Token</button>
          </p>
      </form>
    </div>
  </div>


  <div class="box">
    <div class="box-header">
      <h3>{% trans "Webhook" %}</h3>
    </div>
    <div class="box-content with-padding">
      <form method="POST">
        {% csrf_token %}
          <p>If you simply want to integrate with an existing system, sometimes its easiest just to use a webhook.</p>

          <pre class="auto-select">{{ webhook_url }}</pre>

          <p>The release webhook accepts the same parameters as the "Create a new Release" API endpoint, for example:</p>

          <pre class="auto-select">curl {{ webhook_url }} \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{"version": "abcdefg"}'</pre>
      </form>
    </div>
  </div>

  {% if enabled_plugins or other_plugins %}
    {% for plugin, content in enabled_plugins %}
      <div class="box">
        <div class="box-header">
          {% if plugin.can_disable %}
            <form method="POST" class="pull-right">
              {% csrf_token %}
              <input type="hidden" name="plugin" value="{{ plugin.slug }}" />
              <button type="submit" class="btn btn-sm btn-default" name="op" value="disable">Disable</button>
            </form>
          {% endif %}
          <h3>{{ plugin.get_title }}</h3>
        </div>
        <div class="box-content with-padding">
          {{ content }}
          </form>
        </div>
      </div>
    {% endfor %}

    {% if other_plugins %}
      <div class="box">
        <div class="box-header">
          <h3>{% trans "Inactive Integrations" %}</h3>
        </div>
        <div class="box-content with-padding">
          <ul class="integration-list">
            {% for plugin in other_plugins %}
              <li>
                <form method="POST">
                  {% csrf_token %}
                  <input type="hidden" name="op" value="enable" />
                  <input type="hidden" name="plugin" value="{{ plugin.slug }}" />
                  <button type="submit">{{ plugin.get_title }}</button>
                </form>
              </li>
            {% endfor %}
          </ul>
        </div>
      </div>
    {% endif %}
  {% endif %}

  <div class="box">
    <div class="box-header">
      <h3>{% trans "API" %}</h3>
    </div>
    <div class="box-content with-padding">
      <p>You can notify Sentry when you release new versions of your application via our HTTP API.</p>

      <p>See the <a href="https://docs.getsentry.com/hosted/api/releases/">Releases API documentation</a> for more information.</p>
    </div>
  </div>
{% endblock %}
