diff --git a/src/frontend/src/components/core/GlobalVariableModal/GlobalVariableModal.tsx b/src/frontend/src/components/core/GlobalVariableModal/GlobalVariableModal.tsx index 6932af455..000556072 100644 --- a/src/frontend/src/components/core/GlobalVariableModal/GlobalVariableModal.tsx +++ b/src/frontend/src/components/core/GlobalVariableModal/GlobalVariableModal.tsx @@ -24,6 +24,7 @@ export default function GlobalVariableModal({ children, asChild, initialData, + referenceField, open: myOpen, setOpen: mySetOpen, disabled = false, @@ -31,6 +32,7 @@ export default function GlobalVariableModal({ children?: JSX.Element; asChild?: boolean; initialData?: GlobalVariable; + referenceField?: string; open?: boolean; setOpen?: (a: boolean | ((o?: boolean) => boolean)) => void; disabled?: boolean; @@ -61,6 +63,9 @@ export default function GlobalVariableModal({ setAvailableFields( sortByName(fields.concat(initialData?.default_fields ?? [])), ); + if (referenceField && fields.includes(referenceField)) { + setFields([referenceField]); + } } }, [globalVariables, componentFields, initialData]); @@ -106,7 +111,7 @@ export default function GlobalVariableModal({ } function submitForm() { - if (!initialData) { + if (!initialData || !initialData.id) { handleSaveVariable(); } else { updateVariable({ diff --git a/src/frontend/src/components/core/parameterRenderComponent/components/inputGlobalComponent/index.tsx b/src/frontend/src/components/core/parameterRenderComponent/components/inputGlobalComponent/index.tsx index 88ec8d1fa..12856599e 100644 --- a/src/frontend/src/components/core/parameterRenderComponent/components/inputGlobalComponent/index.tsx +++ b/src/frontend/src/components/core/parameterRenderComponent/components/inputGlobalComponent/index.tsx @@ -77,7 +77,18 @@ export default function InputGlobalComponent({ options={globalVariables?.map((variable) => variable.name) ?? []} optionsPlaceholder={"Global Variables"} optionsIcon="Globe" - optionsButton={} + optionsButton={ + + + + + } optionButton={(option) => (