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

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

{% block preheader %}
  New alert from {{ project_label }}.
{% endblock %}

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

{% block main %}
    <h2 style="margin-bottom: 15px">
        New alert from <a href="{% absolute_uri '/{}/{}/' group.project.organization.slug group.project.slug %}">{{ project_label }}</a>
    </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">
        <div class="event-id">ID: {{ event.event_id }}</div>
        <div class="event-date">{{ event.datetime|date:"N j, Y, g:i:s a e" }}</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://sentry.io/"/>
      </div>
    </div>
{% endblock %}
