dont let users add loop node in another loop node for now (#934)
This commit is contained in:
@@ -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,
|
||||
},
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -8,6 +8,7 @@ type WorkflowPanelState = {
|
||||
next?: string | null;
|
||||
parent?: string;
|
||||
connectingEdgeType?: string;
|
||||
disableLoop?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user