fix(setup): hide transport-irrelevant printer fields (USB vs Network)
The wizard rendered every configField in a flat loop, so the USB device path showed under a Network printer (and host/port would show under USB) — the form could mislead. Add a transport-aware filter (mirroring the existing pulseMs/inputRestingHigh skip): when Connection=USB hide host/port/httpPort, otherwise hide devicePath. Verified live (Playwright): each transport shows only its own fields and toggling swaps them. Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
@@ -603,6 +603,15 @@ function DeviceForm({
|
|||||||
// sections below (a relay setting and an input setting, respectively), so
|
// sections below (a relay setting and an input setting, respectively), so
|
||||||
// skip them here to avoid rendering them twice. See OutputEditor/InputEditor.
|
// skip them here to avoid rendering them twice. See OutputEditor/InputEditor.
|
||||||
.filter((f) => !(isController && (f.key === "pulseMs" || f.key === "inputRestingHigh")))
|
.filter((f) => !(isController && (f.key === "pulseMs" || f.key === "inputRestingHigh")))
|
||||||
|
// Printer transport is exclusive: when Connection = USB the network fields
|
||||||
|
// (host/port/status-page) don't apply, and vice-versa the USB device path
|
||||||
|
// doesn't. Hide the irrelevant side so the form can't mislead (e.g. a USB
|
||||||
|
// path lingering under a Network printer). Driven by config.transport.
|
||||||
|
.filter((f) => {
|
||||||
|
const transport = String(config.transport ?? "tcp-ip");
|
||||||
|
if (transport === "usb") return !["host", "port", "httpPort"].includes(f.key);
|
||||||
|
return f.key !== "devicePath";
|
||||||
|
})
|
||||||
.map((f) =>
|
.map((f) =>
|
||||||
f.type === "boolean" ? (
|
f.type === "boolean" ? (
|
||||||
// Boolean config field → a real checkbox (stores a true/false boolean, not
|
// Boolean config field → a real checkbox (stores a true/false boolean, not
|
||||||
|
|||||||
Reference in New Issue
Block a user