import { useCallback } from "react"; import { Accordion, AccordionHeader, AccordionItem, AccordionPanel, Field, Input, Select, Switch, } from "@fluentui/react-components"; import { KVEditor } from "./KVEditor"; import { StringListEditor } from "./StringListEditor"; import { useConfigStyles } from "./configStyles"; import type { BackendType, JailSectionConfig } from "../../types/config"; const BACKENDS = ["", "auto", "polling", "gamin", "pyinotify", "systemd"] as const; interface JailSectionPanelProps { jailName: string; section: JailSectionConfig; onChange: (next: JailSectionConfig) => void; } export function JailSectionPanel({ jailName, section, onChange }: JailSectionPanelProps): React.JSX.Element { const styles = useConfigStyles(); const update = useCallback( (patch: Partial): void => { onChange({ ...section, ...patch }); }, [onChange, section], ); return (
{ update({ enabled: d.checked }); }} aria-label={`Enable jail ${jailName}`} /> { update({ port: d.value || null }); }} /> { update({ filter: d.value || null }); }} /> { const n = parseInt(d.value, 10); update({ maxretry: d.value === "" ? null : isNaN(n) ? null : n }); }} /> { const n = parseInt(d.value, 10); update({ findtime: d.value === "" ? null : isNaN(n) ? null : n }); }} /> { const n = parseInt(d.value, 10); update({ bantime: d.value === "" ? null : isNaN(n) ? null : n }); }} />
Log Paths ({section.logpath.length})
{ update({ logpath: next }); }} placeholder="e.g. /var/log/auth.log" addLabel="Add log path" />
Actions ({section.action.length})
{ update({ action: next }); }} placeholder="e.g. iptables-multiport[name=SSH, port=ssh]" addLabel="Add action" />
{Object.keys(section.extra).length > 0 && ( Extra Settings ({Object.keys(section.extra).length})
{ update({ extra: next }); }} />
)}
); }