diff --git a/webapp/src/components/DAGGraph/elements/index.tsx b/webapp/src/components/DAGGraph/elements/index.tsx index 2075a8f..32b3cc0 100644 --- a/webapp/src/components/DAGGraph/elements/index.tsx +++ b/webapp/src/components/DAGGraph/elements/index.tsx @@ -16,7 +16,7 @@ import { AutomationCondition } from "types/automations/conditions"; import { CollectionNodeMaker } from "../nodes/CollectionNode"; import { ChooseAction } from "types/automations/actions"; import { XYPosition } from "react-flow-renderer"; -import { DAGElementsState } from "./state"; +import { DAGElementsOutputState } from "./outputState"; import { SequenceNodeMaker } from "../nodes/SequenceNode"; import { getNodeType } from "utils/automations"; import { ButtonNodeMaker } from "../nodes/ButtonNode"; @@ -28,21 +28,8 @@ export const makeAutomationNodes = ( ) => { const dims: DAGDims = { ...args.dims, - // think of a better to do this - // condition: args.dims.flipped - // ? args.dims.condition - // : { - // height: args.dims.condition.width, - // width: args.dims.condition.height, - // }, - // trigger: args.dims.flipped - // ? args.dims.trigger - // : { - // height: args.dims.trigger.width, - // width: args.dims.trigger.height, - // }, }; - const state = new DAGElementsState(); + const state = new DAGElementsOutputState(); state.extend( makeTriggerNodes(automation.trigger, { ...args, @@ -92,7 +79,7 @@ export const makeTriggerNodes: ElementMaker = ( nodes, { dims, namer, stateUpdater, nodeId, position } ) => { - const state = new DAGElementsState(); + const state = new DAGElementsOutputState(); state.addNode( CollectionNodeMaker.makeElement({ id: nodeId, position }, dims, { ...dims.trigger, @@ -112,7 +99,7 @@ export const makeConditionNodes: ElementMaker = ( nodes, { nodeId, stateUpdater, position, dims, namer, lastNodeId } ) => { - const state = new DAGElementsState(); + const state = new DAGElementsOutputState(); state.addNode( CollectionNodeMaker.makeElement({ id: nodeId, position }, dims, { ...dims.condition, @@ -137,7 +124,7 @@ export const makeSequenceNodes: ElementMaker = ( nodes, args ) => { - const state = new DAGElementsState(); + const state = new DAGElementsOutputState(); const { lastNodeId, nodeId, position, dims, namer, stateUpdater } = args; nodes.forEach((node, nodeIndex) => { const element = state.addNode( @@ -202,7 +189,7 @@ export const makeSequenceNodes: ElementMaker = ( }; export const makeChooseeNodes: ElementMaker = (nodes, args) => { - const state = new DAGElementsState(); + const state = new DAGElementsOutputState(); if (nodes.length !== 1) { throw new Error("makeChooseNodes only access a list of 1"); } diff --git a/webapp/src/components/DAGGraph/elements/state.ts b/webapp/src/components/DAGGraph/elements/outputState.ts similarity index 93% rename from webapp/src/components/DAGGraph/elements/state.ts rename to webapp/src/components/DAGGraph/elements/outputState.ts index 1677edc..dfe47ba 100644 --- a/webapp/src/components/DAGGraph/elements/state.ts +++ b/webapp/src/components/DAGGraph/elements/outputState.ts @@ -2,7 +2,7 @@ import { DAGAutomationFlowNode } from "../nodes"; import { addSize, pointApply } from "./math"; import { Bbox, ElementData, LastNode } from "./types"; -export class DAGElementsState { +export class DAGElementsOutputState { public data: ElementData = { nodes: [], edges: [], @@ -13,7 +13,10 @@ export class DAGElementsState { { x: 0, y: 0 }, ]; - public extend(other: DAGElementsState, ignoreLastNode: boolean = false) { + public extend( + other: DAGElementsOutputState, + ignoreLastNode: boolean = false + ) { this.data.nodes = this.data.nodes.concat(other.data.nodes); this.data.edges = this.data.edges.concat(other.data.edges); this.bbox[0] = pointApply(this.bbox[0], other.bbox[0], Math.min); diff --git a/webapp/src/components/DAGGraph/elements/types.ts b/webapp/src/components/DAGGraph/elements/types.ts index 8cf36b3..6b75034 100644 --- a/webapp/src/components/DAGGraph/elements/types.ts +++ b/webapp/src/components/DAGGraph/elements/types.ts @@ -4,7 +4,7 @@ import { Namer } from "utils/formatting"; import { ModalState } from "../board/types"; import { DAGAutomationFlowNode } from "../nodes"; import { DAGGraphUpdater } from "../updater"; -import { DAGElementsState } from "./state"; +import { DAGElementsOutputState } from "./outputState"; export type Bbox = [XYPosition, XYPosition]; export type Size = { height: number; width: number }; @@ -47,4 +47,4 @@ export type LastNode = { export type ElementMaker = ( haNodes: A[], args: ElementMakerProps -) => DAGElementsState; +) => DAGElementsOutputState;