From ec78119b3a52f2a42fb6a6f0198b29f82b0f145f Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Thu, 20 Mar 2025 17:06:26 -0300 Subject: [PATCH] fix: apply field name automatically to Apply to Fields in global variable (#7195) * added referenceField to GlobalVariableModal to show the field that created * Added the display name of the input to global variable modal --------- Co-authored-by: cristhianzl --- .../GlobalVariableModal/GlobalVariableModal.tsx | 7 ++++++- .../components/inputGlobalComponent/index.tsx | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) 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) => (