Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | import React from "react"; import { getBezierPath, getMarkerEnd } from "reactflow"; import CustomButton from "../../common/CustomButton/index.tsx"; import { Tooltip } from "@mui/material"; import { PermanentDrawerTypes } from "../../../store/features/drawers/permanentDrawerTypes.ts"; import handleEdgeColor from "../../../utils/playbook/relations/handleEdgeColor.ts"; import { Add } from "@mui/icons-material"; import useEdgeConditions from "../../../hooks/playbooks/useEdgeConditions.ts"; import usePermanentDrawerState from "../../../hooks/common/usePermanentDrawerState.ts"; const foreignObjectSize = 200; const CustomEdge = ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, arrowHeadType, markerEndId, source, }) => { const { rules } = useEdgeConditions(id); const { toggle, permanentView, openDrawer, addAdditionalData, additionalData, } = usePermanentDrawerState(); const [edgePath, labelX, labelY] = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, }); const markerEnd = getMarkerEnd(arrowHeadType, markerEndId); const handleAddConditionClick = (e) => { e.stopPropagation(); Iif ( permanentView === PermanentDrawerTypes.CONDITION && id === additionalData.id ) { toggle(PermanentDrawerTypes.CONDITION); return; } addAdditionalData({ source, id, }); openDrawer(PermanentDrawerTypes.CONDITION); }; return ( <> <path id={id} className={`react-flow__edge-path ${ handleEdgeColor(id) === "green" ? "animated-dotted-line" : "" }`} d={edgePath} markerEnd={markerEnd} style={{ stroke: handleEdgeColor(id), strokeWidth: 2, }} /> <foreignObject width={foreignObjectSize} height={foreignObjectSize} x={labelX - foreignObjectSize / 2} y={labelY - foreignObjectSize / 2}> <div className={`flex items-center justify-center w-full h-full`}> {rules?.length > 0 ? ( <CustomButton className={`${ additionalData.id === id ? "shadow-md shadow-violet-500 " : "" } w-10 h-10 items-center !text-xl p-0 justify-center font-normal`} onClick={handleAddConditionClick}> <Tooltip title="View Condition"> <>{`{ }`}</> </Tooltip> </CustomButton> ) : ( <> <div className="w-full h-full rounded-full step-information" /> <CustomButton className={`${ additionalData.id === id ? "shadow-md shadow-violet-500 " : "" } w-10 h-10 rounded-full items-center p-0 justify-center font-normal step-notes absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2`} onClick={handleAddConditionClick}> <Tooltip title="Add Condition"> <Add fontSize="small" /> </Tooltip> </CustomButton> </> )} </div> </foreignObject> </> ); }; export default CustomEdge; |