chatflow/workflow add field required (#18892)

This commit is contained in:
Junjie.M 2025-04-27 16:12:02 +08:00 committed by GitHub
parent 0e0ec4691a
commit e3daef19e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 26 additions and 3 deletions

View File

@ -17,6 +17,7 @@ type Props = {
children?: React.JSX.Element | string | null
operations?: React.JSX.Element
inline?: boolean
required?: boolean
}
const Field: FC<Props> = ({
@ -28,6 +29,7 @@ const Field: FC<Props> = ({
operations,
inline,
supportFold,
required,
}) => {
const [fold, {
toggle: toggleFold,
@ -38,7 +40,9 @@ const Field: FC<Props> = ({
onClick={() => supportFold && toggleFold()}
className={cn('flex items-center justify-between', supportFold && 'cursor-pointer')}>
<div className='flex h-6 items-center'>
<div className={cn(isSubTitle ? 'system-xs-medium-uppercase text-text-tertiary' : 'system-sm-semibold-uppercase text-text-secondary')}>{title}</div>
<div className={cn(isSubTitle ? 'system-xs-medium-uppercase text-text-tertiary' : 'system-sm-semibold-uppercase text-text-secondary')}>
{title} {required && <span className='text-text-destructive'>*</span>}
</div>
{tooltip && (
<Tooltip
popupContent={tooltip}

View File

@ -81,7 +81,11 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
const resetEditor = useStore(s => s.setControlPromptEditorRerenderKey)
return <div className='my-2'>
<Field title={t('workflow.nodes.agent.strategy.label')} className='px-4 py-2' tooltip={t('workflow.nodes.agent.strategy.tooltip')} >
<Field
required
title={t('workflow.nodes.agent.strategy.label')}
className='px-4 py-2'
tooltip={t('workflow.nodes.agent.strategy.tooltip')} >
<AgentStrategy
strategy={inputs.agent_strategy_name ? {
agent_strategy_provider_name: inputs.agent_strategy_provider_name!,

View File

@ -117,8 +117,8 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
operations={
<AddButton onClick={handleAddOutputVariable} />
}
required
>
<OutputVarList
readonly={readOnly}
outputs={inputs.outputs}

View File

@ -64,6 +64,7 @@ const Panel: FC<NodePanelProps<DocExtractorNodeType>> = ({
<div className='space-y-4 px-4 pb-4'>
<Field
title={t(`${i18nPrefix}.inputVar`)}
required
>
<>
<VarReferencePicker

View File

@ -69,6 +69,7 @@ const Panel: FC<NodePanelProps<HttpNodeType>> = ({
<div className='space-y-4 px-4 pb-4'>
<Field
title={t(`${i18nPrefix}.api`)}
required
operations={
<div className='flex'>
<div
@ -126,6 +127,7 @@ const Panel: FC<NodePanelProps<HttpNodeType>> = ({
</Field>
<Field
title={t(`${i18nPrefix}.body`)}
required
>
<EditBody
nodeId={id}

View File

@ -73,6 +73,7 @@ const Panel: FC<NodePanelProps<IterationNodeType>> = ({
<div className='space-y-4 px-4 pb-4'>
<Field
title={t(`${i18nPrefix}.input`)}
required
operations={(
<div className='system-2xs-medium-uppercase flex h-[18px] items-center rounded-[5px] border border-divider-deep px-1 capitalize text-text-tertiary'>Array</div>
)}
@ -91,6 +92,7 @@ const Panel: FC<NodePanelProps<IterationNodeType>> = ({
<div className='mt-2 space-y-4 px-4 pb-4'>
<Field
title={t(`${i18nPrefix}.output`)}
required
operations={(
<div className='system-2xs-medium-uppercase flex h-[18px] items-center rounded-[5px] border border-divider-deep px-1 capitalize text-text-tertiary'>Array</div>
)}

View File

@ -81,6 +81,7 @@ const Panel: FC<NodePanelProps<KnowledgeRetrievalNodeType>> = ({
{/* {JSON.stringify(inputs, null, 2)} */}
<Field
title={t(`${i18nPrefix}.queryVariable`)}
required
>
<VarReferencePicker
nodeId={id}
@ -94,6 +95,7 @@ const Panel: FC<NodePanelProps<KnowledgeRetrievalNodeType>> = ({
<Field
title={t(`${i18nPrefix}.knowledge`)}
required
operations={
<div className='flex items-center space-x-1'>
<RetrievalConfig

View File

@ -46,6 +46,7 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
<div className='space-y-4 px-4'>
<Field
title={t(`${i18nPrefix}.inputVar`)}
required
>
<VarReferencePicker
readonly={readOnly}

View File

@ -147,6 +147,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
<div className='space-y-4 px-4 pb-4'>
<Field
title={t(`${i18nPrefix}.model`)}
required
>
<ModelParameterModal
popupClassName='!w-[387px]'

View File

@ -115,6 +115,7 @@ const Panel: FC<NodePanelProps<ParameterExtractorNodeType>> = ({
<div className='space-y-4 px-4'>
<Field
title={t(`${i18nCommonPrefix}.model`)}
required
>
<ModelParameterModal
popupClassName='!w-[387px]'
@ -133,6 +134,7 @@ const Panel: FC<NodePanelProps<ParameterExtractorNodeType>> = ({
</Field>
<Field
title={t(`${i18nPrefix}.inputVar`)}
required
>
<>
<VarReferencePicker
@ -157,6 +159,7 @@ const Panel: FC<NodePanelProps<ParameterExtractorNodeType>> = ({
/>
<Field
title={t(`${i18nPrefix}.extractParameters`)}
required
operations={
!readOnly
? (

View File

@ -103,6 +103,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
<div className='space-y-4 px-4'>
<Field
title={t(`${i18nPrefix}.model`)}
required
>
<ModelParameterModal
popupClassName='!w-[387px]'
@ -121,6 +122,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
</Field>
<Field
title={t(`${i18nPrefix}.inputVars`)}
required
>
<VarReferencePicker
readonly={readOnly}
@ -143,6 +145,7 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
/>
<Field
title={t(`${i18nPrefix}.class`)}
required
>
<ClassList
nodeId={id}