From 0d6547991f33235b78a9285ef220556cb3e56db0 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 29 May 2024 20:06:45 -0300 Subject: [PATCH] feat: Add OutputModal component for displaying output preview This commit adds the OutputModal component to the ParameterComponent. The OutputModal component is responsible for displaying the output preview when the user clicks on the "Inspect Output" button. It improves the user experience by allowing them to easily view the output without leaving the current page. --- .../components/parameterComponent/index.tsx | 42 +++++++++++++++++-- .../src/customNodes/genericNode/index.tsx | 16 ------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/frontend/src/customNodes/genericNode/components/parameterComponent/index.tsx b/src/frontend/src/customNodes/genericNode/components/parameterComponent/index.tsx index fce391191..33e3d6ddc 100644 --- a/src/frontend/src/customNodes/genericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/customNodes/genericNode/components/parameterComponent/index.tsx @@ -45,6 +45,7 @@ import useHandleOnNewValue from "../../../hooks/use-handle-new-value"; import useHandleNodeClass from "../../../hooks/use-handle-node-class"; import useHandleRefreshButtonPress from "../../../hooks/use-handle-refresh-buttons"; import TooltipRenderComponent from "../tooltipRenderComponent"; +import OutputModal from "../outputModal"; export default function ParameterComponent({ left, @@ -77,6 +78,10 @@ export default function ParameterComponent({ const flow = currentFlow?.data?.nodes ?? null; const groupedEdge = useRef(null); const setFilterEdge = useFlowStore((state) => state.setFilterEdge); + const [openOutputModal, setOpenOutputModal] = useState(false); + const flowPool = useFlowStore((state) => state.flowPool); + + const displayOutputPreview = !!flowPool[data.id]; const { handleOnNewValue: handleOnNewValueHook } = useHandleOnNewValue( data, @@ -249,9 +254,33 @@ export default function ParameterComponent({ ) : ( - - {title} - +
+ + {title} + + + + +
)} {required ? "*" : ""} @@ -582,6 +611,13 @@ export default function ParameterComponent({ /> + {openOutputModal && ( + + )} ); diff --git a/src/frontend/src/customNodes/genericNode/index.tsx b/src/frontend/src/customNodes/genericNode/index.tsx index d17da3063..6adbafbdf 100644 --- a/src/frontend/src/customNodes/genericNode/index.tsx +++ b/src/frontend/src/customNodes/genericNode/index.tsx @@ -68,7 +68,6 @@ export default function GenericNode({ const [nodeDescription, setNodeDescription] = useState( data.node?.description!, ); - const [openOutputModal, setOpenOutputModal] = useState(false); const [isOutdated, setIsOutdated] = useState(false); const [validationStatus, setValidationStatus] = useState(null); @@ -449,13 +448,6 @@ export default function GenericNode({ {showNode && ( <> - )} - - {openOutputModal && ( - - )} ); }