mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 11:56:55 +08:00
fix: output node vars check
This commit is contained in:
parent
9f59baed10
commit
132a86dcb3
@ -13,10 +13,27 @@ const nodeDefault: NodeDefault<EndNodeType> = {
|
|||||||
defaultValue: {
|
defaultValue: {
|
||||||
outputs: [],
|
outputs: [],
|
||||||
},
|
},
|
||||||
checkValid() {
|
checkValid(payload: EndNodeType, t: any) {
|
||||||
|
const outputs = payload.outputs || []
|
||||||
|
|
||||||
|
let errorMessage = ''
|
||||||
|
if (!outputs.length) {
|
||||||
|
errorMessage = t('workflow.errorMsg.fieldRequired', { field: t('workflow.nodes.end.output.variable') })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const invalidOutput = outputs.find((output) => {
|
||||||
|
const variableName = output.variable?.trim()
|
||||||
|
const hasSelector = Array.isArray(output.value_selector) && output.value_selector.length > 0
|
||||||
|
return !variableName || !hasSelector
|
||||||
|
})
|
||||||
|
|
||||||
|
if (invalidOutput)
|
||||||
|
errorMessage = t('workflow.errorMsg.fieldRequired', { field: t('workflow.nodes.end.output.variable') })
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isValid: true,
|
isValid: !errorMessage,
|
||||||
errorMessage: '',
|
errorMessage,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ const Panel: FC<NodePanelProps<EndNodeType>> = ({
|
|||||||
|
|
||||||
<Field
|
<Field
|
||||||
title={t(`${i18nPrefix}.output.variable`)}
|
title={t(`${i18nPrefix}.output.variable`)}
|
||||||
|
required
|
||||||
operations={
|
operations={
|
||||||
!readOnly ? <AddButton onClick={handleAddVariable} /> : undefined
|
!readOnly ? <AddButton onClick={handleAddVariable} /> : undefined
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user