From 58e4c0793a277be7c8732844e3d4aa6c9e5565cc Mon Sep 17 00:00:00 2001 From: lyzno1 Date: Fri, 17 Oct 2025 21:25:28 +0800 Subject: [PATCH] feat: align tool selector empty state with start blocks --- .../workflow/block-selector/all-tools.tsx | 102 ++++++++++++------ 1 file changed, 68 insertions(+), 34 deletions(-) diff --git a/web/app/components/workflow/block-selector/all-tools.tsx b/web/app/components/workflow/block-selector/all-tools.tsx index d275e49379..8234b932df 100644 --- a/web/app/components/workflow/block-selector/all-tools.tsx +++ b/web/app/components/workflow/block-selector/all-tools.tsx @@ -9,6 +9,7 @@ import { useRef, useState, } from 'react' +import { useTranslation } from 'react-i18next' import type { BlockEnum, ToolWithProvider, @@ -19,6 +20,8 @@ import Tools from './tools' import { useToolTabs } from './hooks' import ViewTypeSelect, { ViewType } from './view-type-select' import cn from '@/utils/classnames' +import Button from '@/app/components/base/button' +import { SearchMenu } from '@/app/components/base/icons/src/vender/line/general' import { useGetLanguage } from '@/context/i18n' import type { ListRef } from '@/app/components/workflow/block-selector/market-place-plugin/list' import PluginList, { type ListProps } from '@/app/components/workflow/block-selector/market-place-plugin/list' @@ -26,6 +29,7 @@ import { PluginCategoryEnum } from '../../plugins/types' import { useMarketplacePlugins } from '../../plugins/marketplace/hooks' import { useGlobalPublicStore } from '@/context/global-public-context' import RAGToolSuggestions from './rag-tool-suggestions' +import Link from 'next/link' type AllToolsProps = { className?: string @@ -64,11 +68,15 @@ const AllTools = ({ onTagsChange, isInRAGPipeline = false, }: AllToolsProps) => { + const { t } = useTranslation() const language = useGetLanguage() const tabs = useToolTabs() const [activeTab, setActiveTab] = useState(ToolTypeEnum.All) const [activeView, setActiveView] = useState(ViewType.flat) - const hasFilter = searchText || tags.length > 0 + const trimmedSearchText = searchText.trim() + const hasSearchText = trimmedSearchText.length > 0 + const hasTags = tags.length > 0 + const hasFilter = hasSearchText || hasTags const isMatchingKeywords = (text: string, keywords: string) => { return text.toLowerCase().includes(keywords.toLowerCase()) } @@ -85,7 +93,7 @@ const AllTools = ({ if (activeTab === ToolTypeEnum.MCP) mergedTools = mcpTools - const normalizedSearch = searchText.trim().toLowerCase() + const normalizedSearch = trimmedSearchText.toLowerCase() if (!hasFilter || !normalizedSearch) return mergedTools.filter(toolWithProvider => toolWithProvider.tools.length > 0) @@ -120,7 +128,7 @@ const AllTools = ({ return acc }, []) - }, [activeTab, buildInTools, customTools, workflowTools, mcpTools, searchText, language, hasFilter]) + }, [activeTab, buildInTools, customTools, workflowTools, mcpTools, trimmedSearchText, language, hasFilter]) const { queryPluginsWithDebounced: fetchPlugins, @@ -130,20 +138,23 @@ const AllTools = ({ const { enable_marketplace } = useGlobalPublicStore(s => s.systemFeatures) useEffect(() => { if (!enable_marketplace) return - if (searchText || tags.length > 0) { + if (hasFilter) { fetchPlugins({ query: searchText, tags, category: PluginCategoryEnum.tool, }) } - }, [searchText, tags, enable_marketplace]) + }, [searchText, tags, enable_marketplace, hasFilter, fetchPlugins]) const pluginRef = useRef(null) const wrapElemRef = useRef(null) const isSupportGroupView = [ToolTypeEnum.All, ToolTypeEnum.BuiltIn].includes(activeTab) const isShowRAGRecommendations = isInRAGPipeline && activeTab === ToolTypeEnum.All && !hasFilter + const hasToolsContent = tools.length > 0 + const hasPluginContent = enable_marketplace && notInstalledPlugins.length > 0 + const shouldShowEmptyState = hasFilter && !hasToolsContent && !hasPluginContent return (
@@ -171,39 +182,62 @@ const AllTools = ({
- {isShowRAGRecommendations && onTagsChange && ( - + {isShowRAGRecommendations && onTagsChange && ( + + )} + - )} - - {/* Plugins from marketplace */} - {enable_marketplace && ( - } - list={notInstalledPlugins} - searchText={searchText} - toolContentClassName={toolContentClassName} - tags={tags} + canNotSelectMultiple={canNotSelectMultiple} + onSelectMultiple={onSelectMultiple} + toolType={activeTab} + viewType={isSupportGroupView ? activeView : ViewType.flat} + hasSearchText={hasSearchText} + selectedTools={selectedTools} + canChooseMCPTool={canChooseMCPTool} + isShowRAGRecommendations={isShowRAGRecommendations} /> + {/* Plugins from marketplace */} + {enable_marketplace && ( + } + list={notInstalledPlugins} + searchText={searchText} + toolContentClassName={toolContentClassName} + tags={tags} + /> + )} +
+ + {shouldShowEmptyState && ( +
+ +
+ {t('workflow.tabs.noPluginsFound')} +
+ + + +
)}