From e4a5eac6765af18fd9b393d34afacddc9e2e435c Mon Sep 17 00:00:00 2001 From: Jaime Idolpx Date: Thu, 11 Jun 2026 22:20:14 -0400 Subject: [PATCH] feat(DeviceDetailOverlay): conditionally render UI elements based on device type and improve cache handling --- src/app/components/DeviceDetailOverlay.tsx | 255 +++++++++++---------- 1 file changed, 132 insertions(+), 123 deletions(-) diff --git a/src/app/components/DeviceDetailOverlay.tsx b/src/app/components/DeviceDetailOverlay.tsx index 04e1969..31263ef 100644 --- a/src/app/components/DeviceDetailOverlay.tsx +++ b/src/app/components/DeviceDetailOverlay.tsx @@ -311,24 +311,26 @@ export default function DeviceDetailOverlay({
-
- - -
+ > +
+ +
+ )}
@@ -350,104 +352,21 @@ export default function DeviceDetailOverlay({ />
-
- -
- { - const path = getDevicePath(); - updateDeviceSetting([...path, 'base_url'], e.target.value); - }} - className="flex-1 px-3 py-2 border border-neutral-300 rounded-lg" - /> - - -
-
- -
- -
- { - const newUrl = e.target.value; - const devicePath = getDevicePath(); - const newConfig = JSON.parse(JSON.stringify(config)); - let dev = newConfig; - for (const k of devicePath) dev = dev[k]; - if (isOutsideBase(newUrl, dev.base_url || '')) clearBaseAndCache(dev); - dev.url = newUrl; - setConfig(newConfig); - }} - className="flex-1 px-3 py-2 border border-neutral-300 rounded-lg" - /> - - -
- - {mediaSetFiles && ( -
- -
- )} -
- - {(deviceData.cache !== undefined || - (deviceData.base_url ?? '').includes('://') || - (deviceData.url ?? '').includes('://')) && ( + {!device.physical && <>
- +
{ const path = getDevicePath(); - updateDeviceSetting([...path, 'cache'], e.target.value); + updateDeviceSetting([...path, 'base_url'], e.target.value); }} className="flex-1 px-3 py-2 border border-neutral-300 rounded-lg" />
- )} + +
+ +
+ { + const newUrl = e.target.value; + const devicePath = getDevicePath(); + const newConfig = JSON.parse(JSON.stringify(config)); + let dev = newConfig; + for (const k of devicePath) dev = dev[k]; + if (isOutsideBase(newUrl, dev.base_url || '')) clearBaseAndCache(dev); + dev.url = newUrl; + setConfig(newConfig); + }} + className="flex-1 px-3 py-2 border border-neutral-300 rounded-lg" + /> + + +
+ + {mediaSetFiles && ( +
+ +
+ )} +
+ + {(deviceData.cache !== undefined || + (deviceData.base_url ?? '').includes('://') || + (deviceData.url ?? '').includes('://')) && ( +
+ +
+ { + const path = getDevicePath(); + updateDeviceSetting([...path, 'cache'], e.target.value); + }} + className="flex-1 px-3 py-2 border border-neutral-300 rounded-lg" + /> + + +
+
+ )} + } {deviceData.mode !== undefined && (
-
- {([0, 1] as const).map((val, i) => ( - - ))} -
+ {device.physical + ? + {(deviceData.mode ?? 0) === 0 ? 'Read Only' : 'Write Enabled'} + + :
+ {([0, 1] as const).map((val, i) => ( + + ))} +
+ }
)}