all work
This commit is contained in:
1 parent
3e79ddffcc
commit
019fa23758
2 files changed
+68
No files matched your search
@@ -0,0 +1,38 @@
|
|||||||
|
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { AutomationAction } from "~/automations/types/actions";
|
||||||
|
import { usePageTheme } from "~/styles/page";
|
||||||
|
import { SequenceEditor } from ".";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'SequenceEditor',
|
||||||
|
component: SequenceEditor,
|
||||||
|
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||||
|
} as ComponentMeta<typeof SequenceEditor>;
|
||||||
|
|
||||||
|
|
||||||
|
const Template: ComponentStory<typeof SequenceEditor> = ({node, ...args}) => {
|
||||||
|
const {classes} = usePageTheme({});
|
||||||
|
const [data, setData] = useState(node);
|
||||||
|
return <div className={classes.page}>
|
||||||
|
<SequenceEditor {...args}
|
||||||
|
node={data}
|
||||||
|
onUpdate={data => {
|
||||||
|
setData(data)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ServiceAction = Template.bind({})
|
||||||
|
ServiceAction.args = {
|
||||||
|
node: {
|
||||||
|
$smType: 'action',
|
||||||
|
action: 'service',
|
||||||
|
action_data: {
|
||||||
|
service: 'switch.toggle',
|
||||||
|
data: {},
|
||||||
|
target: {},
|
||||||
|
}
|
||||||
|
} as AutomationAction
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { FC } from "react";
|
||||||
|
import { ChooseAction } from "~/automations/types/actions";
|
||||||
|
|
||||||
|
|
||||||
|
export const ChooseEditor: FC<{
|
||||||
|
node: ChooseAction,
|
||||||
|
onUpdate: (u: ChooseAction) => void,
|
||||||
|
}> = ({
|
||||||
|
node,
|
||||||
|
onUpdate,
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
return <div>
|
||||||
|
<div>
|
||||||
|
<span>{node.action}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
{node.action_data.choose.map( ({conditions, sequence}, i) => <div>
|
||||||
|
<button>X</button>
|
||||||
|
<div>{i > 0 ? "else if" : 'if'}</div>
|
||||||
|
<div>Condition</div>
|
||||||
|
<div>
|
||||||
|
{sequence.map( s => s.$smType)}
|
||||||
|
</div>
|
||||||
|
</div>)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
Reference in new issue
Block a user