{% extends "sentry/emails/base.html" %}

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

{% block preheader %}
  {% if group.times_seen == 1 %}
      New Issue on {{ project_label }}.
  {% else %}
      Regression on {{ project_label }}.
  {% endif %}
{% endblock %}

{% block header %}
    <a href="{{ link }}" class="btn">View on Sentry</a>
    {{ block.super }}
{% endblock %}

{% block main %}
    <h2 style="margin-bottom: 15px">
        {% url 'sentry-stream' group.project.organization.slug group.project.slug as project_link %}
        {% if group.times_seen == 1 %}
            New Issue on <a href="{% absolute_uri project_link %}">{{ project_label }}</a>
        {% else %}
            Regression on <a href="{% absolute_uri project_link %}">{{ project_label }}</a>
        {% endif %}
    </h2>

    {% if enhanced_privacy %}
      <div class="notice">Details about this issue are not shown in this notification since enhanced privacy
        controls are enabled. For more details about this issue, <a href="{{ link }}">view this issue on Sentry</a>.</div>
    {% else %}
      <div class="event">
        <pre class="message">{{ event.message }}</pre>
        <div class="event-id">ID: {{ event.event_id }}</div>
        <div class="event-date">{{ event.datetime }} UTC</div>
      </div>

      {% for label, html, _ in interfaces %}
      <div class="interface">
          <h3 class="title">{{ label }}</h3>
          {{ html }}
      </div>
      {% endfor %}

      {% if tags %}
        <h3>Tags</h3>

        <ul class="tag-list">
        {% for tag_key, tag_value in tags %}
          <li>
              <strong>{{ tag_key }}</strong>
              <em>=</em>
              <span>
              {% with query=tag_key|add:":\""|add:tag_value|add:"\""|urlencode %}
                <a href="{% absolute_uri project_link %}?query={{ query }}">{{ tag_value|truncatechars:50 }}</a> {% if tag_value|is_url %}<a href="{{ tag_value }}" class="icon-share"></a>{% endif %}
              {% endwith %}
              </span>
          </li>
        {% endfor %}
        </ul>
      {% endif %}
    {% endif %}

    {% if rules %}
        <p class="via">
            You are receiving this email due to matching rules:
            {% for rule_label, rule_link in rules %}
                <a href="{% absolute_uri rule_link %}">{{ rule_label }}</a>{% if not forloop.last %}, {% endif %}
            {% endfor %}
        </p>
    {% endif %}


    {# support for gmail actions #}
    <div itemscope itemtype="http://schema.org/EmailMessage">
      <meta itemprop="description" content="View Issue Details in Sentry"/>
      <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
        <link itemprop="url" href="{{ link }}"/>
        <meta itemprop="name" content="View in Sentry"/>
      </div>
      <div itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
        <meta itemprop="name" content="GetSentry"/>
        <link itemprop="url" href="https://getsentry.com/"/>
      </div>
    </div>
{% endblock %}
