{% extends "sentry/explore/code/list_tag.html" %}

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

{% block title %}
    {% if selection == 'functions' %}
        {{ tag.data.function }} from
    {% endif %}
    {{ tag.data.filename }} | {{ block.super }}
{% endblock %}

{% block bodyclass %} with-sidebar{% endblock %}

{% block sidebar %}
    <h6>{% trans "Code Details" %}</h6>
    <dl>
        <dt>{% trans "Filename:" %}</dt>
        <dd><a href="{% url 'sentry-explore-code-details' organization.slug project.slug tag.id %}">{{ tag.data.filename }}</a></dd>
        {% if selection == 'functions' %}
            <dt>{% trans "Function:" %}</dt>
            <dd><a href="{% url 'sentry-explore-code-details-by-function' organization.slug project.slug tag.id %}">{{ tag.data.function }}</a></dd>
        {% endif %}
        <dt>First Seen:</dt>
        <dd>{{ tag.first_seen|timesince }}</dd>
        <dt>Last Seen:</dt>
        <dd>{{ tag.last_seen|timesince }}</dd>
        <dt>Number of Events:</dt>
        <dd>{{ tag.times_seen|small_count }}</dd>
    </dl>
{% endblock %}

{% block main %}
    {% paginator event_list from request as event_list per_page EVENTS_PER_PAGE %}

    <div class="btn-toolbar">
        <div class="pull-left">
            <h2 style="line-height:1;">{{ tag.data.filename }}{% if selection == 'functions' %} <small>{{ tag.data.function }}</small>{% endif %}</h2>
        </div>
        <div class="btn-group pull-right">
            <a class="btn prev{% if not event_list.paginator.has_previous %} disabled{% else %}" href="?p={{ event_list.paginator.previous_page }}{% endif %}"><span>{% trans "Previous" %}</span></a>
            <a class="btn next{% if not event_list.paginator.has_next %} disabled{% else %}" href="?p={{ event_list.paginator.next_page }}{% endif %}"><span>{% trans "Next" %}</span></a>
        </div>
    </div>

    <div id="event_list"></div>

    <script>
    $(function(){
        new app.GroupListView({
            className: 'group-list',
            members: {{ event_list.paginator.objects|to_json:request|safe }},
            id: "event_list"
        });
    });
    </script>

    <div class="btn-toolbar">
        <div class="btn-group pull-right">
            <a class="btn prev{% if not event_list.paginator.has_previous %} disabled{% else %}" href="?p={{ event_list.paginator.previous_page }}{% endif %}"><span>{% trans "Previous" %}</span></a>
            <a class="btn next{% if not event_list.paginator.has_next %} disabled{% else %}" href="?p={{ event_list.paginator.next_page }}{% endif %}"><span>{% trans "Next" %}</span></a>
        </div>
    </div>
{% endblock %}
