Commit ede0bb53 authored by StyleZhang's avatar StyleZhang

control run

parent 186b85cd
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
cloneElement, cloneElement,
memo, memo,
useCallback, useCallback,
useState,
} from 'react' } from 'react'
import { type Node } from '../../types' import { type Node } from '../../types'
import { BlockEnum } from '../../types' import { BlockEnum } from '../../types'
...@@ -38,6 +39,7 @@ const BasePanel: FC<BasePanelProps> = ({ ...@@ -38,6 +39,7 @@ const BasePanel: FC<BasePanelProps> = ({
handleNodeSelect, handleNodeSelect,
handleNodeDataUpdate, handleNodeDataUpdate,
} = useWorkflow() } = useWorkflow()
const [controlSingleRun, setControlSingleRun] = useState(0)
const handleTitleChange = useCallback((title: string) => { const handleTitleChange = useCallback((title: string) => {
handleNodeDataUpdate({ id, data: { ...data, title } }) handleNodeDataUpdate({ id, data: { ...data, title } })
}, [handleNodeDataUpdate, id, data]) }, [handleNodeDataUpdate, id, data])
...@@ -64,7 +66,10 @@ const BasePanel: FC<BasePanelProps> = ({ ...@@ -64,7 +66,10 @@ const BasePanel: FC<BasePanelProps> = ({
<TooltipPlus <TooltipPlus
popupContent='Run this step' popupContent='Run this step'
> >
<div className='flex items-center justify-center mr-1 w-6 h-6 rounded-md hover:bg-black/5 cursor-pointer'> <div
className='flex items-center justify-center mr-1 w-6 h-6 rounded-md hover:bg-black/5 cursor-pointer'
onClick={() => !controlSingleRun && setControlSingleRun(Date.now())}
>
<Play className='w-4 h-4 text-gray-500' /> <Play className='w-4 h-4 text-gray-500' />
</div> </div>
</TooltipPlus> </TooltipPlus>
...@@ -88,7 +93,7 @@ const BasePanel: FC<BasePanelProps> = ({ ...@@ -88,7 +93,7 @@ const BasePanel: FC<BasePanelProps> = ({
</div> </div>
</div> </div>
<div className='py-2'> <div className='py-2'>
{cloneElement(children, { id, data })} {cloneElement(children, { id, data, controlSingleRun, setControlSingleRun })}
</div> </div>
{ {
data.type !== BlockEnum.End && ( data.type !== BlockEnum.End && (
......
...@@ -11,7 +11,7 @@ import Field from '@/app/components/workflow/nodes/_base/components/field' ...@@ -11,7 +11,7 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
import Split from '@/app/components/workflow/nodes/_base/components/split' import Split from '@/app/components/workflow/nodes/_base/components/split'
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor' import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
import TypeSelector from '@/app/components/workflow/nodes/_base/components/selector' import TypeSelector from '@/app/components/workflow/nodes/_base/components/selector'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.code' const i18nPrefix = 'workflow.nodes.code'
...@@ -25,7 +25,7 @@ const codeLanguages = [ ...@@ -25,7 +25,7 @@ const codeLanguages = [
value: CodeLanguage.javascript, value: CodeLanguage.javascript,
}, },
] ]
const Panel: FC<NodeProps<CodeNodeType>> = ({ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -8,11 +8,11 @@ import Field from '@/app/components/workflow/nodes/_base/components/field' ...@@ -8,11 +8,11 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
import AddButton from '@/app/components/base/button/add-button' import AddButton from '@/app/components/base/button/add-button'
import Split from '@/app/components/workflow/nodes/_base/components/split' import Split from '@/app/components/workflow/nodes/_base/components/split'
import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor' import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.directAnswer' const i18nPrefix = 'workflow.nodes.directAnswer'
const Panel: FC<NodeProps<DirectAnswerNodeType>> = ({ const Panel: FC<NodePanelProps<DirectAnswerNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -9,7 +9,7 @@ import { EndVarType } from './types' ...@@ -9,7 +9,7 @@ import { EndVarType } from './types'
import VarList from '@/app/components/workflow/nodes/_base/components/variable/var-list' import VarList from '@/app/components/workflow/nodes/_base/components/variable/var-list'
import Field from '@/app/components/workflow/nodes/_base/components/field' import Field from '@/app/components/workflow/nodes/_base/components/field'
import AddButton from '@/app/components/base/button/add-button' import AddButton from '@/app/components/base/button/add-button'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.end' const i18nPrefix = 'workflow.nodes.end'
...@@ -36,7 +36,7 @@ const TypeItem = ({ type, current, onClick }: { type: EndVarType; current: EndVa ...@@ -36,7 +36,7 @@ const TypeItem = ({ type, current, onClick }: { type: EndVarType; current: EndVa
const allTypes = [EndVarType.plainText, EndVarType.structured, EndVarType.none] const allTypes = [EndVarType.plainText, EndVarType.structured, EndVarType.none]
const Panel: FC<NodeProps<EndNodeType>> = ({ const Panel: FC<NodePanelProps<EndNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -13,10 +13,10 @@ import AddButton from '@/app/components/base/button/add-button' ...@@ -13,10 +13,10 @@ import AddButton from '@/app/components/base/button/add-button'
import Split from '@/app/components/workflow/nodes/_base/components/split' import Split from '@/app/components/workflow/nodes/_base/components/split'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import { Settings01 } from '@/app/components/base/icons/src/vender/line/general' import { Settings01 } from '@/app/components/base/icons/src/vender/line/general'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.http' const i18nPrefix = 'workflow.nodes.http'
const Panel: FC<NodeProps<HttpNodeType>> = ({ const Panel: FC<NodePanelProps<HttpNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -7,10 +7,10 @@ import useConfig from './use-config' ...@@ -7,10 +7,10 @@ import useConfig from './use-config'
import ConditionList from './components/condition-list' import ConditionList from './components/condition-list'
import type { IfElseNodeType } from './types' import type { IfElseNodeType } from './types'
import Field from '@/app/components/workflow/nodes/_base/components/field' import Field from '@/app/components/workflow/nodes/_base/components/field'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.ifElse' const i18nPrefix = 'workflow.nodes.ifElse'
const Panel: FC<NodeProps<IfElseNodeType>> = ({ const Panel: FC<NodePanelProps<IfElseNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -10,11 +10,11 @@ import type { KnowledgeRetrievalNodeType } from './types' ...@@ -10,11 +10,11 @@ import type { KnowledgeRetrievalNodeType } from './types'
import Field from '@/app/components/workflow/nodes/_base/components/field' import Field from '@/app/components/workflow/nodes/_base/components/field'
import Split from '@/app/components/workflow/nodes/_base/components/split' import Split from '@/app/components/workflow/nodes/_base/components/split'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.knowledgeRetrieval' const i18nPrefix = 'workflow.nodes.knowledgeRetrieval'
const Panel: FC<NodeProps<KnowledgeRetrievalNodeType>> = ({ const Panel: FC<NodePanelProps<KnowledgeRetrievalNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -12,12 +12,12 @@ import AddButton from '@/app/components/base/button/add-button' ...@@ -12,12 +12,12 @@ import AddButton from '@/app/components/base/button/add-button'
import Split from '@/app/components/workflow/nodes/_base/components/split' import Split from '@/app/components/workflow/nodes/_base/components/split'
import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal' import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import type { NodeProps } from '@/app/components/workflow/types'
import { Resolution } from '@/types/app' import { Resolution } from '@/types/app'
import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.llm' const i18nPrefix = 'workflow.nodes.llm'
const Panel: FC<NodeProps<LLMNodeType>> = ({ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -8,11 +8,11 @@ import AdvancedSetting from './components/advanced-setting' ...@@ -8,11 +8,11 @@ import AdvancedSetting from './components/advanced-setting'
import type { QuestionClassifierNodeType } from './types' import type { QuestionClassifierNodeType } from './types'
import Field from '@/app/components/workflow/nodes/_base/components/field' import Field from '@/app/components/workflow/nodes/_base/components/field'
import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal' import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.questionClassifiers' const i18nPrefix = 'workflow.nodes.questionClassifiers'
const Panel: FC<NodeProps<QuestionClassifierNodeType>> = ({ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -9,11 +9,11 @@ import Field from '@/app/components/workflow/nodes/_base/components/field' ...@@ -9,11 +9,11 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import AddButton from '@/app/components/base/button/add-button' import AddButton from '@/app/components/base/button/add-button'
import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal' import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal'
import type { InputVar, NodeProps } from '@/app/components/workflow/types' import type { InputVar, NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.start' const i18nPrefix = 'workflow.nodes.start'
const Panel: FC<NodeProps<StartNodeType>> = ({ const Panel: FC<NodePanelProps<StartNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -10,11 +10,11 @@ import Split from '@/app/components/workflow/nodes/_base/components/split' ...@@ -10,11 +10,11 @@ import Split from '@/app/components/workflow/nodes/_base/components/split'
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor' import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general' import { HelpCircle } from '@/app/components/base/icons/src/vender/line/general'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.templateTransform' const i18nPrefix = 'workflow.nodes.templateTransform'
const Panel: FC<NodeProps<TemplateTransformNodeType>> = ({ const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -5,11 +5,11 @@ import Split from '../_base/components/split' ...@@ -5,11 +5,11 @@ import Split from '../_base/components/split'
import type { ToolNodeType } from './types' import type { ToolNodeType } from './types'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import Field from '@/app/components/workflow/nodes/_base/components/field' import Field from '@/app/components/workflow/nodes/_base/components/field'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.tool' const i18nPrefix = 'workflow.nodes.tool'
const Panel: FC<NodeProps<ToolNodeType>> = ({ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -8,10 +8,10 @@ import Field from '@/app/components/workflow/nodes/_base/components/field' ...@@ -8,10 +8,10 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
import Selector from '@/app/components/workflow/nodes/_base/components/selector' import Selector from '@/app/components/workflow/nodes/_base/components/selector'
import AddButton from '@/app/components/base/button/add-button' import AddButton from '@/app/components/base/button/add-button'
import { ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows' import { ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows'
import type { NodeProps } from '@/app/components/workflow/types' import type { NodePanelProps } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.variableAssigner' const i18nPrefix = 'workflow.nodes.variableAssigner'
const Panel: FC<NodeProps<VariableAssignerNodeType>> = ({ const Panel: FC<NodePanelProps<VariableAssignerNodeType>> = ({
id, id,
data, data,
}) => { }) => {
......
...@@ -40,6 +40,12 @@ export type CommonEdgeType = { ...@@ -40,6 +40,12 @@ export type CommonEdgeType = {
export type Node = ReactFlowNode<CommonNodeType> export type Node = ReactFlowNode<CommonNodeType>
export type SelectedNode = Pick<Node, 'id' | 'data'> export type SelectedNode = Pick<Node, 'id' | 'data'>
export type NodeProps<T> = { id: string; data: CommonNodeType<T> } export type NodeProps<T> = { id: string; data: CommonNodeType<T> }
export type NodePanelProps<T> = {
id: string
data: CommonNodeType<T>
controlSingleRun: boolean
setControlSingleRun: (value: boolean) => void
}
export type Edge = ReactFlowEdge<CommonEdgeType> export type Edge = ReactFlowEdge<CommonEdgeType>
export type ValueSelector = string[] // [nodeId, key | obj key path] export type ValueSelector = string[] // [nodeId, key | obj key path]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment