{% if worker_list %}
    <table class="table table-sm" id="worker-list">
        <thead>
            <tr>
                <th>
                    Name (Type)
                    {% include "web/_order.html" with name="name" order=order asc=asc only %}
                </th>
                <th>
                    Last seen
                    {% include "web/_order.html" with name="last_seen_at" order=order asc=asc only %}
                </th>
                <th>
                    Status
                    {% include "web/_order.html" with name="token__enabled" order=order asc=asc only %}
                </th>
            </tr>
        </thead>
        <tbody>
            {% for worker in worker_list %}
                <tr>
                    <td>{% include "_worker_name_type.html" with worker=worker only %}</td>
                    <td>
                        {% with last_seen_at=worker.token.last_seen_at %}
                            {% if last_seen_at %}
                                {{ last_seen_at|timesince }} ago
                            {% else %}
                                Never
                            {% endif %}
                        {% endwith %}
                    </td>
                    <td>
                        {% if not worker.token.enabled %}
                            {% include "web/_worker-status.html" with status="disabled" %}
                        {% elif not worker.connected %}
                            {% include "web/_worker-status.html" with status="disconnected" %}
                        {% elif worker.running_work_requests %}
                            {% spaceless %}
                                {% for work_request in worker.running_work_requests %}
                                    {% if work_request.workspace.public or request.user.is_authenticated %}
                                        <a href="{% url "work_requests:detail" pk=work_request.id %}">{{ work_request.get_label }}</a>
                                    {% else %}
                                        Private Task
                                    {% endif %}
                                    <br>
                                {% endfor %}
                            {% endspaceless %}
                        {% else %}
                            {% include "web/_worker-status.html" with status="idle" %}
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
{% else %}
    <p>No workers registered in this debusine instance.</p>
{% endif %}
