-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(21481): Create nodes from dropping an edge from a source * fix(21481): fix handle name * feat(21481): add support for creating nodes on drop * feat(21481): add mapping for valid dropped nodes * feat(21481): add visual feedback for the dropped node * fix(21481): remove optional chaining * fix(21481): fix rebase
- Loading branch information
Showing
5 changed files
with
259 additions
and
6 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
hivemq-edge/src/frontend/src/extensions/datahub/components/nodes/ConnectionLine.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FC, useMemo } from 'react' | ||
import { ConnectionLineComponentProps, getSimpleBezierPath } from 'reactflow' | ||
import { Tag } from '@chakra-ui/react' | ||
|
||
import { getConnectedNodeFrom } from '@datahub/utils/node.utils.ts' | ||
import { NodeIcon } from '@datahub/components/helpers' | ||
|
||
const ConnectionLine: FC<ConnectionLineComponentProps> = ({ | ||
fromHandle, | ||
fromNode, | ||
fromX, | ||
fromY, | ||
toY, | ||
toX, | ||
...props | ||
}) => { | ||
const droppedNode = useMemo(() => { | ||
return getConnectedNodeFrom(fromNode?.type, fromHandle?.id) | ||
}, [fromHandle?.id, fromNode?.type]) | ||
|
||
const pathParams = { | ||
sourceX: fromX, | ||
sourceY: fromY, | ||
sourcePosition: props.fromPosition, | ||
targetX: toX, | ||
targetY: toY, | ||
targetPosition: props.toPosition, | ||
} | ||
|
||
const [d] = getSimpleBezierPath(pathParams) | ||
|
||
return ( | ||
<g> | ||
<path fill="none" stroke="grey" strokeWidth={1.5} className="animated" d={d} /> | ||
{props.connectionStatus === null && ( | ||
<foreignObject x={toX} y={toY - 20} width="50px" height="50px"> | ||
<Tag size="lg" colorScheme="gray" borderRadius="full" variant="outline"> | ||
<NodeIcon type={droppedNode?.type} /> | ||
</Tag> | ||
</foreignObject> | ||
)} | ||
</g> | ||
) | ||
} | ||
|
||
export default ConnectionLine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters