Add filter discovery endpoints with active/inactive status (Task 2.1)
- Add list_filters() and get_filter() to config_file_service.py:
scans filter.d/, parses [Definition] + [Init] sections, merges .local
overrides, and cross-references running jails to set active/used_by_jails
- Add FilterConfig.active, used_by_jails, source_file, has_local_override
fields to the Pydantic model; add FilterListResponse and FilterNotFoundError
- Add GET /api/config/filters and GET /api/config/filters/{name} to config.py
- Remove the shadowed GET /api/config/filters list route from file_config.py;
rename GET /api/config/filters/{name} raw variant to /filters/{name}/raw
- Update frontend: fetchFilterFiles() adapts FilterListResponse -> ConfFilesResponse;
add fetchFilters() and fetchFilter() to api/config.ts; remove unused
fetchFilterFiles/fetchActionFiles calls from useConfigActiveStatus
- Fix ConfigPageLogPath test mock to include fetchInactiveJails and related
exports introduced by Stage 1
- Backend: 169 tests pass, mypy --strict clean, ruff clean
- Frontend: 63 tests pass, tsc --noEmit clean, eslint clean
This commit is contained in:
@@ -12,11 +12,7 @@
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { fetchJails } from "../api/jails";
|
||||
import {
|
||||
fetchActionFiles,
|
||||
fetchFilterFiles,
|
||||
fetchJailConfigs,
|
||||
} from "../api/config";
|
||||
import { fetchJailConfigs } from "../api/config";
|
||||
import type { JailConfig } from "../types/config";
|
||||
import type { JailSummary } from "../types/jail";
|
||||
|
||||
@@ -44,8 +40,10 @@ export interface UseConfigActiveStatusResult {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch jails, jail configs, filter files, and action files in parallel and
|
||||
* derive active-status sets for each config type.
|
||||
* Fetch jails and jail configs, then derive active-status sets for each
|
||||
* config type. Active status is computed from live jail data; filter and
|
||||
* action files are not fetched directly because their active state is already
|
||||
* available via {@link fetchFilters} / {@link fetchActions}.
|
||||
*
|
||||
* @returns Active-status sets, loading flag, error, and refresh function.
|
||||
*/
|
||||
@@ -69,10 +67,8 @@ export function useConfigActiveStatus(): UseConfigActiveStatusResult {
|
||||
Promise.all([
|
||||
fetchJails(),
|
||||
fetchJailConfigs(),
|
||||
fetchFilterFiles(),
|
||||
fetchActionFiles(),
|
||||
])
|
||||
.then(([jailsResp, configsResp, _filterResp, _actionResp]) => {
|
||||
.then(([jailsResp, configsResp]) => {
|
||||
if (ctrl.signal.aborted) return;
|
||||
|
||||
const summaries: JailSummary[] = jailsResp.jails;
|
||||
|
||||
Reference in New Issue
Block a user