{% extends "sentry/projects/manage.html" %}

{% load i18n %}

{% block main %}
    <a href="{% url 'sentry-new-project-rule' project.organization.slug project.slug %}" class="btn pull-right btn-primary btn-sm">
        <span class="icon-plus"></span>
        {% trans "New Rule" %}
    </a>
    <h2>{% trans "Rules" %}</h2>

    {% if rule_list %}
        <div class="rules-list">
            {% for rule in rule_list %}
                <div class="box">
                    <div class="box-header">
                        <div class="pull-right">
                            <a href="{% url 'sentry-edit-project-rule' project.organization.slug project.slug rule.id %}"class="btn btn-sm btn-default">Edit Rule</a>
                            <form style="display:inline" method="POST" action="{% url 'sentry-remove-project-rule' project.organization.slug project.slug rule.id %}">
                                {% csrf_token %}
                                <button type="submit" class="btn btn-sm btn-default"
                                        onclick="return confirm('Are you sure you want to remove this rule?')"><span class="icon-trash" style="margin-right: 3px;"></span></button>
                            </form>
                        </div>
                        <h3><a href="{% url 'sentry-edit-project-rule' project.organization.slug project.slug rule.id %}">{{ rule.label }}</a></h3>
                    </div>
                    <div class="box-content with-padding">
                        <div class="row">
                            <div class="col-md-6">
                                {% if rule.conditions %}
                                    <h6>When <strong>{{ rule.match }}</strong> of these conditions are met:</h6>
                                    <table class="conditions-list table">
                                    {% for condition in rule.conditions %}
                                        <tr>
                                            <td>{{ condition }}</td>
                                        </tr>
                                    {% endfor %}
                                    </table>
                                {% endif %}
                            </div>
                            <div class="col-md-6">
                                {% if rule.actions %}
                                    <h6>Take these actions:</h6>
                                    <table class="actions-list table">
                                    {% for action in rule.actions %}
                                        <tr>
                                            <td>{{ action }}</td>
                                        </tr>
                                    {% endfor %}
                                    </table>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% else %}
        <p>You have not yet created any rules. Rules allow you to tweak the behavior of Sentry in various situations, such as sending notifications.</p>
    {% endif %}
{% endblock %}
