From 2438a8c6588683d0b270463e341419a78b7a37dc Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 24 Nov 2023 12:43:29 -0300 Subject: [PATCH] fix(GenericNode/index.tsx): fix initial state of inputName to be false instead of true for better user experience refactor(GenericNode/index.tsx): refactor tooltip div structure to improve readability and add pencil icon if node has flow refactor(GenericNode/index.tsx): refactor color logic to use typesContext instead of accessing types directly refactor(GenericNode/index.tsx): refactor output type title logic to use ternary operator for better readability refactor(GenericNode/index.tsx): refactor validation status params rendering to use ternary operator for better readability refactor(GenericNode/index.tsx): refactor generic node description rendering to use ternary operator for better readability refactor(GenericNode/index.tsx): refactor template field rendering to use ternary operator for better readability refactor(PageComponent/index.tsx): remove unnecessary empty line --- .../src/CustomNodes/GenericNode/index.tsx | 43 ++++++++++--------- .../components/PageComponent/index.tsx | 1 - 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 4df59b634..a86207063 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -38,7 +38,7 @@ export default function GenericNode({ const { types, deleteNode, reactFlowInstance, setFilterEdge, getFilterEdge } = useContext(typesContext); const name = nodeIconsLucide[data.type] ? data.type : types[data.type]; - const [inputName, setInputName] = useState(true); + const [inputName, setInputName] = useState(false); const [nodeName, setNodeName] = useState(data.node!.display_name); const [inputDescription, setInputDescription] = useState(false); const [nodeDescription, setNodeDescription] = useState( @@ -198,11 +198,14 @@ export default function GenericNode({ ) : ( -
setInputName(true)} - > - {data.node?.display_name} +
setInputName(true)}> +
+ {data.node?.display_name} +
+ {data.node?.flow&& }
)} @@ -232,10 +235,10 @@ export default function GenericNode({ setData={setData} color={ nodeColors[ - types[data.node?.template[templateField].type!] + types[data.node?.template[templateField].type!] ] ?? nodeColors[ - data.node?.template[templateField].type! + data.node?.template[templateField].type! ] ?? nodeColors.unknown } @@ -282,7 +285,7 @@ export default function GenericNode({ color={nodeColors[types[data.type]] ?? nodeColors.unknown} title={ data.node?.output_types && - data.node.output_types.length > 0 + data.node.output_types.length > 0 ? data.node.output_types.join("|") : data.type } @@ -320,10 +323,10 @@ export default function GenericNode({
{typeof validationStatus.params === "string" ? validationStatus.params - .split("\n") - .map((line: string, index: number) => ( -
{line}
- )) + .split("\n") + .map((line: string, index: number) => ( +
{line}
+ )) : ""}
) @@ -367,14 +370,14 @@ export default function GenericNode({ className={ showNode ? "generic-node-desc " + - (data.node?.description !== "" ? "py-5" : "pb-5") + (data.node?.description !== "" ? "py-5" : "pb-5") : "" } > {data.node?.description !== "" && - showNode && - data.node?.flow && - inputDescription ? ( + showNode && + data.node?.flow && + inputDescription ? (