{% load humanize %}
{% load i18n %}

<div class="card shadow">
    <div class="card-body table-responsive secret-meta">
        <table class="table table-borderless align-middle">
            <tr>
                <td>{% trans "Changed" %}</td>
                <td>
                    <span data-bs-toggle="tooltip" data-bs-placement="top"
                          title="{{ secret.last_changed|date:"Y-m-d H:i:s e" }}">
                        {{ secret.last_changed|naturalday:"Y-m-d" }}
                    </span>
                </td>
            </tr>
            <tr>
                <td>{% trans "Changed by" %}</td>
                <td>{{ secret.current_revision.set_by.username }}</td>
            </tr>
            <tr class="border-top">
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>{% trans "Created" %}</td>
                <td>
                    <span data-bs-toggle="tooltip" data-bs-placement="top"
                          title="{{ secret.created|date:"Y-m-d H:i:s e" }}">
                        {{ secret.created|naturalday:"Y-m-d" }}
                    </span>
                </td>
            </tr>
            <tr>
                <td>{% trans "Created by" %}</td>
                <td>{{ secret.created_by.username }}</td>
            </tr>
            <tr class="border-top">
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>{% trans "Shared with" %}</td>
                <td>
                    <span data-bs-toggle="tooltip" data-bs-placement="left"
                          title="{% for share in allowed_groups %}{{ share.shared_entity_name }}<br>{% endfor %}">
                        {% blocktrans with groupcount=allowed_groups|length %}
                            {{ groupcount }} group(s)
                        {% endblocktrans %}
                    </span>
                    <br>
                    <span data-bs-toggle="tooltip" data-bs-placement="left"
                          title="{% for share in allowed_users %}{{ share.shared_entity_name }}<br>{% endfor %}">
                        {% blocktrans with usercount=allowed_users|length %}
                            {{ usercount }} user(s)
                        {% endblocktrans %}
                    </span>
                </td>
            </tr>
        </table>
        <hr>
        {% if request.user.is_superuser %}
            <a class="btn btn-light" href="{% url 'audit.log' %}?secret={{ secret.hashid }}">
                <i class="fa fa-list fa-fw text-info-emphasis"></i>
                {% trans "Audit log" %}
            </a>
        {% endif %}
    </div>
</div>
