fix(web): loop & iteration history
This commit is contained in:
@@ -57,7 +57,6 @@ const CanvasToolbar: FC<CanvasToolbarProps> = ({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
labelRender={(props) => {
|
labelRender={(props) => {
|
||||||
console.log('props', props)
|
|
||||||
return `${props.value}%`
|
return `${props.value}%`
|
||||||
}}
|
}}
|
||||||
className="rb:w-20 rb:h-4!"
|
className="rb:w-20 rb:h-4!"
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
|||||||
const [fileList, setFileList] = useState<any[]>([])
|
const [fileList, setFileList] = useState<any[]>([])
|
||||||
const [message, setMessage] = useState<string | undefined>(undefined)
|
const [message, setMessage] = useState<string | undefined>(undefined)
|
||||||
|
|
||||||
console.log('abortRef', abortRef, chatList)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the chat drawer and loads workflow variables from the start node
|
* Opens the chat drawer and loads workflow variables from the start node
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const AddNode: ReactShapeConfig['component'] = ({ node, graph }) => {
|
|||||||
|
|
||||||
// Handle node selection from popover and create new node replacing the add-node placeholder
|
// Handle node selection from popover and create new node replacing the add-node placeholder
|
||||||
const handleNodeSelect = (selectedNodeType: any) => {
|
const handleNodeSelect = (selectedNodeType: any) => {
|
||||||
|
graph.startBatch('add-node');
|
||||||
const parentBBox = node.getBBox();
|
const parentBBox = node.getBBox();
|
||||||
const cycleId = data.cycle;
|
const cycleId = data.cycle;
|
||||||
const horizontalSpacing = 0;
|
const horizontalSpacing = 0;
|
||||||
@@ -76,6 +77,8 @@ const AddNode: ReactShapeConfig['component'] = ({ node, graph }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
graph.stopBatch('add-node');
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
addedEdges.forEach(e => {
|
addedEdges.forEach(e => {
|
||||||
const src = graph.getCellById(e.getSourceCellId());
|
const src = graph.getCellById(e.getSourceCellId());
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ const ConditionNode: ReactShapeConfig['component'] = ({ node }) => {
|
|||||||
{data.type === 'if-else' &&
|
{data.type === 'if-else' &&
|
||||||
<Flex vertical gap={4} className="rb:mt-3!">
|
<Flex vertical gap={4} className="rb:mt-3!">
|
||||||
{data.config?.cases?.defaultValue.map((item: any, index: number) => (
|
{data.config?.cases?.defaultValue.map((item: any, index: number) => (
|
||||||
<div key={index} className={item.expressions.length > 0 ? '' : 'rb:mb-1'}>
|
<div key={index}>
|
||||||
<Flex justify={item.expressions.length > 0 ? "space-between" : 'end'} className="rb:mb-1! rb:leading-4">
|
<Flex justify={item.expressions.length > 0 ? "space-between" : 'end'} className="rb:mb-1! rb:leading-4">
|
||||||
{item.expressions.length > 0 && <span className="rb:text-[#5B6167] rb:text-[10px] rb:pl-1">CASE{index + 1}</span>}
|
{item.expressions.length > 0 && <span className="rb:text-[#5B6167] rb:text-[10px] rb:pl-1">CASE{index + 1}</span>}
|
||||||
<span className="rb:text-[#212332] rb:font-medium rb:text-[12px]">{index === 0 ? 'IF' : `ELIF`}</span>
|
<span className="rb:text-[#212332] rb:font-medium rb:text-[12px]">{index === 0 ? 'IF' : `ELIF`}</span>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const PortClickHandler: React.FC<PortClickHandlerProps> = ({ graph }) => {
|
|||||||
// Handle node selection from popover menu and create new node with edge connection
|
// Handle node selection from popover menu and create new node with edge connection
|
||||||
const handleNodeSelect = (selectedNodeType: any) => {
|
const handleNodeSelect = (selectedNodeType: any) => {
|
||||||
if (!sourceNode || !graph) return;
|
if (!sourceNode || !graph) return;
|
||||||
|
graph.startBatch('add-node');
|
||||||
|
|
||||||
const sourceNodeData = sourceNode.getData();
|
const sourceNodeData = sourceNode.getData();
|
||||||
const sourceNodeType = sourceNodeData?.type;
|
const sourceNodeType = sourceNodeData?.type;
|
||||||
@@ -308,6 +309,7 @@ const PortClickHandler: React.FC<PortClickHandlerProps> = ({ graph }) => {
|
|||||||
if (tgt?.isNode()) tgt.toFront();
|
if (tgt?.isNode()) tgt.toFront();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
graph.stopBatch('add-node');
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
// Clean up temporary element
|
// Clean up temporary element
|
||||||
|
|||||||
@@ -488,6 +488,9 @@ export const useWorkflowGraph = ({
|
|||||||
graphRef.current.cleanHistory()
|
graphRef.current.cleanHistory()
|
||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
|
} else {
|
||||||
|
graphRef.current.enableHistory()
|
||||||
|
graphRef.current.cleanHistory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -526,14 +529,12 @@ export const useWorkflowGraph = ({
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
beforeAddCommand(_event, args: any) {
|
beforeAddCommand(_event, args: any) {
|
||||||
const event = args?.key ? `cell:change:${args.key}` : _event;
|
const event = args?.key ? `cell:change:${args.key}` : _event;
|
||||||
if (event.startsWith('cell:change:') &&
|
const allowed = ['cell:added', 'cell:removed', 'cell:change:position', 'cell:change:source', 'cell:change:target'];
|
||||||
event !== 'cell:change:position' &&
|
if (!allowed.includes(event)) return false;
|
||||||
event !== 'cell:change:source' &&
|
|
||||||
event !== 'cell:change:target') return false;
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
graphRef.current.on('history:change', ({ cmds }: { cmds: Command[] }) => {
|
graphRef.current.on('history:change', () => {
|
||||||
setCanUndo(graphRef.current?.canUndo() ?? false)
|
setCanUndo(graphRef.current?.canUndo() ?? false)
|
||||||
setCanRedo(graphRef.current?.canRedo() ?? false)
|
setCanRedo(graphRef.current?.canRedo() ?? false)
|
||||||
})
|
})
|
||||||
@@ -753,8 +754,6 @@ export const useWorkflowGraph = ({
|
|||||||
// Find corresponding parent node
|
// Find corresponding parent node
|
||||||
const parentNode = nodes?.find(n => n.id === nodeData.cycle);
|
const parentNode = nodes?.find(n => n.id === nodeData.cycle);
|
||||||
if (parentNode) {
|
if (parentNode) {
|
||||||
// Use removeChild method to delete child node
|
|
||||||
parentNode.removeChild(nodeToDelete);
|
|
||||||
parentNodesToUpdate.push(parentNode);
|
parentNodesToUpdate.push(parentNode);
|
||||||
}
|
}
|
||||||
// Add child node to deletion list
|
// Add child node to deletion list
|
||||||
@@ -782,6 +781,12 @@ export const useWorkflowGraph = ({
|
|||||||
|
|
||||||
// Delete all collected nodes and edges
|
// Delete all collected nodes and edges
|
||||||
if (cells.length > 0) {
|
if (cells.length > 0) {
|
||||||
|
graphRef.current?.startBatch('delete');
|
||||||
|
// Remove parent-child relationships before removeCells
|
||||||
|
parentNodesToUpdate.forEach(parentNode => {
|
||||||
|
cells.filter(c => c.isNode() && (c as Node).getData()?.cycle === parentNode.getData()?.id)
|
||||||
|
.forEach(child => parentNode.removeChild(child));
|
||||||
|
});
|
||||||
graphRef.current?.removeCells(cells);
|
graphRef.current?.removeCells(cells);
|
||||||
|
|
||||||
// If parent is iteration/loop and only cycle-start remains, add add-node connected to it
|
// If parent is iteration/loop and only cycle-start remains, add add-node connected to it
|
||||||
@@ -818,6 +823,7 @@ export const useWorkflowGraph = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
graphRef.current?.stopBatch('delete');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export const isSubExprSet = (sub: any) => {
|
|||||||
* Uses the same per-expression height logic as getConditionNodeCasePortY.
|
* Uses the same per-expression height logic as getConditionNodeCasePortY.
|
||||||
*/
|
*/
|
||||||
export const calcConditionNodeTotalHeight = (cases: any[]) => {
|
export const calcConditionNodeTotalHeight = (cases: any[]) => {
|
||||||
|
if (!cases?.length) return conditionNodeHeight;
|
||||||
const casesHeight = cases.reduce((acc: number, c: any) => {
|
const casesHeight = cases.reduce((acc: number, c: any) => {
|
||||||
const exprs = c?.expressions ?? [];
|
const exprs = c?.expressions ?? [];
|
||||||
const n = exprs.length;
|
const n = exprs.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user