From bdeaebd005667fe6975c8222b3dcd6bd868ecbd4 Mon Sep 17 00:00:00 2001 From: Justin Lampley Date: Thu, 9 Dec 2021 18:56:45 -0500 Subject: [PATCH] Merge network device options with default options --- src/api/src/services/MulticastDns/index.ts | 2 +- src/ui/components/UserDefinesList/index.tsx | 4 ++-- src/ui/views/ConfiguratorView/index.tsx | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/api/src/services/MulticastDns/index.ts b/src/api/src/services/MulticastDns/index.ts index 89f3e1c3b..a6569fcaa 100644 --- a/src/api/src/services/MulticastDns/index.ts +++ b/src/api/src/services/MulticastDns/index.ts @@ -90,7 +90,7 @@ export default class MulticastDnsService { if (userDefineKey) { if (match.length === 3) { if (match[2]) { - userDefines.push(UserDefine.Text(userDefineKey, match[2])); + userDefines.push(UserDefine.Text(userDefineKey, match[2], true)); } else { userDefines.push(UserDefine.Boolean(userDefineKey, true)); } diff --git a/src/ui/components/UserDefinesList/index.tsx b/src/ui/components/UserDefinesList/index.tsx index 55bab5982..24112178f 100644 --- a/src/ui/components/UserDefinesList/index.tsx +++ b/src/ui/components/UserDefinesList/index.tsx @@ -118,8 +118,8 @@ const UserDefinesList: FunctionComponent = (props) => { diff --git a/src/ui/views/ConfiguratorView/index.tsx b/src/ui/views/ConfiguratorView/index.tsx index 0665842c0..c7a394929 100644 --- a/src/ui/views/ConfiguratorView/index.tsx +++ b/src/ui/views/ConfiguratorView/index.tsx @@ -361,6 +361,26 @@ const ConfiguratorView: FunctionComponent = (props) => { userDefineOptions: [...deviceOptionsResponse.targetDeviceOptions], } ); + + // if a network device is selected, merge in its options + if (selectedDevice && networkDevices.has(selectedDevice)) { + const networkDevice = networkDevices.get(selectedDevice); + userDefineOptions.userDefineOptions = userDefineOptions.userDefineOptions.map( + (userDefineOption) => { + const networkDeviceOption = networkDevice?.options.find( + (item) => item.key === userDefineOption.key + ); + + const newUserDefineOption = { ...userDefineOption }; + if (networkDeviceOption) { + newUserDefineOption.enabled = networkDeviceOption.enabled; + newUserDefineOption.value = networkDeviceOption.value; + } + return newUserDefineOption; + } + ); + } + setDeviceOptionsFormData(userDefineOptions); }; handleUpdate().catch((err) => {