mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-01 00:05:43 +08:00
### What problem does this PR solve? Fix: Unable to reconnect after deleting the connection between begin and parser #13868 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -18,10 +18,20 @@ export function CommonHandle({
|
||||
const { visible, hideModal, showModal } = useSetModalState();
|
||||
const { canShowDropdown, setActiveDropdown, clearActiveDropdown } =
|
||||
useDropdownManager();
|
||||
const { hasChildNode } = useGraphStore((state) => state);
|
||||
const { hasDownstreamNode, hasUpstreamNode } = useGraphStore(
|
||||
(state) => state,
|
||||
);
|
||||
const isPipeline = useIsPipeline();
|
||||
|
||||
const isConnectable = !(isPipeline && hasChildNode(nodeId)); // Using useMemo will cause isConnectable to not be updated when the subsequent connection line is deleted
|
||||
let isConnectable = true;
|
||||
|
||||
if (isPipeline) {
|
||||
if (props.type === 'source') {
|
||||
isConnectable = !hasDownstreamNode(nodeId);
|
||||
} else if (props.type === 'target') {
|
||||
isConnectable = !hasUpstreamNode(nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
|
||||
@@ -692,6 +692,7 @@ export const RestrictedUpstreamMap = {
|
||||
[Operator.Loop]: [Operator.Begin],
|
||||
[Operator.LoopStart]: [Operator.Begin],
|
||||
[Operator.ExitLoop]: [Operator.Begin],
|
||||
[Operator.PDFGenerator]: [Operator.Begin],
|
||||
};
|
||||
|
||||
export const NodeMap = {
|
||||
|
||||
@@ -115,7 +115,8 @@ export type RFState = {
|
||||
) => void; // Deleting a condition of a classification operator will delete the related edge
|
||||
findAgentToolNodeById: (id: string | null) => string | undefined;
|
||||
selectNodeIds: (nodeIds: string[]) => void;
|
||||
hasChildNode: (nodeId: string) => boolean;
|
||||
hasDownstreamNode: (nodeId: string) => boolean;
|
||||
hasUpstreamNode: (nodeId: string) => boolean;
|
||||
};
|
||||
|
||||
// this is our useStore hook that we can use in our components to get parts of the store and call actions
|
||||
@@ -469,7 +470,7 @@ const useGraphStore = create<RFState>()(
|
||||
const { updateNodeForm, edges, getOperatorTypeFromId } = get();
|
||||
if (sourceHandle) {
|
||||
// A handle will connect to multiple downstream nodes
|
||||
let currentHandleTargets = edges
|
||||
const currentHandleTargets = edges
|
||||
.filter(
|
||||
(x) =>
|
||||
x.source === source &&
|
||||
@@ -647,10 +648,14 @@ const useGraphStore = create<RFState>()(
|
||||
})),
|
||||
);
|
||||
},
|
||||
hasChildNode: (nodeId) => {
|
||||
hasDownstreamNode: (nodeId) => {
|
||||
const { edges } = get();
|
||||
return edges.some((edge) => edge.source === nodeId);
|
||||
},
|
||||
hasUpstreamNode: (nodeId) => {
|
||||
const { edges } = get();
|
||||
return edges.some((edge) => edge.target === nodeId);
|
||||
},
|
||||
})),
|
||||
{ name: 'graph', trace: true },
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user