mirror of https://github.com/langgenius/dify.git
user action add
This commit is contained in:
parent
b02199145e
commit
fb6c8fa01f
|
|
@ -24,6 +24,7 @@ const Panel: FC<NodePanelProps<HumanInputNodeType>> = ({
|
|||
const { t } = useTranslation()
|
||||
const {
|
||||
inputs,
|
||||
handleUserActionAdd,
|
||||
handleUserActionChange,
|
||||
handleUserActionDelete,
|
||||
handleTimeoutChange,
|
||||
|
|
@ -41,7 +42,7 @@ const Panel: FC<NodePanelProps<HumanInputNodeType>> = ({
|
|||
<div className='flex items-center px-1'>
|
||||
<ActionButton
|
||||
onClick={() => {
|
||||
inputs.userActions.push({
|
||||
handleUserActionAdd({
|
||||
id: uuid4(),
|
||||
name: 'Action',
|
||||
text: 'Button Text',
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ const useConfig = (id: string, payload: HumanInputNodeType) => {
|
|||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||
const { inputs, setInputs } = useNodeCrud<HumanInputNodeType>(id, payload)
|
||||
|
||||
const handleUserActionAdd = (newAction: UserAction) => {
|
||||
setInputs({
|
||||
...inputs,
|
||||
userActions: [...inputs.userActions, newAction],
|
||||
})
|
||||
}
|
||||
|
||||
const handleUserActionChange = (updatedAction: UserAction) => {
|
||||
const newActions = produce(inputs.userActions, (draft) => {
|
||||
const index = draft.findIndex(a => a.id === updatedAction.id)
|
||||
|
|
@ -38,6 +45,7 @@ const useConfig = (id: string, payload: HumanInputNodeType) => {
|
|||
return {
|
||||
readOnly,
|
||||
inputs,
|
||||
handleUserActionAdd,
|
||||
handleUserActionChange,
|
||||
handleUserActionDelete,
|
||||
handleTimeoutChange,
|
||||
|
|
|
|||
Loading…
Reference in New Issue