From c0a4f3b715592dc463efc92237ad4a5646d6c970 Mon Sep 17 00:00:00 2001 From: twwu Date: Mon, 29 Dec 2025 13:57:34 +0800 Subject: [PATCH] refactor(human-input): reorganize hooks and improve structure for better maintainability --- .../components/workflow-panel/last-run/use-last-run.ts | 2 +- .../workflow/nodes/human-input/{ => hooks}/use-config.ts | 2 +- .../nodes/human-input/{ => hooks}/use-form-content.ts | 4 ++-- .../human-input/{ => hooks}/use-single-run-form-params.ts | 6 +++--- web/app/components/workflow/nodes/human-input/panel.tsx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename web/app/components/workflow/nodes/human-input/{ => hooks}/use-config.ts (99%) rename web/app/components/workflow/nodes/human-input/{ => hooks}/use-form-content.ts (94%) rename web/app/components/workflow/nodes/human-input/{ => hooks}/use-single-run-form-params.ts (96%) diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts index d3c6f6efc8..853296efd5 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts @@ -15,7 +15,7 @@ import useVariableAssignerSingleRunFormParams from '@/app/components/workflow/no import useCodeSingleRunFormParams from '@/app/components/workflow/nodes/code/use-single-run-form-params' import useDocExtractorSingleRunFormParams from '@/app/components/workflow/nodes/document-extractor/use-single-run-form-params' import useHttpRequestSingleRunFormParams from '@/app/components/workflow/nodes/http/use-single-run-form-params' -import useHumanInputSingleRunFormParams from '@/app/components/workflow/nodes/human-input/use-single-run-form-params' +import useHumanInputSingleRunFormParams from '@/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params' import useIfElseSingleRunFormParams from '@/app/components/workflow/nodes/if-else/use-single-run-form-params' import useIterationSingleRunFormParams from '@/app/components/workflow/nodes/iteration/use-single-run-form-params' import useKnowledgeBaseSingleRunFormParams from '@/app/components/workflow/nodes/knowledge-base/use-single-run-form-params' diff --git a/web/app/components/workflow/nodes/human-input/use-config.ts b/web/app/components/workflow/nodes/human-input/hooks/use-config.ts similarity index 99% rename from web/app/components/workflow/nodes/human-input/use-config.ts rename to web/app/components/workflow/nodes/human-input/hooks/use-config.ts index 5f2eeccb13..b980491ca0 100644 --- a/web/app/components/workflow/nodes/human-input/use-config.ts +++ b/web/app/components/workflow/nodes/human-input/hooks/use-config.ts @@ -1,4 +1,4 @@ -import type { DeliveryMethod, HumanInputNodeType, UserAction } from './types' +import type { DeliveryMethod, HumanInputNodeType, UserAction } from '../types' import { produce } from 'immer' import { useState } from 'react' import { diff --git a/web/app/components/workflow/nodes/human-input/use-form-content.ts b/web/app/components/workflow/nodes/human-input/hooks/use-form-content.ts similarity index 94% rename from web/app/components/workflow/nodes/human-input/use-form-content.ts rename to web/app/components/workflow/nodes/human-input/hooks/use-form-content.ts index 69326ef40d..16724d7873 100644 --- a/web/app/components/workflow/nodes/human-input/use-form-content.ts +++ b/web/app/components/workflow/nodes/human-input/hooks/use-form-content.ts @@ -1,7 +1,7 @@ -import type { FormInputItem, HumanInputNodeType } from './types' +import type { FormInputItem, HumanInputNodeType } from '../types' import { produce } from 'immer' import { useCallback, useEffect, useRef, useState } from 'react' -import useNodeCrud from '../_base/hooks/use-node-crud' +import useNodeCrud from '../../_base/hooks/use-node-crud' const useFormContent = (id: string, payload: HumanInputNodeType) => { const [editorKey, setEditorKey] = useState(0) diff --git a/web/app/components/workflow/nodes/human-input/use-single-run-form-params.ts b/web/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts similarity index 96% rename from web/app/components/workflow/nodes/human-input/use-single-run-form-params.ts rename to web/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts index 98796a983f..7ef8a14ae6 100644 --- a/web/app/components/workflow/nodes/human-input/use-single-run-form-params.ts +++ b/web/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts @@ -1,10 +1,10 @@ -import type { HumanInputNodeType } from './types' +import type { HumanInputNodeType } from '../types' import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' import type { InputVar } from '@/app/components/workflow/types' import { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' -import useNodeCrud from '../_base/hooks/use-node-crud' -import { isOutput } from './utils' +import useNodeCrud from '../../_base/hooks/use-node-crud' +import { isOutput } from '../utils' const i18nPrefix = 'workflow.nodes.humanInput' diff --git a/web/app/components/workflow/nodes/human-input/panel.tsx b/web/app/components/workflow/nodes/human-input/panel.tsx index fc77ad8ff9..30907daeaf 100644 --- a/web/app/components/workflow/nodes/human-input/panel.tsx +++ b/web/app/components/workflow/nodes/human-input/panel.tsx @@ -28,8 +28,8 @@ import FormContent from './components/form-content' import FormContentPreview from './components/form-content-preview' import TimeoutInput from './components/timeout' import UserActionItem from './components/user-action' +import useConfig from './hooks/use-config' import { UserActionButtonType } from './types' -import useConfig from './use-config' import { genActionId } from './utils' const i18nPrefix = 'workflow.nodes.humanInput'