From 84e87828cdd888c3cdd6c0cd78dda70aede974c7 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 6 Mar 2023 17:54:40 -0300 Subject: [PATCH] removed connection of to string and boolean --- .../components/parameterComponent/index.tsx | 204 +++++++++--------- 1 file changed, 107 insertions(+), 97 deletions(-) diff --git a/langflow/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/langflow/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 1fd43647f..f3b8b8a96 100644 --- a/langflow/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/langflow/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -1,8 +1,6 @@ import { Handle, Position, useUpdateNodeInternals } from "reactflow"; import Tooltip from "../../../../components/TooltipComponent"; -import { - isValidConnection, -} from "../../../../utils"; +import { classNames, isValidConnection } from "../../../../utils"; import { useContext, useEffect, useRef, useState } from "react"; import InputComponent from "../../../../components/inputComponent"; import ToggleComponent from "../../../../components/toggleComponent"; @@ -12,101 +10,113 @@ import { typesContext } from "../../../../contexts/typesContext"; import { ParameterComponentType } from "../../../../types/components"; export default function ParameterComponent({ - left, - id, - data, - tooltipTitle, - title, - color, - type, - name = "", - required = false, -}:ParameterComponentType) { - const ref = useRef(null); - const updateNodeInternals = useUpdateNodeInternals(); - const [position, setPosition] = useState(0); - useEffect(() => { - if (ref.current && ref.current.offsetTop && ref.current.clientHeight) { - setPosition(ref.current.offsetTop + ref.current.clientHeight / 2); - updateNodeInternals(data.id); - } - }, [data.id, ref, updateNodeInternals]); + left, + id, + data, + tooltipTitle, + title, + color, + type, + name = "", + required = false, +}: ParameterComponentType) { + const ref = useRef(null); + const updateNodeInternals = useUpdateNodeInternals(); + const [position, setPosition] = useState(0); + useEffect(() => { + if (ref.current && ref.current.offsetTop && ref.current.clientHeight) { + setPosition(ref.current.offsetTop + ref.current.clientHeight / 2); + updateNodeInternals(data.id); + } + }, [data.id, ref, updateNodeInternals]); - useEffect(() => { - updateNodeInternals(data.id); - }, [data.id, position, updateNodeInternals]); + useEffect(() => { + updateNodeInternals(data.id); + }, [data.id, position, updateNodeInternals]); - const [enabled, setEnabled] = useState(data.node.template[name]?.value ?? false); - const {reactFlowInstance} = useContext(typesContext); - let disabled = reactFlowInstance?.getEdges().some((e) => (e.targetHandle === id)) ?? false; + const [enabled, setEnabled] = useState( + data.node.template[name]?.value ?? false + ); + const { reactFlowInstance } = useContext(typesContext); + let disabled = + reactFlowInstance?.getEdges().some((e) => e.targetHandle === id) ?? false; - return ( -
- <> -
{title}{required ? " *" : ""}
- - - isValidConnection(connection,reactFlowInstance) - } - className={ - (left ? "-ml-0.5 " : "-mr-0.5 ") + - "w-3 h-3 rounded-full border-2 bg-white dark:bg-gray-800" - } - style={{ - borderColor: color, - top: position, - }} - > - - {left === true && type === "str" ? ( -
- {data.node.template[name].list ? - { - data.node.template[name].value = t; - }} - /> - : - data.node.template[name].multiline ? ( - { - data.node.template[name].value = t; - }} - /> - ) : - { - data.node.template[name].value = t; - }} - /> - } - -
- ) : left === true && type === "bool" ? ( -
- { - data.node.template[name].value = t; - setEnabled(t); - }} - /> -
- ) : ( - <> - )} - -
- ); + return ( +
+ <> +
+ {title} + {required ? " *" : ""} +
+ + + isValidConnection(connection, reactFlowInstance) + } + className={classNames( + (left ? "-ml-0.5 " : "-mr-0.5 "), + "w-3 h-3 rounded-full border-2 bg-white dark:bg-gray-800",left && (type==="str" || type==="bool")?"hidden":"" + )} + style={{ + borderColor: color, + top: position, + }} + > + + {left === true && type === "str" ? ( +
+ {data.node.template[name].list ? ( + { + data.node.template[name].value = t; + }} + /> + ) : data.node.template[name].multiline ? ( + { + data.node.template[name].value = t; + }} + /> + ) : ( + { + data.node.template[name].value = t; + }} + /> + )} +
+ ) : left === true && type === "bool" ? ( +
+ { + data.node.template[name].value = t; + setEnabled(t); + }} + /> +
+ ) : ( + <> + )} + +
+ ); }