Refactor ServerTab and ConfFilesTab to use reducers

This commit is contained in:
2026-04-21 19:52:05 +02:00
parent 260ce7e875
commit 1ba82d56e7
5 changed files with 482 additions and 130 deletions

View File

@@ -452,7 +452,11 @@ const source = timeRange === "24h" ? "fail2ban" : "archive";
---
### TASK-023 — Replace loose `string` types with union types in config models
### TASK-023 — Replace loose `string` types with union types in config models (done)
**Where fixed:** `frontend/src/types/config.ts`, `frontend/src/types/jail.ts`, `frontend/src/components/config/JailsTab.tsx`, `frontend/src/components/config/JailSectionPanel.tsx`, `backend/app/models/config.py`
**Summary:** Added explicit union types for `DNSMode`, `LogEncoding`, and `BackendType` in frontend config models and backend Pydantic models. Updated the affected jail config form state and select handlers to use the narrowed types.
**Where found:** `frontend/src/types/config.ts``JailConfig.use_dns`, `JailConfig.log_encoding`, `JailConfig.backend`, and several action/filter fields are typed as plain `string` despite having a fixed set of valid values defined by fail2ban.
@@ -474,7 +478,11 @@ Update `JailConfig` (and the corresponding `JailConfigUpdate` patch type) to use
---
### TASK-024 — Add `useReducer` to `ServerTab` and `ConfFilesTab`
### TASK-024 — Add `useReducer` to `ServerTab` and `ConfFilesTab` (done)
**Status:** done
**Summary:** Replaced the local `useState` clusters in `ServerTab.tsx` and `ConfFilesTab.tsx` with reducer-based state management, ensuring compound updates such as flush/reload/restart transitions and file content edits update atomically.
**Where found:**
- `frontend/src/components/config/ServerTab.tsx` — 11 `useState` calls managing logLevel, logTarget, dbPurgeAge, dbMaxMatches, flushing, msg, isReloading, isRestarting, and three map threshold fields.