fix(ui): show toast notification when user deletion returns an error#3205
fix(ui): show toast notification when user deletion returns an error#3205crivetimihai merged 6 commits intomainfrom
Conversation
|
Hi @crivetimihai thanks for reopening this! I've verified the code, everything looks good, intact and matching my original changes. Ready for review whenever you get the chance. Thanks! |
dfb03d1 to
2121608
Compare
Closes #3015 Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
…d-vars Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Verify that _render_user_card_html includes the hx-on::after-request attribute with handleDeleteUserError on the delete button. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Cover the three key behaviors: extracting text from error HTML, fallback message when responseText is empty, and no-op on success. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
2121608 to
532a69d
Compare
Review SummaryRebased onto Code ReviewCorrectness: The fix is sound. The global Security: No XSS risk. Triple defense-in-depth:
Consistency: This is the only Performance: Frontend-only change, no new requests or DOM overhead. Commits added
NoteThe PR includes some unrelated formatting changes in |
🔗 Related Issue
Closes #3015
📝 Summary
When deleting a user returns a 4xx error (e.g. self-deletion, last
admin, or DB error), the error HTML was silently discarded by HTMX
because the global
htmx:beforeSwaphandler does not allow swapsfor user delete responses. The error was never shown to the admin.
This fix attaches
hx-on::after-requestto the delete button inboth the Jinja template (
users_partial.html) and thePython-generated card (
admin.py). On any non-2xx response itparses the error HTML, extracts the plain text, and calls the
already-existing
showErrorMessage()function to display a toast.No backend changes required.
🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes
Frontend-only fix. The
admin_delete_userendpoint already returnscorrect 400/403 responses with descriptive messages, this PR only
ensures those messages are surfaced to the user via the existing
toast system.