Skip to content

Commit

Permalink
Merge network device options with default options
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlampley authored and jurgelenas committed Dec 10, 2021
1 parent 48dd7eb commit bdeaebd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/api/src/services/MulticastDns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/UserDefinesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ const UserDefinesList: FunctionComponent<UserDefinesListProps> = (props) => {
<ListItem sx={styles.complimentaryItem}>
<TextField
size="small"
onBlur={onUserDefineValueChange(item.key)}
defaultValue={item.value}
onChange={onUserDefineValueChange(item.key)}
value={item.value}
fullWidth
label={inputLabel(item.key)}
/>
Expand Down
20 changes: 20 additions & 0 deletions src/ui/views/ConfiguratorView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,26 @@ const ConfiguratorView: FunctionComponent<ConfiguratorViewProps> = (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) => {
Expand Down

0 comments on commit bdeaebd

Please sign in to comment.