From 4b6e118a88976c74e26541572445c52b05ceb304 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sat, 14 Mar 2026 19:50:55 +0100 Subject: [PATCH] Fix ActivateJailDialog blocking logic and mypy false positive Two frontend bugs and one mypy false positive fixed: - ActivateJailDialog: Activate button was never disabled when blockingIssues.length > 0 (missing condition in disabled prop). - ActivateJailDialog: handleConfirm called onActivated() even when the backend returned active=false (blocked activation). Dialog now stays open and shows result.message instead. - config.py: Settings() call flagged by mypy --strict because pydantic-settings loads required fields from env vars at runtime; suppressed with a targeted type: ignore[call-arg] comment. Tests: added ActivateJailDialog.test.tsx (5 tests covering button state, backend-rejection handling, success path, and crash detection callback). --- Docs/Tasks.md | 131 ++++++++++ backend/app/config.py | 2 +- .../components/config/ActivateJailDialog.tsx | 9 +- .../__tests__/ActivateJailDialog.test.tsx | 229 ++++++++++++++++++ 4 files changed, 369 insertions(+), 2 deletions(-) create mode 100644 frontend/src/components/config/__tests__/ActivateJailDialog.test.tsx diff --git a/Docs/Tasks.md b/Docs/Tasks.md index 32e7007..e3eb49e 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -331,3 +331,134 @@ The `deactivate_jail` endpoint in `backend/app/routers/config.py` is inconsisten 3. **Manual test with running server:** - Go to `/config`, find an active jail and click "Deactivate". - Immediately navigate to the Dashboard — "Active Jails" count should already reflect the reduced count without any delay. + +--- + +## Task 7 — Fix ActivateJailDialog not honouring backend rejection and mypy false positive + +**Status:** in progress + +### Problem description + +Two independent bugs were introduced during Tasks 5–6: + +**Bug 1 — "Activate" button is never disabled on validation errors (frontend)** + +In `frontend/src/components/config/ActivateJailDialog.tsx`, Task 5 Part B set: + +```tsx +const blockingIssues = validationIssues; // all issues block activation +``` + +but the "Activate" `