{% load i18n wagtailadmin %}
{% if workflow_state %}
<li>
    <button data-url="{% url 'wagtailadmin_pages:workflow_status' page.id %}"
            class="button button-small button-nobg text-notransform action-workflow-status">
        {% if workflow_state.status == 'needs_changes' %}
            {% icon name="warning" %}
            {% trans "Changes requested" %}
            {% include "wagtailadmin/shared/last_updated.html" with since_text=since_text last_updated=workflow_state.current_task_state.finished_at time_prefix="at" %}
        {% else %}
            {% if workflow_state.status == "in_progress" %}
                {% trans "Awaiting" %}
                {% trans "since" as since_text %}
            {% else %}
                {{ workflow_state.get_status_display }}
            {% endif %}
            {{ workflow_state.current_task_state.task.name }}
            {% include "wagtailadmin/shared/last_updated.html" with since_text=since_text last_updated=workflow_state.current_task_state.started_at %}
        {% endif %}
    </button>
</li>
{% else %}
<li class="header-meta--status">
    {% with latest_revision=page.get_latest_revision %}
        {% if latest_revision %}
            {% if latest_revision.user %}
                <span class="avatar small" data-wagtail-tooltip="{{ latest_revision.user|user_display_name }}"><img src="{% avatar_url latest_revision.user size=25 %}" alt="" /></span>
            {% endif %}
            {% if latest_revision == page.live_revision %}
                {% trans "Published" %}
            {% else %}
                {% trans "Draft saved" %}
            {% endif %}
            {% include "wagtailadmin/shared/last_updated.html" with last_updated=latest_revision.created_at time_prefix="at" %}
        {% else %}
            {% if page.live %}
                {% trans "Published" %}
            {% else %}
                {% trans "Draft" %}
            {% endif %}
        {% endif %}
    {% endwith %}
</li>
{% endif %}
