Skip to content

Commit 3d31ee4

Browse files
committed
Remove onDrop
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent 9c89aee commit 3d31ee4

File tree

1 file changed

+1
-44
lines changed

1 file changed

+1
-44
lines changed

public/pages/workflow_detail/workspace/workspace.tsx

+1-44
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import React, { useRef, useCallback, useEffect, useState } from 'react';
6+
import React, { useRef, useCallback, useEffect } from 'react';
77
import { useDispatch } from 'react-redux';
88
import ReactFlow, {
99
Controls,
@@ -15,17 +15,14 @@ import ReactFlow, {
1515
useStore,
1616
useReactFlow,
1717
useOnSelectionChange,
18-
Panel,
1918
} from 'reactflow';
2019
import { EuiFlexItem, EuiFlexGroup } from '@elastic/eui';
2120
import { setDirty } from '../../../store';
2221
import {
23-
IComponent,
2422
IComponentData,
2523
ReactFlowComponent,
2624
Workflow,
2725
} from '../../../../common';
28-
import { generateId, initComponentData } from '../../../utils';
2926
import {
3027
IngestGroupComponent,
3128
SearchGroupComponent,
@@ -96,45 +93,6 @@ export function Workspace(props: WorkspaceProps) {
9693
event.dataTransfer.dropEffect = 'move';
9794
}, []);
9895

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-
13896
// Initialization. Set the nodes and edges to an existing workflow state,
13997
useEffect(() => {
14098
const workflow = { ...props.workflow };
@@ -166,7 +124,6 @@ export function Workspace(props: WorkspaceProps) {
166124
onNodesChange={onNodesChange}
167125
onEdgesChange={onEdgesChange}
168126
onConnect={onConnect}
169-
onDrop={onDrop}
170127
onDragOver={onDragOver}
171128
className="reactflow-workspace"
172129
fitView

0 commit comments

Comments
 (0)