From 736a6053ef0076818db6042a11bd4ab42cef1dc9 Mon Sep 17 00:00:00 2001 From: Ari Date: Thu, 16 Jun 2022 20:39:11 -0400 Subject: [PATCH] always pretty list --- webapp/src/components/Inputs/InputList.tsx | 2 +- webapp/src/components/NodeEditor/index.tsx | 140 +++++++++++++-------- 2 files changed, 87 insertions(+), 55 deletions(-) diff --git a/webapp/src/components/Inputs/InputList.tsx b/webapp/src/components/Inputs/InputList.tsx index 5b52dfc..c69b39a 100644 --- a/webapp/src/components/Inputs/InputList.tsx +++ b/webapp/src/components/Inputs/InputList.tsx @@ -27,7 +27,7 @@ export function InputList({ label, id, className, - prettyOptionLabels, + prettyOptionLabels = true, getKey = String, placeholder, title, diff --git a/webapp/src/components/NodeEditor/index.tsx b/webapp/src/components/NodeEditor/index.tsx index 64cee59..b5d6690 100644 --- a/webapp/src/components/NodeEditor/index.tsx +++ b/webapp/src/components/NodeEditor/index.tsx @@ -1,14 +1,14 @@ import "./index.css"; -import { FC, ReactNode } from 'react'; -import { AutomationNode, AutomationNodeMapping } from 'types/automations/index'; +import { FC, ReactNode } from "react"; +import { AutomationNode, AutomationNodeMapping } from "types/automations/index"; import { useEditorNodeState } from "./OptionManager"; import { InputList } from "components/Inputs/InputList"; import { Button } from "components/Inputs/Button"; import InputBoolean from "components/Inputs/InputBoolean"; export interface NodeEditorProps { - node: AutomationNode + node: AutomationNode; allowedTypes?: Array; onClose?: () => void; onSave?: (n: AutomationNode) => void; @@ -21,9 +21,9 @@ export interface NodeEditorProps { export const NodeEditor: FC = ({ node, allowedTypes = ["action", "condition", "trigger"], - onClose = () => { }, - onSave = () => { }, - onFlags = () => { }, + onClose = () => {}, + onSave = () => {}, + onFlags = () => {}, saveBtnCreateText = false, children, isErrored = false, @@ -34,58 +34,90 @@ export const NodeEditor: FC = ({ // alias const isModified = state.isModified; const isReady = state.isReady(); - const areYouSureNotReady = (what: string) => !isReady ? - window.confirm(`This node is missing some values, are you sure you want to ${what}?`) : - state.isErrored ? - window.confirm(`This node contains errors, are you sure you want to ${what}?`) : - true; + const areYouSureNotReady = (what: string) => + !isReady + ? window.confirm( + `This node is missing some values, are you sure you want to ${what}?` + ) + : state.isErrored + ? window.confirm( + `This node contains errors, are you sure you want to ${what}?` + ) + : true; // events onFlags(isReady, isModified); // render - return
-
-
- {allowedTypes.length > 1 ? : <>} - {state.nodeType !== 'condition' ? : <>} -
- - + return ( +
+
+
+ {allowedTypes.length > 1 ? ( + + ) : ( + <> + )} + {state.nodeType !== "condition" ? ( + + ) : ( + <> + )} +
+ + +
+ {state.renderOptionList()} +
+
+ + + {children}
- {state.renderOptionList()}
-
- - - {children} -
-
-} + ); +};