diff --git a/web/src/components/ConditionEditor/ConditionNode.tsx b/web/src/components/ConditionEditor/ConditionNode.tsx
index 9679d06..59f6000 100644
--- a/web/src/components/ConditionEditor/ConditionNode.tsx
+++ b/web/src/components/ConditionEditor/ConditionNode.tsx
@@ -4,6 +4,7 @@ import { getConditionDefaultValues } from "~/automations/defaults";
import { AutomationCondition } from "~/automations/types/conditions";
import { CheckMarkIcon, PencilIcon } from "~/icons/icons";
import InputList from "../Inputs/InputList";
+import InputYaml from "../Inputs/InputYaml";
import { getEditor } from "./editorRender";
import { useStyles } from "./style";
import { getViewer } from "./viewRender";
@@ -29,6 +30,7 @@ export const ConditionNode: FC<{
}) => {
// state
const [internalDisplayMode, setInternalDisplayMode] = useState(true);
+ const [yamlMode, setYamlMode] = useState(false);
// alias
const effectiveDM = displayMode && internalDisplayMode;
const onAddChild = () => {
@@ -74,7 +76,6 @@ export const ConditionNode: FC<{
} else if (condition.condition ==='or') {
hasChildren = true
}
- console.log({condition: condition.condition, hasChildren})
const {classes} = useStyles({ hasChildren });
// components
@@ -86,6 +87,7 @@ export const ConditionNode: FC<{
- {childrenConditions}
- {hasChildren &&
+ {yamlMode &&
onUpdate({
+ ...condition,
+ condition_data: update as any
+ })}
+ resizable
+ />}
+ {!yamlMode && childrenConditions}
+ {!yamlMode && hasChildren &&
}
diff --git a/web/src/components/ConditionEditor/style.ts b/web/src/components/ConditionEditor/style.ts
index 08f1d0b..529eaf4 100644
--- a/web/src/components/ConditionEditor/style.ts
+++ b/web/src/components/ConditionEditor/style.ts
@@ -27,8 +27,7 @@ export const useStyles = createAppUseStyles<{
position: 'relative',
display: 'flex',
flexDirection: hasChildren? 'column' : 'row',
- // width: hasChildren? '100%' : undefined,
- // height: hasChildren? '100%' : undefined,
+ alignItems: hasChildren ? undefined : 'flex-start',
}),
title: ({hasChildren}) => ({
display: 'flex',
@@ -101,11 +100,26 @@ export const useStyles = createAppUseStyles<{
border: `1px solid ${theme.primaryAccent}`,
borderBottomRightRadius: hasChildren ? 10 : 0,
borderBottomLeftRadius: hasChildren ? 10 : 0,
+ minHeight: hasChildren ? undefined : '100%'
}),
addBtnContainer: {
display: 'flex',
justifyContent: 'center',
},
+ yamlBtn: {
+ backgroundColor: theme.secondary,
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: theme.secondaryAccent,
+ color: theme.secondaryAccent,
+ paddingLeft: 20,
+ paddingRight: 20,
+ cursor: 'pointer',
+ "&:hover": {
+ backgroundColor: Color(theme.primary).brighten().hex(),
+ fill: Color(theme.primaryAccent).brighten().hex(),
+ },
+ },
addBtn: {
backgroundColor: theme.secondary,
borderWidth: 1,
@@ -115,7 +129,6 @@ export const useStyles = createAppUseStyles<{
borderRadius: 5,
marginTop: 5,
marginBottom: 5,
- marginRight: 5,
paddingLeft: 20,
paddingRight: 20,
cursor: 'pointer',
diff --git a/web/src/components/Inputs/InputList.tsx b/web/src/components/Inputs/InputList.tsx
index f0e9f33..e52307a 100644
--- a/web/src/components/Inputs/InputList.tsx
+++ b/web/src/components/Inputs/InputList.tsx
@@ -1,12 +1,11 @@
-import { useState } from "react";
import InputWrapper from "./InputWrapper";
-import { useInputTextStyles } from "./styles";
+import { useInputListStyles } from "./styles";
export interface Props
{
current: T;
options: readonly T[];
- onChange: (n: string) => void;
+ onChange: (n: T) => void;
id?: string;
className?: string;
label: string;
@@ -15,8 +14,8 @@ export default function InputList({
current, options, onChange, label,
...selattr
}: Props) {
- const {classes} = useInputTextStyles({});
- return
+ const {classes} = useInputListStyles({});
+ return