mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: test buildNodesAndEdgesFromDSLComponents (#940)
### What problem does this PR solve? feat: test buildNodesAndEdgesFromDSLComponents #918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -8,7 +8,6 @@ import ReactFlow, {
|
||||
OnConnect,
|
||||
OnEdgesChange,
|
||||
OnNodesChange,
|
||||
Position,
|
||||
addEdge,
|
||||
applyEdgeChanges,
|
||||
applyNodeChanges,
|
||||
@ -19,47 +18,24 @@ import { NodeContextMenu, useHandleNodeContextMenu } from './context-menu';
|
||||
|
||||
import FlowDrawer from '../flow-drawer';
|
||||
import { useHandleDrop, useShowDrawer } from '../hooks';
|
||||
import { initialEdges, initialNodes } from '../mock';
|
||||
import { getLayoutedElements } from '../utils';
|
||||
import { TextUpdaterNode } from './node';
|
||||
|
||||
const nodeTypes = { textUpdater: TextUpdaterNode };
|
||||
|
||||
const initialNodes = [
|
||||
{
|
||||
sourcePosition: Position.Left,
|
||||
targetPosition: Position.Right,
|
||||
id: 'node-1',
|
||||
type: 'textUpdater',
|
||||
position: { x: 400, y: 100 },
|
||||
data: { label: 123 },
|
||||
},
|
||||
{
|
||||
sourcePosition: Position.Right,
|
||||
targetPosition: Position.Left,
|
||||
id: '1',
|
||||
data: { label: 'Hello' },
|
||||
position: { x: 0, y: 50 },
|
||||
type: 'input',
|
||||
},
|
||||
{
|
||||
sourcePosition: Position.Right,
|
||||
targetPosition: Position.Left,
|
||||
id: '2',
|
||||
data: { label: 'World' },
|
||||
position: { x: 200, y: 50 },
|
||||
},
|
||||
];
|
||||
|
||||
const initialEdges = [
|
||||
{ id: '1-2', source: '1', target: '2', label: 'to the', type: 'step' },
|
||||
];
|
||||
|
||||
interface IProps {
|
||||
sideWidth: number;
|
||||
}
|
||||
|
||||
function FlowCanvas({ sideWidth }: IProps) {
|
||||
const [nodes, setNodes] = useState<Node[]>(initialNodes);
|
||||
const [edges, setEdges] = useState<Edge[]>(initialEdges);
|
||||
const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(
|
||||
initialNodes,
|
||||
initialEdges,
|
||||
'LR',
|
||||
);
|
||||
const [nodes, setNodes] = useState<Node[]>(layoutedNodes);
|
||||
const [edges, setEdges] = useState<Edge[]>(layoutedEdges);
|
||||
const { ref, menu, onNodeContextMenu, onPaneClick } =
|
||||
useHandleNodeContextMenu(sideWidth);
|
||||
const { drawerVisible, hideDrawer, showDrawer } = useShowDrawer();
|
||||
|
||||
Reference in New Issue
Block a user