dont let users add loop node in another loop node for now (#934)

This commit is contained in:
Kerem Yilmaz
2024-10-08 11:56:03 -07:00
committed by GitHub
parent 18cebb21e1
commit 750a3f8deb
4 changed files with 8 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ function EdgeWithAddButton({
size="icon"
className="h-4 w-4 rounded-full transition-all hover:scale-150"
onClick={() => {
const disableLoop = Boolean(sourceNode?.parentId);
setWorkflowPanelState({
active: true,
content: "nodeLibrary",
@@ -63,6 +64,7 @@ function EdgeWithAddButton({
previous: source,
next: target,
parent: sourceNode?.parentId,
disableLoop,
},
});
}}

View File

@@ -27,6 +27,7 @@ function NodeAdderNode({ id, parentId }: NodeProps<NodeAdderNode>) {
className="rounded-full bg-slate-50 p-2"
onClick={() => {
const previous = edges.find((edge) => edge.target === id)?.source;
const disableLoop = Boolean(parentId);
setWorkflowPanelState({
active: true,
content: "nodeLibrary",
@@ -35,6 +36,7 @@ function NodeAdderNode({ id, parentId }: NodeProps<NodeAdderNode>) {
next: id,
parent: parentId,
connectingEdgeType: "default",
disableLoop,
},
});
}}

View File

@@ -106,6 +106,9 @@ function WorkflowNodeLibraryPanel({ onNodeClick, first }: Props) {
</header>
<div className="space-y-2">
{nodeLibraryItems.map((item) => {
if (workflowPanelData?.disableLoop && item.nodeType === "loop") {
return null;
}
return (
<div
key={item.nodeType}

View File

@@ -8,6 +8,7 @@ type WorkflowPanelState = {
next?: string | null;
parent?: string;
connectingEdgeType?: string;
disableLoop?: boolean;
};
};