{% load helpers %}
{% if perms.netbox_secrets.view_secret %}
    <div class="card">
        <h5 class="card-header">Secrets</h5>
        <div class="card-body">
            {% with secrets=secrets %}
                {% if secrets.exists %}
                    <form id="secret_form">
                        {% csrf_token %}
                    </form>
                    <table class="table table-hover">
                        <tr>
                            <th>Name</th>
                            <th>Role</th>
                            <th>Secret</th>
                            <th></th>
                        </tr>
                        {% for secret in secrets %}
                            <tr>
                                <td><a href="{{ secret.get_absolute_url }}">
                                    {% if secret.name %}{{ secret.name }}{% else %}(Not Set){% endif %}</a></td>
                                <td><a href="{{ secret.role.get_absolute_url }}">{{ secret.role }}</a></td>
                                <td class="font-monospace" id="secret_{{ secret.pk }}">********</td>
                                <td class="text-end noprint">
                                    {% include 'netbox_secrets/inc/secret_actions.html' with object=secret %}
                                </td>
                            </tr>
                        {% endfor %}
                    </table>
                {% else %}
                    <div class="text-muted">None</div>
                {% endif %}
            {% endwith %}
        </div>
        <div class="card-footer text-end noprint">
            {% include 'netbox_secrets/inc/secret_add_button.html' %}
        </div>
    </div>
    {% include 'netbox_secrets/inc/private_key_modal.html' %}
{% endif %}
