user action add

This commit is contained in:
JzoNg 2025-08-01 14:26:21 +08:00
parent b02199145e
commit fb6c8fa01f
2 changed files with 10 additions and 1 deletions

View File

@ -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',

View File

@ -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,