Generated output parameters and disable one of them if the other is in use

This commit is contained in:
Lucas Oliveira 2023-03-31 09:04:24 -03:00
commit 876a691004
2 changed files with 117 additions and 107 deletions

View file

@ -46,12 +46,14 @@ export default function ParameterComponent({
const { reactFlowInstance } = useContext(typesContext);
let disabled =
reactFlowInstance?.getEdges().some((e) => e.targetHandle === id) ?? false;
let disabledSource =
reactFlowInstance?.getEdges().some((e) => e.sourceHandle !== id && e.source === data.id) ?? false;
const { save } = useContext(TabsContext);
return (
<div
ref={ref}
className="w-full flex flex-wrap justify-between items-center bg-gray-50 dark:bg-gray-800 dark:text-white mt-1 px-5 py-2"
className={"w-full flex flex-wrap justify-between items-center dark:text-white mt-1 px-5 py-2 " + (!left ? (disabledSource ? "bg-gray-100 dark:bg-gray-700 text-gray-500": "bg-gray-50 dark:bg-gray-800") : "bg-gray-50 dark:bg-gray-800")}
>
<>
<div className="text-sm truncate">
@ -76,8 +78,8 @@ export default function ParameterComponent({
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 ? "-ml-0.5 " : ("-mr-0.5 " + (disabledSource ? "pointer-events-none border-gray-400 " : "")),
"w-3 h-3 rounded-full border-2 bg-white dark:bg-gray-800",
)}
style={{
borderColor: color,