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

View File

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

View File

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

View File

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