diff --git a/web/app/components/workflow/nodes/human-input/components/timeout.tsx b/web/app/components/workflow/nodes/human-input/components/timeout.tsx new file mode 100644 index 0000000000..d40d3dcf42 --- /dev/null +++ b/web/app/components/workflow/nodes/human-input/components/timeout.tsx @@ -0,0 +1,53 @@ +import type { FC } from 'react' +import React from 'react' +import { useTranslation } from 'react-i18next' +import type { Timeout } from '../types' +import Input from '@/app/components/base/input' +import cn from '@/utils/classnames' + +const i18nPrefix = 'workflow.nodes.humanInput' + +type Props = { + timeout: Timeout + onChange: (state: Timeout) => void +} + +const TimeoutInput: FC = ({ + timeout, + onChange, +}) => { + const { t } = useTranslation() + return ( +
+ onChange({ ...timeout, value: Number(e.target.value) })} + /> +
+
onChange({ ...timeout, unit: 'days' })} + > +
{t(`${i18nPrefix}.timeout.days`)}
+
+
onChange({ ...timeout, unit: 'hours' })} + > +
{t(`${i18nPrefix}.timeout.hours`)}
+
+
+
+ ) +} + +export default TimeoutInput diff --git a/web/app/components/workflow/nodes/human-input/default.ts b/web/app/components/workflow/nodes/human-input/default.ts index 773f142b59..4b702f05c6 100644 --- a/web/app/components/workflow/nodes/human-input/default.ts +++ b/web/app/components/workflow/nodes/human-input/default.ts @@ -37,6 +37,10 @@ const nodeDefault: NodeDefault = { type: UserActionButtonType.Ghost, }, ], + timeout: { + value: 3, + unit: 'days', + }, }, getAvailablePrevNodes(isChatMode: boolean) { const nodes = isChatMode diff --git a/web/app/components/workflow/nodes/human-input/node.tsx b/web/app/components/workflow/nodes/human-input/node.tsx index f52d238759..f3278e244a 100644 --- a/web/app/components/workflow/nodes/human-input/node.tsx +++ b/web/app/components/workflow/nodes/human-input/node.tsx @@ -1,5 +1,6 @@ import type { FC } from 'react' import React from 'react' +import { useTranslation } from 'react-i18next' import { RiMailSendFill, RiRobot2Fill, @@ -9,7 +10,11 @@ import type { HumanInputNodeType } from './types' import type { NodeProps } from '@/app/components/workflow/types' import { DeliveryMethodType } from './types' +const i18nPrefix = 'workflow.nodes.humanInput' + const Node: FC> = (props) => { + const { t } = useTranslation() + const { data } = props const deliveryMethods = data.deliveryMethod const userActions = data.userActions @@ -18,7 +23,7 @@ const Node: FC> = (props) => { <> {deliveryMethods.length > 0 && (
-
delivery method
+
{t(`${i18nPrefix}.deliveryMethod.title`)}
{deliveryMethods.map(method => (
diff --git a/web/app/components/workflow/nodes/human-input/panel.tsx b/web/app/components/workflow/nodes/human-input/panel.tsx index 3a115fed0b..9800fc3573 100644 --- a/web/app/components/workflow/nodes/human-input/panel.tsx +++ b/web/app/components/workflow/nodes/human-input/panel.tsx @@ -1,8 +1,11 @@ import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' +import useConfig from './use-config' import type { HumanInputNodeType } from './types' import type { NodePanelProps } from '@/app/components/workflow/types' +import Divider from '@/app/components/base/divider' +import TimeoutInput from './components/timeout' const i18nPrefix = 'workflow.nodes.humanInput' @@ -11,11 +14,21 @@ const Panel: FC> = ({ data, }) => { const { t } = useTranslation() - + const { + inputs, + handleTimeoutChange, + } = useConfig(id, data) return ( -
-
- TODO +
+
+ +
+
+
{t(`${i18nPrefix}.timeout.title`)}
+
) diff --git a/web/app/components/workflow/nodes/human-input/types.ts b/web/app/components/workflow/nodes/human-input/types.ts index 0e06c8509d..6ccad31eb9 100644 --- a/web/app/components/workflow/nodes/human-input/types.ts +++ b/web/app/components/workflow/nodes/human-input/types.ts @@ -4,7 +4,7 @@ export type HumanInputNodeType = CommonNodeType & { deliveryMethod: DeliveryMethod[] formContent: any userActions: UserAction[] - timeout: any + timeout: Timeout outputs: Variable[] } 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 cf17a34bc6..ae99b46013 100644 --- a/web/app/components/workflow/nodes/human-input/use-config.ts +++ b/web/app/components/workflow/nodes/human-input/use-config.ts @@ -1,5 +1,4 @@ -import useVarList from '../_base/hooks/use-var-list' -import type { HumanInputNodeType } from './types' +import type { HumanInputNodeType, Timeout } from './types' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' import { useNodesReadOnly, @@ -8,19 +7,17 @@ const useConfig = (id: string, payload: HumanInputNodeType) => { const { nodesReadOnly: readOnly } = useNodesReadOnly() const { inputs, setInputs } = useNodeCrud(id, payload) - const { handleVarListChange, handleAddVariable } = useVarList({ - inputs, - setInputs: (newInputs) => { - setInputs(newInputs) - }, - varKey: 'outputs', - }) + const handleTimeoutChange = (timeout: Timeout) => { + setInputs({ + ...inputs, + timeout, + }) + } return { readOnly, inputs, - handleVarListChange, - handleAddVariable, + handleTimeoutChange, } } diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 32b8809eed..56516bf13d 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -905,9 +905,16 @@ const translation = { parameterSchema: 'Parameter Schema', }, humanInput: { - deliveryMethod: 'delivery method', + deliveryMethod: { + title: 'Delivery Method', + }, formContent: 'form content', userActions: 'user actions', + timeout: { + title: 'Timeout', + hours: 'Hours', + days: 'Days', + }, }, }, tracing: { diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index bf073c66ed..ae8a7000e4 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -906,9 +906,16 @@ const translation = { parameterSchema: '参数 Schema', }, humanInput: { - deliveryMethod: '提交方式', + deliveryMethod: { + title: '提交方式', + }, formContent: '表单内容', userActions: '用户操作', + timeout: { + title: '超时设置', + hours: '小时', + days: '日', + }, }, }, tracing: {