feat: Disable inspect button for empty node outputs (#7528)
🔧 (NodeOutputfield/index.tsx): refactor useMemo hook to check for empty output messages in the flowPoolNode data 🔧 (NodeOutputfield/index.tsx): refactor disabledInspectButton logic to include check for empty output messages Co-authored-by: Mike Fortman <michael.fortman@datastax.com>
This commit is contained in:
parent
b1e6881fd2
commit
34f00a7f9e
1 changed files with 12 additions and 3 deletions
|
|
@ -213,6 +213,12 @@ function NodeOutputField({
|
|||
[flowPool, flowPoolId, flowPoolNode?.data, internalOutputName],
|
||||
);
|
||||
|
||||
const emptyOutput = useMemo(() => {
|
||||
return Object.keys(flowPoolNode?.data?.outputs ?? {})?.every(
|
||||
(key) => flowPoolNode?.data?.outputs[key]?.message?.length === 0,
|
||||
);
|
||||
}, [flowPoolNode?.data?.outputs]);
|
||||
|
||||
const disabledOutput = useMemo(
|
||||
() => edges.some((edge) => edge.sourceHandle === scapedJSONStringfy(id)),
|
||||
[edges, id],
|
||||
|
|
@ -369,6 +375,9 @@ function NodeOutputField({
|
|||
],
|
||||
);
|
||||
|
||||
const disabledInspectButton =
|
||||
!displayOutputPreview || unknownOutput || emptyOutput;
|
||||
|
||||
if (!showNode) return <>{Handle}</>;
|
||||
|
||||
return (
|
||||
|
|
@ -424,7 +433,7 @@ function NodeOutputField({
|
|||
<ShadTooltip
|
||||
content={
|
||||
displayOutputPreview
|
||||
? unknownOutput
|
||||
? unknownOutput || emptyOutput
|
||||
? "Output can't be displayed"
|
||||
: "Inspect output"
|
||||
: "Please build the component first"
|
||||
|
|
@ -435,12 +444,12 @@ function NodeOutputField({
|
|||
<OutputModal
|
||||
open={openOutputModal}
|
||||
setOpen={setOpenOutputModal}
|
||||
disabled={!displayOutputPreview || unknownOutput}
|
||||
disabled={disabledInspectButton}
|
||||
nodeId={flowPoolId}
|
||||
outputName={internalOutputName}
|
||||
>
|
||||
<InspectButton
|
||||
disabled={!displayOutputPreview || unknownOutput}
|
||||
disabled={disabledInspectButton}
|
||||
displayOutputPreview={displayOutputPreview}
|
||||
unknownOutput={unknownOutput ?? false}
|
||||
errorOutput={errorOutput ?? false}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue