* refactor: improve output selection logic and edge updating in GenericNode * feat: enhance output rendering logic for loop and conditional components * feat: add group_outputs flag to output components for enhanced display control * feat: enhance output handling by adding support for hidden outputs in NodeOutputs component * fix: update display output logic to handle tool mode correctly * fix: improve output selection logic in NodeOutputs component * refactor: simplify output selection logic in OutputComponent and GenericNode * refactor: remove commented code and clean up unused memoization in various components * refactor: clean up NodeOutputs component by removing commented code and simplifying output logic * [autofix.ci] apply automated fixes * feat: add group_outputs field to test_output in schema tests * test: Skip grouped components output preview test and add wait times for stability * fix: remove 'group_outputs' property from multiple starter project JSON files * Revert starter_projects folder to main branch state * Revert starter_projects folder to match origin/main exactly * Re-sync starter_projects folder with main branch after merge conflict * Add "group_outputs" property to various agent configurations * test: skip progress tracking test for admin users * test: enable progress tracking for admin users and improve component interaction * test: remove redundant dropdown interaction and enhance multi-select functionality --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
125 lines
3.2 KiB
TypeScript
125 lines
3.2 KiB
TypeScript
import { NodeDataType } from "@/types/flow";
|
|
import { OutputParameter } from ".";
|
|
|
|
export default function NodeOutputs({
|
|
outputs,
|
|
keyPrefix,
|
|
data,
|
|
types,
|
|
selected,
|
|
showNode,
|
|
isToolMode,
|
|
showHiddenOutputs,
|
|
selectedOutput,
|
|
handleSelectOutput,
|
|
}: {
|
|
outputs: any;
|
|
keyPrefix: string;
|
|
data: NodeDataType;
|
|
types: any;
|
|
selected: boolean;
|
|
showNode: boolean;
|
|
isToolMode: boolean;
|
|
showHiddenOutputs: boolean;
|
|
selectedOutput: any;
|
|
handleSelectOutput: any;
|
|
}) {
|
|
const hasLoopOutput = outputs.some((output) => output.allows_loop);
|
|
const hasGroupOutputs = outputs.some((output) => output.group_outputs);
|
|
const isConditionalRouter = data.type === "ConditionalRouter";
|
|
const hasHiddenOutputs = outputs.some((output) => output.hidden);
|
|
|
|
const shouldShowAllOutputs =
|
|
hasLoopOutput || hasGroupOutputs || isConditionalRouter || hasHiddenOutputs;
|
|
|
|
if (shouldShowAllOutputs) {
|
|
const outputsToRender =
|
|
keyPrefix === "hidden"
|
|
? outputs.filter((output) => output.hidden)
|
|
: outputs.filter((output) => !output.hidden);
|
|
|
|
return (
|
|
<>
|
|
{outputsToRender?.map((output, idx) => (
|
|
<OutputParameter
|
|
key={`${keyPrefix}-${output.name}-${idx}`}
|
|
output={output}
|
|
outputs={outputs}
|
|
idx={
|
|
data.node!.outputs?.findIndex(
|
|
(out) => out.name === output.name,
|
|
) ?? idx
|
|
}
|
|
lastOutput={idx === outputsToRender.length - 1}
|
|
data={data}
|
|
types={types}
|
|
selected={selected}
|
|
showNode={showNode}
|
|
isToolMode={isToolMode}
|
|
showHiddenOutputs={showHiddenOutputs}
|
|
handleSelectOutput={handleSelectOutput}
|
|
hidden={
|
|
keyPrefix === "hidden"
|
|
? showHiddenOutputs
|
|
? output.hidden
|
|
: true
|
|
: false
|
|
}
|
|
/>
|
|
))}
|
|
</>
|
|
);
|
|
}
|
|
|
|
const getDisplayOutput = () => {
|
|
const filteredOutputs =
|
|
keyPrefix === "hidden"
|
|
? outputs.filter((output) => output.hidden)
|
|
: outputs.filter((output) => !output.hidden);
|
|
|
|
if (selectedOutput) {
|
|
return (
|
|
filteredOutputs.find((output) => output.name === selectedOutput.name) ||
|
|
filteredOutputs[0]
|
|
);
|
|
}
|
|
|
|
const outputWithSelection = filteredOutputs.find(
|
|
(output) => output.selected,
|
|
);
|
|
|
|
return outputWithSelection || filteredOutputs[0];
|
|
};
|
|
|
|
const displayOutput = getDisplayOutput();
|
|
|
|
if (!displayOutput) return null;
|
|
|
|
return (
|
|
<OutputParameter
|
|
key={`${keyPrefix}-${displayOutput.name}`}
|
|
output={displayOutput}
|
|
outputs={outputs}
|
|
idx={
|
|
data.node!.outputs?.findIndex(
|
|
(out) => out.name === displayOutput.name,
|
|
) ?? 0
|
|
}
|
|
lastOutput={true}
|
|
data={data}
|
|
types={types}
|
|
selected={selected}
|
|
handleSelectOutput={handleSelectOutput}
|
|
showNode={showNode}
|
|
isToolMode={isToolMode}
|
|
showHiddenOutputs={showHiddenOutputs}
|
|
hidden={
|
|
keyPrefix === "hidden"
|
|
? showHiddenOutputs
|
|
? displayOutput.hidden
|
|
: true
|
|
: false
|
|
}
|
|
/>
|
|
);
|
|
}
|