

{% load i18n wagtailadmin_tags %}
{% if workflow_states %}
    {% trans "Your pages in a workflow" as heading %}
    {% panel id="pages-in-workflow" heading=heading %}
        <table class="listing">
            <col />
            <col width="30%"/>
            <col width="15%"/>
            <thead class="w-sr-only">
                <tr>
                    <th class="title">{% trans "Title" %}</th>
                    <th>{% trans "Task" %}</th>
                    <th>{% trans "Task started" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for workflow_state in workflow_states %}
                    {% with workflow_state.current_task_state.page_revision as revision %}
                        {% page_permissions workflow_state.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' workflow_state.page.id %}" title="{% trans 'Edit this page' %}">{{ workflow_state.page.specific_deferred.get_admin_display_title }}</a>
                                    {% else %}
                                        {{ workflow_state.page.specific_deferred.get_admin_display_title }}
                                    {% endif %}

                                    {% i18n_enabled as show_locale_labels %}
                                    {% if show_locale_labels and workflow_state.page.locale_id %}
                                        {% locale_label_from_id workflow_state.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=workflow_state.page %}
                                    {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=workflow_state.page %}
                                </div>
                            </td>
                            <td class="task" valign="top">
                                {% if workflow_state.current_task_state.status == 'rejected' %}
                                    {% icon name="warning" class_name="default" %}
                                    {% trans "Changes requested at" %}
                                {% elif workflow_state.current_task_state.status == 'in_progress' %}
                                    {% trans "Awaiting" %}
                                {% endif %}
                                {{ workflow_state.current_task_state.task.name }}
                            </td>
                            <td valign="top">{% human_readable_date workflow_state.current_task_state.started_at %}</td>
                        </tr>
                    {% endwith %}
                {% endfor %}
            </tbody>
        </table>
    {% endpanel %}
{% endif %}
