From d71200ee3285242c4db70f8477281533635fb8f1 Mon Sep 17 00:00:00 2001 From: zhsama Date: Tue, 14 Oct 2025 16:42:21 +0800 Subject: [PATCH] feat: enhance block selector and change block components with flow type handling --- .../block-selector/all-start-blocks.tsx | 35 ++++++++++++++----- .../panel-operator/change-block.tsx | 6 +++- .../workflow/operator/add-block.tsx | 6 +++- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/web/app/components/workflow/block-selector/all-start-blocks.tsx b/web/app/components/workflow/block-selector/all-start-blocks.tsx index f2314ac398..eeedb54bce 100644 --- a/web/app/components/workflow/block-selector/all-start-blocks.tsx +++ b/web/app/components/workflow/block-selector/all-start-blocks.tsx @@ -1,5 +1,10 @@ 'use client' -import { useCallback, useRef, useState } from 'react' +import { + useCallback, + useEffect, + useRef, + useState, +} from 'react' import { useTranslation } from 'react-i18next' import type { BlockEnum, OnSelectBlock } from '../types' import type { TriggerDefaultValue } from './types' @@ -12,6 +17,7 @@ import { RiArrowRightUpLine } from '@remixicon/react' import { getMarketplaceUrl } from '@/utils/var' import Button from '@/app/components/base/button' import { SearchMenu } from '@/app/components/base/icons/src/vender/line/general' +import { BlockEnum as BlockEnumValue } from '../types' type AllStartBlocksProps = { className?: string @@ -25,6 +31,7 @@ const AllStartBlocks = ({ className, searchText, onSelect, + availableBlocksTypes, tags = [], }: AllStartBlocksProps) => { const { t } = useTranslation() @@ -32,6 +39,11 @@ const AllStartBlocks = ({ const [hasStartBlocksContent, setHasStartBlocksContent] = useState(false) const [hasPluginContent, setHasPluginContent] = useState(false) + const entryNodeTypes = availableBlocksTypes?.length + ? availableBlocksTypes + : ENTRY_NODE_TYPES + const enableTriggerPlugin = entryNodeTypes.includes(BlockEnumValue.TriggerPlugin) + const handleStartBlocksContentChange = useCallback((hasContent: boolean) => { setHasStartBlocksContent(hasContent) }, []) @@ -43,6 +55,11 @@ const AllStartBlocks = ({ const hasAnyContent = hasStartBlocksContent || hasPluginContent const shouldShowEmptyState = searchText && !hasAnyContent + useEffect(() => { + if (!enableTriggerPlugin && hasPluginContent) + setHasPluginContent(false) + }, [enableTriggerPlugin, hasPluginContent]) + return (
- + { ( + + )} )}
diff --git a/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx b/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx index cbbf10b63a..4a6bb824ff 100644 --- a/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx +++ b/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx @@ -11,10 +11,12 @@ import { useIsChatMode, useNodesInteractions, } from '@/app/components/workflow/hooks' +import { useHooksStore } from '@/app/components/workflow/hooks-store' import type { Node, OnSelectBlock, } from '@/app/components/workflow/types' +import { FlowType } from '@/types/common' type ChangeBlockProps = { nodeId: string @@ -33,6 +35,8 @@ const ChangeBlock = ({ availableNextBlocks, } = useAvailableBlocks(nodeData.type, nodeData.isInIteration || nodeData.isInLoop) const isChatMode = useIsChatMode() + const flowType = useHooksStore(s => s.configsMap?.flowType) + const showStartTab = flowType !== FlowType.ragPipeline && !isChatMode const availableNodes = useMemo(() => { if (availablePrevBlocks.length && availableNextBlocks.length) @@ -66,7 +70,7 @@ const ChangeBlock = ({ trigger={renderTrigger} popupClassName='min-w-[240px]' availableBlocksTypes={availableNodes} - showStartTab={!isChatMode} + showStartTab={showStartTab} /> ) } diff --git a/web/app/components/workflow/operator/add-block.tsx b/web/app/components/workflow/operator/add-block.tsx index ce1326a78a..c40f2277bb 100644 --- a/web/app/components/workflow/operator/add-block.tsx +++ b/web/app/components/workflow/operator/add-block.tsx @@ -18,6 +18,7 @@ import { useNodesReadOnly, usePanelInteractions, } from '../hooks' +import { useHooksStore } from '../hooks-store' import { useWorkflowStore } from '../store' import TipPopup from './tip-popup' import cn from '@/utils/classnames' @@ -28,6 +29,7 @@ import type { import { BlockEnum, } from '@/app/components/workflow/types' +import { FlowType } from '@/types/common' type AddBlockProps = { renderTrigger?: (open: boolean) => React.ReactNode @@ -46,6 +48,8 @@ const AddBlock = ({ const [open, setOpen] = useState(false) const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, false) const { nodesMap: nodesMetaDataMap } = useNodesMetaData() + const flowType = useHooksStore(s => s.configsMap?.flowType) + const showStartTab = flowType !== FlowType.ragPipeline && !isChatMode const handleOpenChange = useCallback((open: boolean) => { setOpen(open) @@ -110,7 +114,7 @@ const AddBlock = ({ trigger={renderTrigger || renderTriggerElement} popupClassName='!min-w-[256px]' availableBlocksTypes={availableNextBlocks} - showStartTab={!isChatMode} + showStartTab={showStartTab} /> ) }