Narrow jail config types with explicit union values
This commit is contained in:
@@ -34,11 +34,14 @@ import {
|
||||
import { ApiError } from "../../api/client";
|
||||
import type {
|
||||
AddLogPathRequest,
|
||||
BackendType,
|
||||
DNSMode,
|
||||
InactiveJail,
|
||||
JailConfig,
|
||||
JailConfigUpdate,
|
||||
JailValidationIssue,
|
||||
JailValidationResult,
|
||||
LogEncoding,
|
||||
} from "../../types/config";
|
||||
import { useAutoSave } from "../../hooks/useAutoSave";
|
||||
import { useConfigActiveStatus } from "../../hooks/useConfigActiveStatus";
|
||||
@@ -127,9 +130,9 @@ function JailConfigDetail({
|
||||
const [ignoreRegex, setIgnoreRegex] = useState<string[]>(jail.ignore_regex);
|
||||
const [logPaths, setLogPaths] = useState<string[]>(jail.log_paths);
|
||||
const [datePattern, setDatePattern] = useState(jail.date_pattern ?? "");
|
||||
const [dnsMode, setDnsMode] = useState(jail.use_dns);
|
||||
const [backend, setBackend] = useState(jail.backend);
|
||||
const [logEncoding, setLogEncoding] = useState(jail.log_encoding);
|
||||
const [dnsMode, setDnsMode] = useState<DNSMode>(jail.use_dns);
|
||||
const [backend, setBackend] = useState<BackendType>(jail.backend);
|
||||
const [logEncoding, setLogEncoding] = useState<LogEncoding>(jail.log_encoding);
|
||||
const [prefRegex, setPrefRegex] = useState(jail.prefregex);
|
||||
const [deletingPath, setDeletingPath] = useState<string | null>(null);
|
||||
const [newLogPath, setNewLogPath] = useState("");
|
||||
@@ -302,7 +305,7 @@ function JailConfigDetail({
|
||||
value={backend}
|
||||
disabled={readOnly}
|
||||
onChange={(_e, d) => {
|
||||
setBackend(d.value);
|
||||
setBackend(d.value as BackendType);
|
||||
}}
|
||||
>
|
||||
{BACKENDS.map((b) => (
|
||||
@@ -315,7 +318,7 @@ function JailConfigDetail({
|
||||
value={logEncoding.toLowerCase()}
|
||||
disabled={readOnly}
|
||||
onChange={(_e, d) => {
|
||||
setLogEncoding(d.value);
|
||||
setLogEncoding(d.value as LogEncoding);
|
||||
}}
|
||||
>
|
||||
{LOG_ENCODINGS.map((e) => (
|
||||
@@ -350,7 +353,7 @@ function JailConfigDetail({
|
||||
value={dnsMode}
|
||||
disabled={readOnly}
|
||||
onChange={(_e, d) => {
|
||||
setDnsMode(d.value);
|
||||
setDnsMode(d.value as DNSMode);
|
||||
}}
|
||||
>
|
||||
<option value="yes">yes — resolve hostnames</option>
|
||||
|
||||
Reference in New Issue
Block a user