mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-05 18:15:06 +08:00
### What problem does this PR solve? Feat: Filter the query variable drop-down box options by type #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -232,8 +232,15 @@ function useAddToolNode() {
|
||||
return { addToolNode };
|
||||
}
|
||||
|
||||
function isBottomSubAgent(type: string, position: Position) {
|
||||
return (
|
||||
(type === Operator.Agent && position === Position.Bottom) ||
|
||||
type === Operator.Tool
|
||||
);
|
||||
}
|
||||
|
||||
export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
|
||||
const { edges, nodes, addEdge, addNode, getNode } = useGraphStore(
|
||||
const { edges, nodes, addEdge, addNode, getNode, updateNode } = useGraphStore(
|
||||
(state) => state,
|
||||
);
|
||||
const getNodeName = useGetNodeName();
|
||||
@ -291,6 +298,18 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
|
||||
if (node && node.parentId) {
|
||||
newNode.parentId = node.parentId;
|
||||
newNode.extent = 'parent';
|
||||
const parentNode = getNode(node.parentId);
|
||||
if (parentNode && !isBottomSubAgent(type, params.position)) {
|
||||
const MoveRightDistance = 310;
|
||||
updateNode({
|
||||
...parentNode,
|
||||
width: (parentNode.width || 0) + MoveRightDistance,
|
||||
position: {
|
||||
x: parentNode.position.x + MoveRightDistance / 2,
|
||||
y: parentNode.position.y,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (type === Operator.Iteration) {
|
||||
@ -377,6 +396,7 @@ export function useAddNode(reactFlowInstance?: ReactFlowInstance<any, any>) {
|
||||
initializeOperatorParams,
|
||||
nodes,
|
||||
reactFlowInstance,
|
||||
updateNode,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user