From c2986aa3f1863994130432a4eadf87ff462fc7cc Mon Sep 17 00:00:00 2001 From: Adam Shiervani Date: Tue, 20 May 2025 14:23:09 +0200 Subject: [PATCH] refactor(ui): enhance Modal and network settings components - Add stable scrollbar gutter to Modal component - Refactor custom domain input handling and layout adjustments --- ui/src/components/Modal.tsx | 4 +- .../routes/devices.$id.settings.network.tsx | 39 +++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ui/src/components/Modal.tsx b/ui/src/components/Modal.tsx index 1772011..d9433df 100644 --- a/ui/src/components/Modal.tsx +++ b/ui/src/components/Modal.tsx @@ -20,7 +20,9 @@ const Modal = React.memo(function Modal({ transition className="fixed inset-0 bg-gray-500/75 transition-opacity data-closed:opacity-0 data-enter:duration-500 data-leave:duration-200 data-enter:ease-out data-leave:ease-in dark:bg-slate-900/90" /> -
+
{/* TODO: This doesn't work well with other-sessions */}
{ + send("getNetworkState", {}, resp => { + if ("error" in resp) return; + console.log(resp.result); + setNetworkState(resp.result as NetworkState); + }); + }, [send, setNetworkState]); + const setNetworkSettingsRemote = useCallback( (settings: NetworkSettings) => { setNetworkSettingsLoaded(false); @@ -130,21 +138,14 @@ export default function SettingsNetworkRoute() { // We need to update the firstNetworkSettings ref to the new settings so we can use it to determine if the settings have changed firstNetworkSettings.current = resp.result as NetworkSettings; setNetworkSettings(resp.result as NetworkSettings); + getNetworkState(); setNetworkSettingsLoaded(true); notifications.success("Network settings saved"); }); }, - [send], + [getNetworkState, send], ); - const getNetworkState = useCallback(() => { - send("getNetworkState", {}, resp => { - if ("error" in resp) return; - console.log(resp.result); - setNetworkState(resp.result as NetworkState); - }); - }, [send, setNetworkState]); - const handleRenewLease = useCallback(() => { send("renewDHCPLease", {}, resp => { if ("error" in resp) { @@ -255,7 +256,7 @@ export default function SettingsNetworkRoute() {
-
+
{selectedDomainOption === "custom" && ( -
- + setCustomDomain(e.target.value)} - /> -
)}