From ad391cd567fed46da15e3ab3bd3fd42e7c512bf8 Mon Sep 17 00:00:00 2001
From: Brady Veal <61876166+bveal52@users.noreply.github.com>
Date: Mon, 16 Dec 2024 14:48:48 -0500
Subject: [PATCH 1/3] fix copy default UI
---
apps/frontend/app/components/Parameter.tsx | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/apps/frontend/app/components/Parameter.tsx b/apps/frontend/app/components/Parameter.tsx
index 0fc16e92..3f12cc80 100644
--- a/apps/frontend/app/components/Parameter.tsx
+++ b/apps/frontend/app/components/Parameter.tsx
@@ -43,8 +43,21 @@ const Parameter = ({ form, type, index, confirmedValues, setConfirmedValues, ...
if (form.values.hyperparameters[index].values && (form.values.hyperparameters[index].values.length != 1 && form.values.hyperparameters[index].values[0] != '')) {
updateConfirmedValues(index, form.values.hyperparameters[index].values);
}
+
+ if (form.values.hyperparameters[index].default && form.values.hyperparameters[index].default != -1) {
+ setUseDefault(true);
+ }
+ else {
+ setUseDefault(false);
+ }
}, []);
+ useEffect(() => {
+ if (form.values.hyperparameters[index].useDefault == false) {
+ form.setFieldValue(`hyperparameters.${index}.default`, -1);
+ }
+ }, [useDefault]);
+
const handleRemove = () => {
form.removeListItem('hyperparameters', index);
@@ -54,7 +67,14 @@ const Parameter = ({ form, type, index, confirmedValues, setConfirmedValues, ...
const handleSwitchChange = () => {
setUseDefault(!useDefault);
- form.setFieldValue(`hyperparameters.${index}.useDefault`, !useDefault);
+ if(`hyperparameters.${index}.default` != -1){
+ form.setFieldValue(`hyperparameters.${index}.useDefault`, !useDefault);
+ }
+ else {
+ form.setFieldValue(`hyperparameters.${index}.useDefault`, false);
+ }
+
+
};
return (
@@ -89,7 +109,7 @@ const Parameter = ({ form, type, index, confirmedValues, setConfirmedValues, ...
)}