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

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

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

{% block main %}
    <section class="body">
    {% block inner %}
        <div class="page-header">
            <h2>{% trans "Project Details" %}</h2>
        </div>
        <form class="form-stacked" action="" method="post">
            {% csrf_token %}

            {{ form|as_crispy_errors }}

            <fieldset>
                {% for field in form %}
                    {% if field.name != 'origins' and field.name != 'public' and field.name != 'resolve_age' %}
                        {{ field|as_crispy_field }}
                    {% endif %}
                {% endfor %}
            </fieldset>
            <fieldset id="events">
                <div><legend>{% trans "Event Settings" %}</legend></div>
                {{ form.resolve_age|as_crispy_field }}
                {% if form.public %}
                    {{ form.public|as_crispy_field }}
                {% endif %}
            </fieldset>
            <fieldset id="client-security">
                <div><legend>{% trans "Client Security" %}</legend></div>
                {% with form.origins as field %}
                    <p>{% blocktrans with 'https://github.com/getsentry/raven-js' as link %}Configure origin URLs which Sentry should accept events from. This is used for communication with clients like <a href="{{ link }}">raven-js</a>.{% endblocktrans %}
                    <p>{% blocktrans %}This will restrict requests based on the <code>Origin</code> and <code>Referer</code> headers.{% endblocktrans %}</p>
                    {{ field|as_crispy_field }}
                {% endwith %}
            </fieldset>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary">{% trans "Save Changes" %}</button>
                {% if not project.is_default_project %}
                    <a href="{% url 'sentry-remove-project' project.team.slug project.slug %}" class="btn btn-danger">{% trans "Remove Project" %}</a>
                {% else %}
                    <p class="pull-right">{% trans "This project cannot be removed. It is used internally by the Sentry server." %}</p>
                {% endif %}
            </div>
        </form>

        <script type="text/javascript">
        new app.ProjectDetailsPage();
        </script>
    {% endblock %}
    </section>
{% endblock %}

{% block sidebar %}
    <ul class="nav nav-list">
        <li class="nav-header">{% trans "Details" %}</li>
        <li{% if page == 'details' %} class="active"{% endif %}>
            <a href="{% url 'sentry-manage-project' project.team.slug project.slug %}">{% trans "Settings" %}</a>
        </li>
        <li{% if page == 'notifications' %} class="active"{% endif %}>
            <a href="{% url 'sentry-project-notifications' project.team.slug project.slug %}">{% trans "Notifications" %}</a>
        </li>
        <li{% if page == 'quotas' %} class="active"{% endif %}>
            <a href="{% url 'sentry-manage-project-quotas' project.team.slug project.slug %}">{% trans "Rate Limits" %}</a>
        </li>
        <li{% if page == 'tags' %} class="active"{% endif %}>
            <a href="{% url 'sentry-manage-project-tags' project.team.slug project.slug %}">{% trans "Tags" %}</a>
        </li>
        <li{% if page == 'keys' %} class="active"{% endif %}>
            <a href="{% url 'sentry-manage-project-keys' project.team.slug project.slug %}">{% trans "API Keys" %}</a>
        </li>
    </ul>
    <ul class="nav nav-list">
        <li class="nav-header">{% trans "Client Configuration" %}</li>
        <li{% if page == 'client_help' %} class="active"{% endif %}>
            <a href="{% url 'sentry-project-client-help' project.team.slug project.slug %}">{% trans "All Platforms" %}</a>
        </li>
        <li{% if page == 'client_help_javascript' %} class="active"{% endif %}>
            <a href="{% url 'sentry-docs-client' project.team.slug project.slug "javascript" %}">{% trans "JavaScript" %}</a>
        </li>
        <li{% if page == 'client_help_python' %} class="active"{% endif %}>
            <a href="{% url 'sentry-docs-client' project.team.slug project.slug "python" %}">{% trans "Python" %}</a>
        </li>
        <li{% if page == 'client_help_php' %} class="active"{% endif %}>
            <a href="{% url 'sentry-docs-client' project.team.slug project.slug "php" %}">{% trans "PHP" %}</a>
        </li>
        <li{% if page == 'client_help_ruby' %} class="active"{% endif %}>
            <a href="{% url 'sentry-docs-client' project.team.slug project.slug "ruby" %}">{% trans "Ruby" %}</a>
        </li>
        <li{% if page == 'client_help_node.js' %} class="active"{% endif %}>
            <a href="{% url 'sentry-docs-client' project.team.slug project.slug "node.js" %}">{% trans "Node.js" %}</a>
        </li>
        <li{% if page == 'client_help_java' %} class="active"{% endif %}>
            <a href="{% url 'sentry-docs-client' project.team.slug project.slug "java" %}">{% trans "Java" %}</a>
        </li>
    </ul>
    {% with project|get_plugins as plugins %}
        <ul class="nav nav-list">
            <li class="nav-header">{% trans "Integrations" %}</li>
            <li class="{% if page == 'plugins' %} active{% endif %}">
                <a href="{% url 'sentry-manage-project-plugins' project.team.slug project.slug %}">{% trans "Manage Integrations" %} ({{ PLUGINS|length }})</a>
            </li>
            {% for p in plugins %}
                <li{% if page == 'plugin' and plugin.slug == p.slug %} class="active"{% endif %}>
                    <a href="{% url 'sentry-configure-project-plugin' project.team.slug project.slug p.slug %}">{{ p.get_title }}</a>
                </li>
            {% endfor %}
        </ul>
    {% endwith %}
{% endblock %}
