Skip to content

Commit

Permalink
fix: resolve issue with adding global variable when input is connected (
Browse files Browse the repository at this point in the history
#4289)

* fix: prevent add global variable when inpiut is connected

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
  • Loading branch information
3 people authored and joaoguilhermeS committed Nov 7, 2024
1 parent c9f48c7 commit 253e71a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ export default function GlobalVariableModal({
initialData,
open: myOpen,
setOpen: mySetOpen,
disabled = false,
}: {
children?: JSX.Element;
asChild?: boolean;
initialData?: GlobalVariable;
open?: boolean;
setOpen?: (a: boolean | ((o?: boolean) => boolean)) => void;
disabled?: boolean;
}): JSX.Element {
const [key, setKey] = useState(initialData?.name ?? "");
const [value, setValue] = useState(initialData?.value ?? "");
Expand Down Expand Up @@ -122,6 +124,7 @@ export default function GlobalVariableModal({
setOpen={setOpen}
size="x-small"
onSubmit={submitForm}
disable={disabled}
>
<BaseModal.Header
description={
Expand All @@ -138,7 +141,9 @@ export default function GlobalVariableModal({
aria-hidden="true"
/>
</BaseModal.Header>
<BaseModal.Trigger asChild={asChild}>{children}</BaseModal.Trigger>
<BaseModal.Trigger disable={disabled} asChild={asChild}>
{children}
</BaseModal.Trigger>
<BaseModal.Content>
<div className="flex h-full w-full flex-col gap-4 align-middle">
<Label>Variable Name</Label>
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/components/inputComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ export default function InputComponent({
className={cn(
password && selectedOption === "" ? "right-8" : "right-0",
"absolute inset-y-0 flex items-center pr-2.5",
disabled && "cursor-not-allowed opacity-50",
)}
>
<button
disabled={disabled}
onClick={(e) => {
if (disabled) return;
setShowOptions(!showOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function InputGlobalComponent({
optionsPlaceholder={"Global Variables"}
optionsIcon="Globe"
optionsButton={
<GlobalVariableModal>
<GlobalVariableModal disabled={disabled}>
<CommandItem value="doNotFilter-addNewVariable">
<ForwardedIconComponent
name="Plus"
Expand Down

0 comments on commit 253e71a

Please sign in to comment.