{% load i18n %}
{% load translations %}
{% load permissions %}
{% load icons %}

<div class="container-fluid">
{% for change in last_changes %}
<div class="row history-row">
    <div class="col-xs-2 history-event">
        <strong>{{ change.get_user_display }}</strong>
        <p class="text-muted">{{ change.get_action_display }}</p>
        <p>
            {% if change.project %}
            <a href="{{ change.project.get_absolute_url }}">{{ change.project }}</a>
            {% endif %}
            {% if change.dictionary %}
            — <a href="{{ change.dictionary.get_parent_url }}">{{ change.dictionary.language }}</a>
            {% endif %}
            {% if change.component %}
            / <a href="{{ change.component.get_absolute_url }}">{{ change.component.name }}</a>
            {% endif %}
            {% if change.translation %}
            — <a href="{{ change.translation.get_absolute_url }}">{{ change.translation.language }}</a>
            {% endif %}
        </p>
    </div>
    <div class="col-xs-10 history-data">
        {% if not hide_links %}
        {% perm 'unit.edit' change.unit as user_can_translate %}
        <div class="btn-float pull-right flip">
            <a class="btn btn-link" href="{{ change.get_absolute_url }}" title="{% trans "View details" %}">{% icon "magnify-plus-outline.svg" %}</a>
            {% if debug %}
            <a class="btn btn-link" href="{% url 'show_change' pk=change.pk %}" title="{% trans "View notification" %}">{% icon "bell.svg" %}</a>
            {% endif %}
            {% if change.can_revert and user_can_translate %}
            <a class="btn btn-link" href="{{ cchange.translation.get_translate_url}}?{% if search_url %}{{ search_url }}&amp;offset={{ offset }}&amp;{% endif %}checksum={{ change.unit.checksum }}&amp;revert={{ change.id }}" title="{% trans "Revert" %}">{% icon "undo.svg" %}</a>
            {% endif %}
        </div>
        {% endif %}
        <div class="comment-content">
            {% with details=change.get_details_display %}
            {% if details %}
                {{ details }}
            {% elif change.can_revert %}
                {% format_translation change.target change.unit.translation.language change.unit.translation.plural diff=change.old %}
            {% elif change.show_content %}
                {% format_translation change.target change.unit.translation.language change.unit.translation.plural %}
            {% elif change.show_source %}
                {% format_translation change.target change.component.project.source_language diff=change.old %}
            {% elif change.target %}
                <pre>{{ change.target }}</pre>
            {% else %}
                {{ change.get_action_display }}
            {% endif %}
            {% endwith %}
            <span class="pull-right flip text-muted">{{ change.timestamp|naturaltime }}</span>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{% empty %}
<p>{% trans "No matching activity found." %}</p>
{% endfor %}
</div>
