From c70a7e832e4a50fd3527e54d35cc9436551cefb3 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 29 Jul 2025 18:30:48 +0800 Subject: [PATCH] chore: data source add single run button --- .../_base/components/workflow-panel/index.tsx | 41 ++++++++++++++----- .../nodes/data-source/before-run-form.tsx | 19 +++++++++ web/app/components/workflow/utils/workflow.ts | 6 +++ 3 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 web/app/components/workflow/nodes/data-source/before-run-form.tsx diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx index 80c96ee5be..a1566347b2 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx @@ -2,7 +2,7 @@ import type { FC, ReactNode, } from 'react' -import { +import React, { cloneElement, memo, useCallback, @@ -45,8 +45,10 @@ import { canRunBySingle, hasErrorHandleNode, hasRetryNode, + isSupportCustomRunForm, } from '@/app/components/workflow/utils' import Tooltip from '@/app/components/base/tooltip' +import type { CommonNodeType } from '@/app/components/workflow/types' import { BlockEnum, type Node, NodeRunningStatus } from '@/app/components/workflow/types' import { useStore as useAppStore } from '@/app/components/app/store' import { useStore } from '@/app/components/workflow/store' @@ -69,9 +71,19 @@ import { } from '@/app/components/plugins/plugin-auth' import { AuthCategory } from '@/app/components/plugins/plugin-auth' import { canFindTool } from '@/utils' +import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types' import { DataSourceClassification } from '@/app/components/workflow/nodes/data-source/types' import { useModalContext } from '@/context/modal-context' +import DataSourceBeforeRunForm from '@/app/components/workflow/nodes/data-source/before-run-form' +const getCustomRunForm = (nodeType: BlockEnum, payload: CommonNodeType): React.JSX.Element => { + switch (nodeType) { + case BlockEnum.DataSource: + return + default: + return
Custom Run Form: {nodeType} not found
+ } +} type BasePanelProps = { children: ReactNode id: Node['id'] @@ -294,6 +306,8 @@ const BasePanel: FC = ({ } if (isShowSingleRun) { + const form = getCustomRunForm(data.type, data) + return (
= ({ width: `${nodePanelWidth}px`, }} > - + {isSupportCustomRunForm(data.type) ? ( + form + ) : ( + + )} +
) diff --git a/web/app/components/workflow/nodes/data-source/before-run-form.tsx b/web/app/components/workflow/nodes/data-source/before-run-form.tsx new file mode 100644 index 0000000000..b3fa4f1d04 --- /dev/null +++ b/web/app/components/workflow/nodes/data-source/before-run-form.tsx @@ -0,0 +1,19 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import type { DataSourceNodeType } from './types' + +type Props = { + payload: DataSourceNodeType +} + +const BeforeRunForm: FC = ({ + payload, +}) => { + return ( +
+ DataSource: {payload.datasource_name} +
+ ) +} +export default React.memo(BeforeRunForm) diff --git a/web/app/components/workflow/utils/workflow.ts b/web/app/components/workflow/utils/workflow.ts index 81de6d4714..5f8bf27683 100644 --- a/web/app/components/workflow/utils/workflow.ts +++ b/web/app/components/workflow/utils/workflow.ts @@ -37,6 +37,12 @@ export const canRunBySingle = (nodeType: BlockEnum, isChildNode: boolean) => { || nodeType === BlockEnum.IfElse || nodeType === BlockEnum.VariableAggregator || nodeType === BlockEnum.Assigner + || nodeType === BlockEnum.DataSource + // || nodeType === BlockEnum.KnowledgeBase +} + +export const isSupportCustomRunForm = (nodeType: BlockEnum) => { + return nodeType === BlockEnum.DataSource } type ConnectedSourceOrTargetNodesChange = {