choose flow
This commit is contained in:
1 parent
468a022582
commit
56d68d9065
5 files changed
+338
-58
No files matched your search
@@ -4,8 +4,9 @@ import ReactFlow, { MiniMap, Controls } from 'react-flow-renderer';
|
||||
import { AutomationData } from "types/automations";
|
||||
import { triggerToFlow } from "./triggerConvertor";
|
||||
import { DAGNode } from "./DAGNode";
|
||||
import { DAGFlowDims, TriggerMakerOptions } from "./types";
|
||||
import { DAGFlowDims, TriggerMakerOptions, FlowData } from './types';
|
||||
import { DAGCircle } from './DAGCircle';
|
||||
import { sequenceToFlow } from "./sequenceConvertor";
|
||||
|
||||
const nodeTypes = {
|
||||
'dagnode': DAGNode,
|
||||
@@ -25,22 +26,40 @@ export const DAGFlow: FC<Props> = ({
|
||||
opts,
|
||||
dims,
|
||||
}) => {
|
||||
const {
|
||||
nodes,
|
||||
edges,
|
||||
} = triggerToFlow(automation.trigger, dims, opts.triggers);
|
||||
const condPoint = makeConditionPoint(dims);
|
||||
const flowData: FlowData = {
|
||||
nodes: [condPoint],
|
||||
edges: [],
|
||||
}
|
||||
triggerToFlow(flowData, automation.trigger, condPoint.id, dims, opts.triggers);
|
||||
sequenceToFlow(flowData, automation.sequence, condPoint.id, dims);
|
||||
return (
|
||||
<ReactFlow
|
||||
nodeTypes={nodeTypes}
|
||||
nodes={nodes}
|
||||
edges={edges}
|
||||
snapToGrid
|
||||
onlyRenderVisibleElements
|
||||
nodesConnectable={false}
|
||||
nodesDraggable={false}
|
||||
{...flowData}
|
||||
>
|
||||
<MiniMap />
|
||||
<Controls />
|
||||
</ReactFlow>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const makeConditionPoint = ({
|
||||
padding,
|
||||
nodeWidth,
|
||||
nodeHeight,
|
||||
circleSize,
|
||||
}: DAGFlowDims) => ({
|
||||
id: `c`,
|
||||
type: 'dagcircle',
|
||||
position: { x: padding.x + nodeWidth * 2, y: padding.y + nodeHeight * 0.25 },
|
||||
data: {
|
||||
size: circleSize,
|
||||
backgroundColor: 'blue',
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user