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],
|
[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(
|
const disabledOutput = useMemo(
|
||||||
() => edges.some((edge) => edge.sourceHandle === scapedJSONStringfy(id)),
|
() => edges.some((edge) => edge.sourceHandle === scapedJSONStringfy(id)),
|
||||||
[edges, id],
|
[edges, id],
|
||||||
|
|
@ -369,6 +375,9 @@ function NodeOutputField({
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const disabledInspectButton =
|
||||||
|
!displayOutputPreview || unknownOutput || emptyOutput;
|
||||||
|
|
||||||
if (!showNode) return <>{Handle}</>;
|
if (!showNode) return <>{Handle}</>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -424,7 +433,7 @@ function NodeOutputField({
|
||||||
<ShadTooltip
|
<ShadTooltip
|
||||||
content={
|
content={
|
||||||
displayOutputPreview
|
displayOutputPreview
|
||||||
? unknownOutput
|
? unknownOutput || emptyOutput
|
||||||
? "Output can't be displayed"
|
? "Output can't be displayed"
|
||||||
: "Inspect output"
|
: "Inspect output"
|
||||||
: "Please build the component first"
|
: "Please build the component first"
|
||||||
|
|
@ -435,12 +444,12 @@ function NodeOutputField({
|
||||||
<OutputModal
|
<OutputModal
|
||||||
open={openOutputModal}
|
open={openOutputModal}
|
||||||
setOpen={setOpenOutputModal}
|
setOpen={setOpenOutputModal}
|
||||||
disabled={!displayOutputPreview || unknownOutput}
|
disabled={disabledInspectButton}
|
||||||
nodeId={flowPoolId}
|
nodeId={flowPoolId}
|
||||||
outputName={internalOutputName}
|
outputName={internalOutputName}
|
||||||
>
|
>
|
||||||
<InspectButton
|
<InspectButton
|
||||||
disabled={!displayOutputPreview || unknownOutput}
|
disabled={disabledInspectButton}
|
||||||
displayOutputPreview={displayOutputPreview}
|
displayOutputPreview={displayOutputPreview}
|
||||||
unknownOutput={unknownOutput ?? false}
|
unknownOutput={unknownOutput ?? false}
|
||||||
errorOutput={errorOutput ?? false}
|
errorOutput={errorOutput ?? false}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue