{% extends "sentry/layout.html" %}

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

{% block heading %}{% trans "Search" %}{% endblock %}

{% block main %}
    {% paginate message_list from request as message_list per_page 15 %}

    <div class="paging-wrap">
        <div class="clearfix">
            <form method="GET" action="">
                <input type="hidden" name="q" value="{% if query %}{{ query }}{% endif %}"/>
                <div class="sort-by">Sort by <select name="sort" onchange="this.form.submit()">
                    <option value=""{% ifequal sort 'relevance' %} selected="selected"{% endifequal %}>Relevance</option>
                    <option value="date"{% ifequal sort 'date' %} selected="selected"{% endifequal %}>Last Seen</option>
                    <option value="new"{% ifequal sort 'new' %} selected="selected"{% endifequal %}>First Seen</option>
                </select>
                </div>
            </form>
            {{ message_list.paging }}
        </div>
    </div>

    {% if message_list.objects %}
        <ul class="messages" id="message_list">
            {% for group, priority in message_list.objects|with_priority %}
                {% include "sentry/partial/_group.html" %}
            {% endfor %}
        </ul>
    {% else %}
        <ul class="messages" id="message_list">
            <li class="no-messages" id="no_messages">{% trans "No messages match your query." %}</li>
        </ul>
    {% endif %}

    <div class="clearfix">
        {{ message_list.paging }}
    </div>
{% endblock %}
