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 { CollectionNodeMaker } from "../nodes/CollectionNode";
|
||||||
import { ChooseAction } from "types/automations/actions";
|
import { ChooseAction } from "types/automations/actions";
|
||||||
import { XYPosition } from "react-flow-renderer";
|
import { XYPosition } from "react-flow-renderer";
|
||||||
import { DAGElementsState } from "./state";
|
import { DAGElementsOutputState } from "./outputState";
|
||||||
import { SequenceNodeMaker } from "../nodes/SequenceNode";
|
import { SequenceNodeMaker } from "../nodes/SequenceNode";
|
||||||
import { getNodeType } from "utils/automations";
|
import { getNodeType } from "utils/automations";
|
||||||
import { ButtonNodeMaker } from "../nodes/ButtonNode";
|
import { ButtonNodeMaker } from "../nodes/ButtonNode";
|
||||||
@@ -28,21 +28,8 @@ export const makeAutomationNodes = (
|
|||||||
) => {
|
) => {
|
||||||
const dims: DAGDims = {
|
const dims: DAGDims = {
|
||||||
...args.dims,
|
...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(
|
state.extend(
|
||||||
makeTriggerNodes(automation.trigger, {
|
makeTriggerNodes(automation.trigger, {
|
||||||
...args,
|
...args,
|
||||||
@@ -92,7 +79,7 @@ export const makeTriggerNodes: ElementMaker<AutomationTrigger> = (
|
|||||||
nodes,
|
nodes,
|
||||||
{ dims, namer, stateUpdater, nodeId, position }
|
{ dims, namer, stateUpdater, nodeId, position }
|
||||||
) => {
|
) => {
|
||||||
const state = new DAGElementsState();
|
const state = new DAGElementsOutputState();
|
||||||
state.addNode(
|
state.addNode(
|
||||||
CollectionNodeMaker.makeElement({ id: nodeId, position }, dims, {
|
CollectionNodeMaker.makeElement({ id: nodeId, position }, dims, {
|
||||||
...dims.trigger,
|
...dims.trigger,
|
||||||
@@ -112,7 +99,7 @@ export const makeConditionNodes: ElementMaker<AutomationCondition> = (
|
|||||||
nodes,
|
nodes,
|
||||||
{ nodeId, stateUpdater, position, dims, namer, lastNodeId }
|
{ nodeId, stateUpdater, position, dims, namer, lastNodeId }
|
||||||
) => {
|
) => {
|
||||||
const state = new DAGElementsState();
|
const state = new DAGElementsOutputState();
|
||||||
state.addNode(
|
state.addNode(
|
||||||
CollectionNodeMaker.makeElement({ id: nodeId, position }, dims, {
|
CollectionNodeMaker.makeElement({ id: nodeId, position }, dims, {
|
||||||
...dims.condition,
|
...dims.condition,
|
||||||
@@ -137,7 +124,7 @@ export const makeSequenceNodes: ElementMaker<AutomationSequenceNode> = (
|
|||||||
nodes,
|
nodes,
|
||||||
args
|
args
|
||||||
) => {
|
) => {
|
||||||
const state = new DAGElementsState();
|
const state = new DAGElementsOutputState();
|
||||||
const { lastNodeId, nodeId, position, dims, namer, stateUpdater } = args;
|
const { lastNodeId, nodeId, position, dims, namer, stateUpdater } = args;
|
||||||
nodes.forEach((node, nodeIndex) => {
|
nodes.forEach((node, nodeIndex) => {
|
||||||
const element = state.addNode(
|
const element = state.addNode(
|
||||||
@@ -202,7 +189,7 @@ export const makeSequenceNodes: ElementMaker<AutomationSequenceNode> = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const makeChooseeNodes: ElementMaker<ChooseAction> = (nodes, args) => {
|
export const makeChooseeNodes: ElementMaker<ChooseAction> = (nodes, args) => {
|
||||||
const state = new DAGElementsState();
|
const state = new DAGElementsOutputState();
|
||||||
if (nodes.length !== 1) {
|
if (nodes.length !== 1) {
|
||||||
throw new Error("makeChooseNodes only access a list of 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 { addSize, pointApply } from "./math";
|
||||||
import { Bbox, ElementData, LastNode } from "./types";
|
import { Bbox, ElementData, LastNode } from "./types";
|
||||||
|
|
||||||
export class DAGElementsState {
|
export class DAGElementsOutputState {
|
||||||
public data: ElementData = {
|
public data: ElementData = {
|
||||||
nodes: [],
|
nodes: [],
|
||||||
edges: [],
|
edges: [],
|
||||||
@@ -13,7 +13,10 @@ export class DAGElementsState {
|
|||||||
{ x: 0, y: 0 },
|
{ 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.nodes = this.data.nodes.concat(other.data.nodes);
|
||||||
this.data.edges = this.data.edges.concat(other.data.edges);
|
this.data.edges = this.data.edges.concat(other.data.edges);
|
||||||
this.bbox[0] = pointApply(this.bbox[0], other.bbox[0], Math.min);
|
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 { ModalState } from "../board/types";
|
||||||
import { DAGAutomationFlowNode } from "../nodes";
|
import { DAGAutomationFlowNode } from "../nodes";
|
||||||
import { DAGGraphUpdater } from "../updater";
|
import { DAGGraphUpdater } from "../updater";
|
||||||
import { DAGElementsState } from "./state";
|
import { DAGElementsOutputState } from "./outputState";
|
||||||
|
|
||||||
export type Bbox = [XYPosition, XYPosition];
|
export type Bbox = [XYPosition, XYPosition];
|
||||||
export type Size = { height: number; width: number };
|
export type Size = { height: number; width: number };
|
||||||
@@ -47,4 +47,4 @@ export type LastNode = {
|
|||||||
export type ElementMaker<A extends AutomationNode = AutomationNode> = (
|
export type ElementMaker<A extends AutomationNode = AutomationNode> = (
|
||||||
haNodes: A[],
|
haNodes: A[],
|
||||||
args: ElementMakerProps
|
args: ElementMakerProps
|
||||||
) => DAGElementsState;
|
) => DAGElementsOutputState;
|
||||||
Reference in new issue
Block a user