using new board
This commit is contained in:
1 parent
2d78319683
commit
595aa2dfa1
33 files changed
+312
-2629
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { FC, useState } from "react";
|
||||
import {
|
||||
AutomationActionData,
|
||||
AutomationSequenceNode,
|
||||
} from "types/automations";
|
||||
import { useHA } from "haService";
|
||||
import { ModalState } from "./board/types";
|
||||
import { createUpdater } from "./updater";
|
||||
import { useAutomationNodes } from "./elements";
|
||||
import { DEFAULT_DIMS } from "./elements/constants";
|
||||
import { DAGGraphBoard } from "./board";
|
||||
import { AutomationTrigger } from "types/automations/triggers";
|
||||
import { AutomationCondition } from "types/automations/conditions";
|
||||
|
||||
export const DAGAutomationGraph: FC<{
|
||||
sequence: AutomationSequenceNode[];
|
||||
trigger: AutomationTrigger[];
|
||||
condition: AutomationCondition[];
|
||||
onSequenceUpdate: (s: AutomationSequenceNode[]) => void;
|
||||
onTriggerUpdate: (t: AutomationTrigger[]) => void;
|
||||
onConditionUpdate: (c: AutomationCondition[]) => void;
|
||||
isFlipped: boolean;
|
||||
}> = (props) => {
|
||||
const { namer } = useHA();
|
||||
const [modalState, setModalState] =
|
||||
useState<ModalState | undefined>(undefined);
|
||||
const updater = createUpdater({
|
||||
openModal: setModalState,
|
||||
sequence: {
|
||||
data: props.sequence,
|
||||
onUpdate: props.onSequenceUpdate,
|
||||
},
|
||||
condition: {
|
||||
data: props.condition,
|
||||
onUpdate: props.onConditionUpdate as any,
|
||||
},
|
||||
trigger: {
|
||||
data: props.trigger,
|
||||
onUpdate: props.onTriggerUpdate as any,
|
||||
},
|
||||
});
|
||||
const elementData = useAutomationNodes(
|
||||
{
|
||||
sequence: props.sequence,
|
||||
condition: props.condition,
|
||||
trigger: props.trigger,
|
||||
},
|
||||
{
|
||||
dims: {
|
||||
...DEFAULT_DIMS,
|
||||
flipped: props.isFlipped,
|
||||
},
|
||||
namer,
|
||||
openModal: setModalState,
|
||||
stateUpdater: updater,
|
||||
}
|
||||
);
|
||||
return (
|
||||
<DAGGraphBoard
|
||||
modalState={modalState}
|
||||
closeModal={() => setModalState(undefined)}
|
||||
state={{
|
||||
ready: true,
|
||||
data: {
|
||||
elements: elementData,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import * as dgconst from "components/DAGFlow/constants";
|
||||
import { Page } from "components/Page";
|
||||
import { SequenceNode } from "./SequenceNode";
|
||||
import { DAGGraphBoard } from "components/DAGGraph/board";
|
||||
@@ -12,9 +11,8 @@ export default {
|
||||
component: SequenceNode,
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
args: {
|
||||
...DEFAULT_DIMS.node,
|
||||
color: "lblue",
|
||||
height: dgconst.NODE_HEIGHT,
|
||||
width: dgconst.NODE_WIDTH,
|
||||
label: "test",
|
||||
hasInput: true,
|
||||
enabled: true,
|
||||
@@ -67,8 +65,16 @@ export const Colors: ComponentStory<typeof SequenceNode> = (args) => {
|
||||
{
|
||||
id: color,
|
||||
position: {
|
||||
x: 50 + dgconst.NODE_HEIGHT * dgconst.DISTANCE_FACTOR * i,
|
||||
y: 50 + dgconst.NODE_HEIGHT * dgconst.DISTANCE_FACTOR * i,
|
||||
x:
|
||||
50 +
|
||||
DEFAULT_DIMS.node.height *
|
||||
DEFAULT_DIMS.distanceFactor.node *
|
||||
i,
|
||||
y:
|
||||
50 +
|
||||
DEFAULT_DIMS.node.height *
|
||||
DEFAULT_DIMS.distanceFactor.node *
|
||||
i,
|
||||
},
|
||||
},
|
||||
DEFAULT_DIMS,
|
||||
|
||||
Reference in new issue
Block a user