updated choose name
This commit is contained in:
1 parent
218972ed5d
commit
21dd880e37
8 files changed
+584
-468
No files matched your search
@@ -1,65 +1,74 @@
|
||||
import { AutomationTrigger } from 'types/automations/triggers';
|
||||
import { DAGAutomationFlowDims, FlowData, TriggerMakerOptions } from './types';
|
||||
import { makeAddButton } from './flowDataMods';
|
||||
import { getDescriptionFromAutomationNode } from 'utils/formatting';
|
||||
import { AutomationTrigger } from "types/automations/triggers";
|
||||
import { DAGAutomationFlowDims, FlowData, TriggerMakerOptions } from "./types";
|
||||
import { makeAddButton } from "./flowDataMods";
|
||||
import { getDescriptionFromAutomationNode } from "utils/formatting";
|
||||
|
||||
export const triggerToFlow = (
|
||||
flowData: FlowData,
|
||||
trigger: AutomationTrigger[],
|
||||
toPoint: string,
|
||||
dims: DAGAutomationFlowDims,
|
||||
opts: TriggerMakerOptions,
|
||||
flowData: FlowData,
|
||||
trigger: AutomationTrigger[],
|
||||
toPoint: string,
|
||||
dims: DAGAutomationFlowDims,
|
||||
opts: TriggerMakerOptions
|
||||
) => {
|
||||
const {
|
||||
distanceFactor,
|
||||
nodeHeight,
|
||||
nodeWidth,
|
||||
padding,
|
||||
conditionHeight,
|
||||
circleSize,
|
||||
const {
|
||||
distanceFactor,
|
||||
nodeHeight,
|
||||
nodeWidth,
|
||||
padding,
|
||||
conditionHeight,
|
||||
circleSize,
|
||||
flipped,
|
||||
} = dims;
|
||||
// convert all triggers to dag nodes
|
||||
trigger.forEach((t, i) => {
|
||||
const flowId = `t-${i}`;
|
||||
flowData.nodes.push({
|
||||
id: flowId,
|
||||
type: "dagnode",
|
||||
data: {
|
||||
label: getDescriptionFromAutomationNode(t, opts.namer, true),
|
||||
height: nodeHeight,
|
||||
width: nodeWidth,
|
||||
flipped,
|
||||
} = dims;
|
||||
// convert all triggers to dag nodes
|
||||
trigger.forEach((t, i) => {
|
||||
const flowId = `t-${i}`;
|
||||
flowData.nodes.push({
|
||||
id: flowId,
|
||||
type: 'dagnode',
|
||||
data: {
|
||||
label: getDescriptionFromAutomationNode(t, opts.namer),
|
||||
height: nodeHeight,
|
||||
width: nodeWidth,
|
||||
flipped,
|
||||
color: 'red',
|
||||
onEditClick: () => opts.onEdit(i),
|
||||
onXClick: () => opts.onDelete(i),
|
||||
},
|
||||
position: flipped ? {
|
||||
y: padding.y,
|
||||
x: padding.x + nodeWidth * distanceFactor * i
|
||||
} : {
|
||||
x: padding.x,
|
||||
y: padding.y + nodeHeight * distanceFactor * i
|
||||
}
|
||||
})
|
||||
flowData.edges.push({
|
||||
id: `e(${flowId})-(${toPoint})`,
|
||||
source: flowId,
|
||||
target: toPoint,
|
||||
})
|
||||
color: "red",
|
||||
onEditClick: () => opts.onEdit(i),
|
||||
onXClick: () => opts.onDelete(i),
|
||||
},
|
||||
position: flipped
|
||||
? {
|
||||
y: padding.y,
|
||||
x: padding.x + nodeWidth * distanceFactor * i,
|
||||
}
|
||||
: {
|
||||
x: padding.x,
|
||||
y: padding.y + nodeHeight * distanceFactor * i,
|
||||
},
|
||||
});
|
||||
flowData.edges.push({
|
||||
id: `e(${flowId})-(${toPoint})`,
|
||||
source: flowId,
|
||||
target: toPoint,
|
||||
});
|
||||
});
|
||||
|
||||
// create a 'add button'
|
||||
flowData.nodes.push(makeAddButton(
|
||||
'trigger-add',
|
||||
flipped ? {
|
||||
// create a 'add button'
|
||||
flowData.nodes.push(
|
||||
makeAddButton(
|
||||
"trigger-add",
|
||||
flipped
|
||||
? {
|
||||
y: padding.y + circleSize / 4,
|
||||
x: padding.x + nodeWidth * distanceFactor * trigger.length,
|
||||
} : {
|
||||
}
|
||||
: {
|
||||
x: padding.x + nodeWidth * 0.4,
|
||||
y: padding.y + conditionHeight / 2 + nodeHeight * distanceFactor * trigger.length,
|
||||
},
|
||||
dims,
|
||||
opts.onAdd
|
||||
))
|
||||
}
|
||||
y:
|
||||
padding.y +
|
||||
conditionHeight / 2 +
|
||||
nodeHeight * distanceFactor * trigger.length,
|
||||
},
|
||||
dims,
|
||||
opts.onAdd
|
||||
)
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user