{% load i18n wagtailadmin_tags %}
{% if page_revisions_for_moderation %}
    <section class="object collapsible">
        <h2 class="title-wrapper">{% trans 'Pages awaiting moderation' %}</h2>
        <div class="object-layout">
            <table class="listing">
                <col />
                <col width="30%"/>
                <col width="15%"/>
                <col width="15%"/>
                <thead>{# Note: the header is visually hidden behind .title-wrapper #}
                    <tr>
                        <th class="title">{% trans "Title" %}</th>
                        <th>{% trans "Parent" %}</th>
                        <th>{% trans "Type" %}</th>
                        <th>{% trans "Edited" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for revision in page_revisions_for_moderation %}
                        {% page_permissions revision.page as page_perms %}
                        <tr>
                            <td class="title" valign="top">
                                <div class="title-wrapper">
                                    {% if page_perms.can_edit %}
                                        <a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" title="{% trans 'Edit this page' %}">{{ revision.page.specific_deferred.get_admin_display_title }}</a>
                                    {% elif revision.page.is_previewable %}
                                        <a href="{% url 'wagtailadmin_pages:preview_for_moderation' revision.id %}" title="{% trans 'Preview this page' %}">{{ revision.page.specific_deferred.get_admin_display_title }}</a>
                                    {% else %}
                                        {{ revision.page.specific_deferred.get_admin_display_title }}
                                    {% endif %}

                                    {% i18n_enabled as show_locale_labels %}
                                    {% if show_locale_labels and revision.page.locale_id %}
                                        {% locale_label_from_id revision.page.locale_id as locale_label %}
                                        <span class="status-tag status-tag--label">{{ locale_label }}</span>
                                    {% endif %}
                                    {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=revision.page %}
                                    {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=revision.page %}
                                </div>
                                <ul class="actions">
                                    <li>
                                        <form action="{% url 'wagtailadmin_pages:approve_moderation' revision.id %}" method="POST">
                                            {% csrf_token %}
                                            <input type="submit" class="button button-small button-secondary" value="{% trans 'Approve' %}">
                                        </form>
                                    </li>
                                    <li class="no-border">
                                        <form action="{% url 'wagtailadmin_pages:reject_moderation' revision.id %}" method="POST">
                                            {% csrf_token %}
                                            <input type="submit" class="button button-small button-secondary no" value="{% trans 'Reject' %}">
                                        </form>
                                    </li>
                                    {% if page_perms.can_edit %}
                                        <li><a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" class="button button-small button-secondary">{% trans 'Edit' %}</a></li>
                                    {% endif %}
                                    {% if revision.page.is_previewable %}
                                        <li><a href="{% url 'wagtailadmin_pages:preview_for_moderation' revision.id %}" class="button button-small button-secondary" target="_blank" rel="noreferrer">{% trans 'Preview' %}</a></li>
                                    {% endif %}
                                </ul>
                            </td>
                            <td valign="top">
                                <a href="{% url 'wagtailadmin_explore' revision.page.get_parent.id %}">{{ revision.page.get_parent.specific_deferred.get_admin_display_title }}</a>
                            </td>
                            <td class="type" valign="top">
                                {{ revision.page.content_type.model_class.get_verbose_name }}
                            </td>
                            <td valign="top">
                                <div class="human-readable-date" title="{{ revision.created_at|date:"DATETIME_FORMAT" }}">{% blocktrans trimmed with time_period=revision.created_at|timesince_simple %}{{ time_period }}{% endblocktrans %} </div>
                                {% if revision.user %}
                                    by {{ revision.user|user_display_name }}
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </section>
{% endif %}
