Fixed IO Modal updates

This commit is contained in:
Lucas Oliveira 2024-04-02 02:24:03 +02:00
commit 42ea5c8e8e

View file

@ -59,13 +59,11 @@ export default function IOModal({
if (!chatInput && !chatOutput) { if (!chatInput && !chatOutput) {
if (inputs.length > 0) { if (inputs.length > 0) {
return inputs[0]; return inputs[0];
} } else {
else {
return outputs[0]; return outputs[0];
} }
} } else {
else { return undefined;
return undefined
} }
} }
@ -116,12 +114,12 @@ export default function IOModal({
} }
useEffect(() => { useEffect(() => {
if(selectedTab!==2) setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0);
}, [allNodes]); }, [allNodes.length]);
useEffect(() => { useEffect(() => {
setSelectedViewField(startView()); setSelectedViewField(startView());
},[open]) }, [open]);
return ( return (
<BaseModal <BaseModal
@ -144,7 +142,7 @@ export default function IOModal({
</BaseModal.Header> </BaseModal.Header>
<BaseModal.Content> <BaseModal.Content>
<div className="flex h-full flex-col "> <div className="flex h-full flex-col ">
<div className="flex-max-width mt-2 h-full"> <div className="flex-max-width h-full">
{selectedTab !== 0 && ( {selectedTab !== 0 && (
<div <div
className={cn( className={cn(
@ -320,12 +318,14 @@ export default function IOModal({
)} )}
> >
<div className="font-xl flex items-center justify-center gap-3 font-semibold"> <div className="font-xl flex items-center justify-center gap-3 font-semibold">
{(haveChat && <button onClick={() => setSelectedViewField(undefined)}> {haveChat && (
<IconComponent <button onClick={() => setSelectedViewField(undefined)}>
name={"ArrowLeft"} <IconComponent
className="h-6 w-6" name={"ArrowLeft"}
></IconComponent> className="h-6 w-6"
</button>)} ></IconComponent>
</button>
)}
{ {
nodes.find((node) => node.id === selectedViewField.id) nodes.find((node) => node.id === selectedViewField.id)
?.data.node.display_name ?.data.node.display_name
@ -376,8 +376,8 @@ export default function IOModal({
</div> </div>
</div> </div>
</BaseModal.Content> </BaseModal.Content>
<BaseModal.Footer> {!haveChat ? (
{!haveChat && ( <BaseModal.Footer>
<div className="flex w-full justify-end pt-2"> <div className="flex w-full justify-end pt-2">
<Button <Button
variant={"outline"} variant={"outline"}
@ -396,8 +396,10 @@ export default function IOModal({
Run Flow Run Flow
</Button> </Button>
</div> </div>
)} </BaseModal.Footer>
</BaseModal.Footer> ) : (
<></>
)}
</BaseModal> </BaseModal>
); );
} }