left4me/l4d2web/l4d2web/templates/admin_users.html
mwiegand c51089df1b
refactor(modals): consolidate modal.js + modal-router.js as inline/routed
Two modal pipelines coexisted after the URL-addressable pilot — modal.js
(inline, ~30 lines) and modal-router.js (routed, ~150 lines) — operating
on different attribute namespaces and exposing different APIs. Future
modal authors had two systems to learn with no naming convention to
help them pick the right one for a given use case.

Consolidates both into static/js/modals.js with two clearly-named
pipelines and a single window.modals.* API:

  Inline modal — content pre-rendered in the page.
    Hooks:  data-inline-modal-open="<dialog-id>"
            data-inline-modal-close
    API:    window.modals.openInline(idOrEl)
            window.modals.closeInline(idOrEl)
    Use:    confirmations, transient prompts, in-page forms without
            URL value.

  Routed modal — content fetched from a URL, ?modal=<path> in URL,
            with history + share-link + refresh-survival.
    Hooks:  <a data-routed-modal href="<path>">
            data-routed-modal-dismiss
    API:    window.modals.openRouted(path)
            window.modals.closeRouted()
    Use:    content with standalone-page meaning.

Single document-level click delegation handles all four attribute
hooks; one DOMContentLoaded handler binds dialog 'close' / 'cancel' /
backdrop on the routed slot; shared popstate and htmx:responseError
listeners. Behaviour unchanged — pure rename + colocation.

Renamed across 11 templates and files-overlay.js. Old data-modal-*
attributes and window.openModal/closeModal globals are gone — clean
break (no back-compat shims). AGENTS.md "Modals: inline vs routed"
section documents the decision guide for new modals.

Verified: 573 backend tests pass. 5/5 Chromium smoke checks pass
(inline open/close, Esc, backdrop, routed open+save, routed Esc).
Console clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 14:31:38 +02:00

75 lines
2.8 KiB
HTML

{% extends "base.html" %}
{% block title %}Admin Users | left4me{% endblock %}
{% block content %}
<section class="panel">
<h1>Users</h1>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Admin</th>
<th>Active</th>
<th>Created</th>
<th>Updated</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ "yes" if user.admin else "no" }}</td>
<td>{{ "yes" if user.active else "no" }}</td>
<td>{{ user.created_at | timeago }}</td>
<td>{{ user.updated_at | timeago }}</td>
<td>
{% if user.id == g.user.id %}
<span class="muted">you</span>
{% else %}
{% if user.active %}
<form method="post" action="/admin/users/{{ user.id }}/deactivate" class="inline-form">
<input type="hidden" name="csrf_token" value="{{ session.get('csrf_token', '') }}">
<button type="submit" class="button-secondary">Deactivate</button>
</form>
{% else %}
<form method="post" action="/admin/users/{{ user.id }}/activate" class="inline-form">
<input type="hidden" name="csrf_token" value="{{ session.get('csrf_token', '') }}">
<button type="submit" class="button-secondary">Activate</button>
</form>
{% endif %}
<button type="button" class="danger-outline" data-inline-modal-open="delete-user-{{ user.id }}-modal">Delete</button>
{% endif %}
</td>
</tr>
{% else %}
<tr><td colspan="6" class="muted">No users found.</td></tr>
{% endfor %}
</tbody>
</table>
</section>
{% for user in users %}
{% if user.id != g.user.id %}
<dialog id="delete-user-{{ user.id }}-modal" class="modal" aria-labelledby="delete-user-{{ user.id }}-title">
<div class="modal-header">
<h2 id="delete-user-{{ user.id }}-title">Delete user "{{ user.username }}"?</h2>
<button type="button" class="modal-close" data-inline-modal-close aria-label="Close">&times;</button>
</div>
<div class="modal-body">
<p>This cannot be undone. Refused if the user owns servers, blueprints,
or custom overlays — delete those first.</p>
<p>For a reversible block, prefer Deactivate.</p>
</div>
<div class="modal-footer">
<button type="button" class="button-secondary" data-inline-modal-close>Cancel</button>
<form method="post" action="/admin/users/{{ user.id }}/delete" class="inline-form">
<input type="hidden" name="csrf_token" value="{{ session.get('csrf_token', '') }}">
<button class="danger" type="submit">Delete</button>
</form>
</div>
</dialog>
{% endif %}
{% endfor %}
{% endblock %}