3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
- import React , { useRef , useCallback , useEffect , useState } from 'react' ;
6
+ import React , { useRef , useCallback , useEffect } from 'react' ;
7
7
import { useDispatch } from 'react-redux' ;
8
8
import ReactFlow , {
9
9
Controls ,
@@ -15,17 +15,14 @@ import ReactFlow, {
15
15
useStore ,
16
16
useReactFlow ,
17
17
useOnSelectionChange ,
18
- Panel ,
19
18
} from 'reactflow' ;
20
19
import { EuiFlexItem , EuiFlexGroup } from '@elastic/eui' ;
21
20
import { setDirty } from '../../../store' ;
22
21
import {
23
- IComponent ,
24
22
IComponentData ,
25
23
ReactFlowComponent ,
26
24
Workflow ,
27
25
} from '../../../../common' ;
28
- import { generateId , initComponentData } from '../../../utils' ;
29
26
import {
30
27
IngestGroupComponent ,
31
28
SearchGroupComponent ,
@@ -96,45 +93,6 @@ export function Workspace(props: WorkspaceProps) {
96
93
event . dataTransfer . dropEffect = 'move' ;
97
94
} , [ ] ) ;
98
95
99
- const onDrop = useCallback (
100
- ( event ) => {
101
- event . preventDefault ( ) ;
102
- // Get the node info from the event metadata
103
- const serializedComponent = event . dataTransfer . getData (
104
- 'application/reactflow'
105
- ) as string ;
106
- const component = JSON . parse ( serializedComponent ) as IComponent ;
107
-
108
- // check if the dropped element is valid
109
- if ( typeof component === 'undefined' || ! component ) {
110
- return ;
111
- }
112
-
113
- // Fetch bounds based on the ref'd div component, adjust as needed.
114
- // TODO: remove hardcoded bounds and fetch from a constant somewhere
115
- // @ts -ignore
116
- const reactFlowBounds = reactFlowWrapper . current . getBoundingClientRect ( ) ;
117
-
118
- // @ts -ignore
119
- const position = reactFlowInstance . project ( {
120
- x : event . clientX - reactFlowBounds . left ,
121
- y : event . clientY - reactFlowBounds . top ,
122
- } ) ;
123
- const id = generateId ( component . type ) ;
124
- const newNode = {
125
- id,
126
- type : 'new' ,
127
- position,
128
- positionAbsolute : position ,
129
- data : initComponentData ( component , id ) ,
130
- } ;
131
-
132
- setNodes ( ( nds ) => nds . concat ( newNode ) ) ;
133
- dispatch ( setDirty ( ) ) ;
134
- } ,
135
- [ reactFlowInstance ]
136
- ) ;
137
-
138
96
// Initialization. Set the nodes and edges to an existing workflow state,
139
97
useEffect ( ( ) => {
140
98
const workflow = { ...props . workflow } ;
@@ -166,7 +124,6 @@ export function Workspace(props: WorkspaceProps) {
166
124
onNodesChange = { onNodesChange }
167
125
onEdgesChange = { onEdgesChange }
168
126
onConnect = { onConnect }
169
- onDrop = { onDrop }
170
127
onDragOver = { onDragOver }
171
128
className = "reactflow-workspace"
172
129
fitView
0 commit comments