renamed state to outputstate
This commit is contained in:
1 parent
b4f46bec92
commit
0b381a6e50
3 files changed
+13
-23
No files matched your search
@@ -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<AutomationTrigger> = (
|
||||
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<AutomationCondition> = (
|
||||
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<AutomationSequenceNode> = (
|
||||
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<AutomationSequenceNode> = (
|
||||
};
|
||||
|
||||
export const makeChooseeNodes: ElementMaker<ChooseAction> = (nodes, args) => {
|
||||
const state = new DAGElementsState();
|
||||
const state = new DAGElementsOutputState();
|
||||
if (nodes.length !== 1) {
|
||||
throw new Error("makeChooseNodes only access a list of 1");
|
||||
}
|
||||
|
||||
+5
-2
@@ -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);
|
||||
@@ -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<A extends AutomationNode = AutomationNode> = (
|
||||
haNodes: A[],
|
||||
args: ElementMakerProps
|
||||
) => DAGElementsState;
|
||||
) => DAGElementsOutputState;
|
||||
Reference in new issue
Block a user