mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-15 19:55:58 +08:00
fix: end node limit in next step (#4945)
This commit is contained in:
parent
7749b71fff
commit
a4041cb40b
@ -4,34 +4,33 @@ import {
|
|||||||
} from 'react'
|
} from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
import {
|
||||||
useNodesExtraData,
|
useAvailableBlocks,
|
||||||
useNodesInteractions,
|
useNodesInteractions,
|
||||||
useNodesReadOnly,
|
useNodesReadOnly,
|
||||||
} from '@/app/components/workflow/hooks'
|
} from '@/app/components/workflow/hooks'
|
||||||
import BlockSelector from '@/app/components/workflow/block-selector'
|
import BlockSelector from '@/app/components/workflow/block-selector'
|
||||||
import { Plus } from '@/app/components/base/icons/src/vender/line/general'
|
import { Plus } from '@/app/components/base/icons/src/vender/line/general'
|
||||||
import type {
|
import type {
|
||||||
BlockEnum,
|
CommonNodeType,
|
||||||
OnSelectBlock,
|
OnSelectBlock,
|
||||||
} from '@/app/components/workflow/types'
|
} from '@/app/components/workflow/types'
|
||||||
|
|
||||||
type AddProps = {
|
type AddProps = {
|
||||||
nodeId: string
|
nodeId: string
|
||||||
nodeType: BlockEnum
|
nodeData: CommonNodeType
|
||||||
sourceHandle: string
|
sourceHandle: string
|
||||||
branchName?: string
|
branchName?: string
|
||||||
}
|
}
|
||||||
const Add = ({
|
const Add = ({
|
||||||
nodeId,
|
nodeId,
|
||||||
nodeType,
|
nodeData,
|
||||||
sourceHandle,
|
sourceHandle,
|
||||||
branchName,
|
branchName,
|
||||||
}: AddProps) => {
|
}: AddProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { handleNodeAdd } = useNodesInteractions()
|
const { handleNodeAdd } = useNodesInteractions()
|
||||||
const nodesExtraData = useNodesExtraData()
|
|
||||||
const { nodesReadOnly } = useNodesReadOnly()
|
const { nodesReadOnly } = useNodesReadOnly()
|
||||||
const availableNextNodes = nodesExtraData[nodeType].availableNextNodes
|
const { availableNextBlocks } = useAvailableBlocks(nodeData.type, nodeData.isInIteration)
|
||||||
|
|
||||||
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
const handleSelect = useCallback<OnSelectBlock>((type, toolDefaultValue) => {
|
||||||
handleNodeAdd(
|
handleNodeAdd(
|
||||||
@ -82,7 +81,7 @@ const Add = ({
|
|||||||
offset={0}
|
offset={0}
|
||||||
trigger={renderTrigger}
|
trigger={renderTrigger}
|
||||||
popupClassName='!w-[328px]'
|
popupClassName='!w-[328px]'
|
||||||
availableBlocksTypes={availableNextNodes}
|
availableBlocksTypes={availableNextBlocks}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ const NextStep = ({
|
|||||||
!nodeWithBranches && !outgoers.length && (
|
!nodeWithBranches && !outgoers.length && (
|
||||||
<Add
|
<Add
|
||||||
nodeId={selectedNode!.id}
|
nodeId={selectedNode!.id}
|
||||||
nodeType={selectedNode!.data.type}
|
nodeData={selectedNode!.data}
|
||||||
sourceHandle='source'
|
sourceHandle='source'
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@ -85,7 +85,7 @@ const NextStep = ({
|
|||||||
<Add
|
<Add
|
||||||
key={branch.id}
|
key={branch.id}
|
||||||
nodeId={selectedNode!.id}
|
nodeId={selectedNode!.id}
|
||||||
nodeType={selectedNode!.data.type}
|
nodeData={selectedNode!.data}
|
||||||
sourceHandle={branch.id}
|
sourceHandle={branch.id}
|
||||||
branchName={branch.name}
|
branchName={branch.name}
|
||||||
/>
|
/>
|
||||||
|
@ -23,8 +23,8 @@ import {
|
|||||||
} from '@/app/components/base/icons/src/vender/line/general'
|
} from '@/app/components/base/icons/src/vender/line/general'
|
||||||
import BlockIcon from '@/app/components/workflow/block-icon'
|
import BlockIcon from '@/app/components/workflow/block-icon'
|
||||||
import {
|
import {
|
||||||
|
useAvailableBlocks,
|
||||||
useNodeDataUpdate,
|
useNodeDataUpdate,
|
||||||
useNodesExtraData,
|
|
||||||
useNodesInteractions,
|
useNodesInteractions,
|
||||||
useNodesReadOnly,
|
useNodesReadOnly,
|
||||||
useNodesSyncDraft,
|
useNodesSyncDraft,
|
||||||
@ -57,8 +57,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
const { handleNodeSelect } = useNodesInteractions()
|
const { handleNodeSelect } = useNodesInteractions()
|
||||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||||
const { nodesReadOnly } = useNodesReadOnly()
|
const { nodesReadOnly } = useNodesReadOnly()
|
||||||
const nodesExtraData = useNodesExtraData()
|
const { availableNextBlocks } = useAvailableBlocks(data.type, data.isInIteration)
|
||||||
const availableNextNodes = nodesExtraData[data.type].availableNextNodes
|
|
||||||
const toolIcon = useToolIcon(data)
|
const toolIcon = useToolIcon(data)
|
||||||
|
|
||||||
const handleResize = useCallback((width: number) => {
|
const handleResize = useCallback((width: number) => {
|
||||||
@ -157,7 +156,7 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||||||
{cloneElement(children, { id, data })}
|
{cloneElement(children, { id, data })}
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
!!availableNextNodes.length && (
|
!!availableNextBlocks.length && (
|
||||||
<div className='p-4 border-t-[0.5px] border-t-black/5'>
|
<div className='p-4 border-t-[0.5px] border-t-black/5'>
|
||||||
<div className='flex items-center mb-1 text-gray-700 text-[13px] font-semibold'>
|
<div className='flex items-center mb-1 text-gray-700 text-[13px] font-semibold'>
|
||||||
{t('workflow.panel.nextStep').toLocaleUpperCase()}
|
{t('workflow.panel.nextStep').toLocaleUpperCase()}
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
generateNewNode,
|
generateNewNode,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import {
|
import {
|
||||||
useNodesExtraData,
|
useAvailableBlocks,
|
||||||
useNodesReadOnly,
|
useNodesReadOnly,
|
||||||
usePanelInteractions,
|
usePanelInteractions,
|
||||||
} from '../hooks'
|
} from '../hooks'
|
||||||
@ -38,11 +38,10 @@ const AddBlock = ({
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const store = useStoreApi()
|
const store = useStoreApi()
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
const nodesExtraData = useNodesExtraData()
|
|
||||||
const { nodesReadOnly } = useNodesReadOnly()
|
const { nodesReadOnly } = useNodesReadOnly()
|
||||||
const { handlePaneContextmenuCancel } = usePanelInteractions()
|
const { handlePaneContextmenuCancel } = usePanelInteractions()
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const availableNextNodes = nodesExtraData[BlockEnum.Start].availableNextNodes
|
const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, false)
|
||||||
|
|
||||||
const handleOpenChange = useCallback((open: boolean) => {
|
const handleOpenChange = useCallback((open: boolean) => {
|
||||||
setOpen(open)
|
setOpen(open)
|
||||||
@ -102,7 +101,7 @@ const AddBlock = ({
|
|||||||
}}
|
}}
|
||||||
trigger={renderTrigger || renderTriggerElement}
|
trigger={renderTrigger || renderTriggerElement}
|
||||||
popupClassName='!min-w-[256px]'
|
popupClassName='!min-w-[256px]'
|
||||||
availableBlocksTypes={availableNextNodes}
|
availableBlocksTypes={availableNextBlocks}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user