mirror of https://github.com/langgenius/dify.git
control run
This commit is contained in:
parent
186b85cd62
commit
ede0bb5396
|
|
@ -6,6 +6,7 @@ import {
|
|||
cloneElement,
|
||||
memo,
|
||||
useCallback,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { type Node } from '../../types'
|
||||
import { BlockEnum } from '../../types'
|
||||
|
|
@ -38,6 +39,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
handleNodeSelect,
|
||||
handleNodeDataUpdate,
|
||||
} = useWorkflow()
|
||||
const [controlSingleRun, setControlSingleRun] = useState(0)
|
||||
const handleTitleChange = useCallback((title: string) => {
|
||||
handleNodeDataUpdate({ id, data: { ...data, title } })
|
||||
}, [handleNodeDataUpdate, id, data])
|
||||
|
|
@ -64,7 +66,10 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
<TooltipPlus
|
||||
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' />
|
||||
</div>
|
||||
</TooltipPlus>
|
||||
|
|
@ -88,7 +93,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
</div>
|
||||
</div>
|
||||
<div className='py-2'>
|
||||
{cloneElement(children, { id, data })}
|
||||
{cloneElement(children, { id, data, controlSingleRun, setControlSingleRun })}
|
||||
</div>
|
||||
{
|
||||
data.type !== BlockEnum.End && (
|
||||
|
|
|
|||
|
|
@ -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 CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
||||
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'
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ const codeLanguages = [
|
|||
value: CodeLanguage.javascript,
|
||||
},
|
||||
]
|
||||
const Panel: FC<NodeProps<CodeNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<CodeNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ import Field from '@/app/components/workflow/nodes/_base/components/field'
|
|||
import AddButton from '@/app/components/base/button/add-button'
|
||||
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
||||
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 Panel: FC<NodeProps<DirectAnswerNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<DirectAnswerNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { EndVarType } from './types'
|
|||
import VarList from '@/app/components/workflow/nodes/_base/components/variable/var-list'
|
||||
import Field from '@/app/components/workflow/nodes/_base/components/field'
|
||||
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'
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ const TypeItem = ({ type, current, onClick }: { type: EndVarType; current: EndVa
|
|||
|
||||
const allTypes = [EndVarType.plainText, EndVarType.structured, EndVarType.none]
|
||||
|
||||
const Panel: FC<NodeProps<EndNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<EndNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ import AddButton from '@/app/components/base/button/add-button'
|
|||
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
||||
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
||||
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 Panel: FC<NodeProps<HttpNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<HttpNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ import useConfig from './use-config'
|
|||
import ConditionList from './components/condition-list'
|
||||
import type { IfElseNodeType } from './types'
|
||||
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 Panel: FC<NodeProps<IfElseNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<IfElseNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ import type { KnowledgeRetrievalNodeType } from './types'
|
|||
import Field from '@/app/components/workflow/nodes/_base/components/field'
|
||||
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
||||
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 Panel: FC<NodeProps<KnowledgeRetrievalNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<KnowledgeRetrievalNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ import AddButton from '@/app/components/base/button/add-button'
|
|||
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 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 type { NodePanelProps } from '@/app/components/workflow/types'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.llm'
|
||||
|
||||
const Panel: FC<NodeProps<LLMNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ import AdvancedSetting from './components/advanced-setting'
|
|||
import type { QuestionClassifierNodeType } from './types'
|
||||
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 type { NodeProps } from '@/app/components/workflow/types'
|
||||
import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.questionClassifiers'
|
||||
|
||||
const Panel: FC<NodeProps<QuestionClassifierNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -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 AddButton from '@/app/components/base/button/add-button'
|
||||
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 Panel: FC<NodeProps<StartNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<StartNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -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 OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
|
||||
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 Panel: FC<NodeProps<TemplateTransformNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<TemplateTransformNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ import Split from '../_base/components/split'
|
|||
import type { ToolNodeType } from './types'
|
||||
import Button from '@/app/components/base/button'
|
||||
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 Panel: FC<NodeProps<ToolNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<ToolNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -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 AddButton from '@/app/components/base/button/add-button'
|
||||
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 Panel: FC<NodeProps<VariableAssignerNodeType>> = ({
|
||||
const Panel: FC<NodePanelProps<VariableAssignerNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ export type CommonEdgeType = {
|
|||
export type Node = ReactFlowNode<CommonNodeType>
|
||||
export type SelectedNode = Pick<Node, 'id' | 'data'>
|
||||
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 ValueSelector = string[] // [nodeId, key | obj key path]
|
||||
|
|
|
|||
Loading…
Reference in New Issue