mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
feat: insert the hitl config
This commit is contained in:
parent
71a511a470
commit
286ab0d468
@ -1,7 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import PromptEditor from '@/app/components/base/prompt-editor'
|
import PromptEditor from '@/app/components/base/prompt-editor'
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import useAvailableVarList from '../../_base/hooks/use-available-var-list'
|
import useAvailableVarList from '../../_base/hooks/use-available-var-list'
|
||||||
import { BlockEnum } from '../../../types'
|
import { BlockEnum } from '../../../types'
|
||||||
import { useWorkflowVariableType } from '../../../hooks'
|
import { useWorkflowVariableType } from '../../../hooks'
|
||||||
@ -46,21 +46,33 @@ const FormContent: FC<Props> = ({
|
|||||||
|
|
||||||
const getVarType = useWorkflowVariableType()
|
const getVarType = useWorkflowVariableType()
|
||||||
|
|
||||||
|
const [needToAddFormInput, setNeedToAddFormInput] = useState(false)
|
||||||
|
const [newFormInputs, setNewFormInputs] = useState<FormInputItem[]>([])
|
||||||
const handleInsertHITLNode = (onInsert: (command: LexicalCommand<unknown>, params: any) => void) => {
|
const handleInsertHITLNode = (onInsert: (command: LexicalCommand<unknown>, params: any) => void) => {
|
||||||
return (payload: FormInputItem) => {
|
return (payload: FormInputItem) => {
|
||||||
// todo insert into form inputs
|
const newFormInputs = [...(formInputs || []), payload]
|
||||||
onInsert(INSERT_HITL_INPUT_BLOCK_COMMAND, {
|
onInsert(INSERT_HITL_INPUT_BLOCK_COMMAND, {
|
||||||
variableName: payload.output_variable_name,
|
variableName: payload.output_variable_name,
|
||||||
nodeId,
|
nodeId,
|
||||||
nodeTitle,
|
nodeTitle,
|
||||||
formInputs,
|
formInputs: newFormInputs,
|
||||||
onFormInputsChange,
|
onFormInputsChange,
|
||||||
onFormInputItemRename,
|
onFormInputItemRename,
|
||||||
onFormInputItemRemove,
|
onFormInputItemRemove,
|
||||||
})
|
})
|
||||||
|
setNewFormInputs(newFormInputs)
|
||||||
|
setNeedToAddFormInput(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// avoid update formInputs would overwrite the value just inserted
|
||||||
|
useEffect(() => {
|
||||||
|
if (needToAddFormInput) {
|
||||||
|
onFormInputsChange(newFormInputs)
|
||||||
|
setNeedToAddFormInput(false)
|
||||||
|
}
|
||||||
|
}, [value])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PromptEditor
|
<PromptEditor
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user