From fb6c8fa01ffa07c1bea50dfe2ac1665441cbaeb7 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Fri, 1 Aug 2025 14:26:21 +0800 Subject: [PATCH] user action add --- web/app/components/workflow/nodes/human-input/panel.tsx | 3 ++- .../components/workflow/nodes/human-input/use-config.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/nodes/human-input/panel.tsx b/web/app/components/workflow/nodes/human-input/panel.tsx index e54f57c0a4..e0f8a287d3 100644 --- a/web/app/components/workflow/nodes/human-input/panel.tsx +++ b/web/app/components/workflow/nodes/human-input/panel.tsx @@ -24,6 +24,7 @@ const Panel: FC> = ({ const { t } = useTranslation() const { inputs, + handleUserActionAdd, handleUserActionChange, handleUserActionDelete, handleTimeoutChange, @@ -41,7 +42,7 @@ const Panel: FC> = ({
{ - inputs.userActions.push({ + handleUserActionAdd({ id: uuid4(), name: 'Action', text: 'Button Text', diff --git a/web/app/components/workflow/nodes/human-input/use-config.ts b/web/app/components/workflow/nodes/human-input/use-config.ts index 148c4d5c83..09effafe23 100644 --- a/web/app/components/workflow/nodes/human-input/use-config.ts +++ b/web/app/components/workflow/nodes/human-input/use-config.ts @@ -8,6 +8,13 @@ const useConfig = (id: string, payload: HumanInputNodeType) => { const { nodesReadOnly: readOnly } = useNodesReadOnly() const { inputs, setInputs } = useNodeCrud(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,