{% extends "sentry/bases/admin.html" %}

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

{% block title %}{% trans "Manage Teams" %} | {{ block.super }}{% endblock %}

{% block admin-nav-teams %} class="active"{% endblock %}

{% block main %}
    {% paginator team_list from request as team_list per_page 50 %}
        <form class="pull-right" method="GET" action="">
            <input class="form-control" type="text" name="tquery" value="{% if team_query %}{{ team_query }}{% endif %}" placeholder="search by team name" style="width: 240px; margin-top: -4px">
        </form>
        <h3 class="no-border">{% trans "Teams" %}</h3>

        {% querystring from request without sort as sort_querystring %}

        {% if team_list.paginator.objects %}
        <table class="table" style="margin-bottom: 20px;">
            <colgroup>
                <col>
                <col style="width:150px;">
                <col style="width:150px;">
                <col style="width:150px;">
            </colgroup>
            <thead>
                <tr>
                    <th><a href="?{{ sort_querystring }}&amp;sort=name">{% trans "Team" %}</a></th>
                    <th style="text-align:right;"><a href="?{{ sort_querystring }}&amp;sort=projects">{% trans "Projects" %}</a></th>
                    <th style="text-align:right;"><a href="?{{ sort_querystring }}&amp;sort=date">{% trans "Date Added" %}</a></th>
                </tr>
            </thead>
            <tbody>
                {% for team in team_list.paginator.objects %}
                    <tr>
                        <td>
                            <a href="{% url 'sentry-manage-team' team.organization.slug team.slug %}"><strong>{{ team.slug }}</strong></a>
                        </td>
                        <td style="text-align:right; vertical-align:middle;">
                            {{ team.num_projects }}
                        </td>
                        <td style="text-align:right; vertical-align:middle;">
                            {{ team.date_added|date }}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>

    {% else %}
        <p class="alert alert-notice">{% trans "There are no active teams in Sentry." %}</p>
    {% endif %}

    <div class="btn-toolbar">
        <div class="btn-group pull-right">
            <a class="btn btn-lg prev{% if not team_list.paginator.has_previous %} disabled{% else %}" href="?{{ team_list.query_string|escape }}&amp;p={{ team_list.paginator.previous_page }}{% endif %}"><span class="icon-arrow-left"></span></a>
            <a class="btn btn-lg next{% if not team_list.paginator.has_next %} disabled{% else %}" href="?{{ team_list.query_string|escape }}&amp;p={{ team_list.paginator.next_page }}{% endif %}"><span class="icon-arrow-right"></span></a>
        </div>
    </div>
{% endblock %}
