diff --git a/web/app/components/workflow/block-selector/all-tools.tsx b/web/app/components/workflow/block-selector/all-tools.tsx index 01eaf74d0f..c8f46f1045 100644 --- a/web/app/components/workflow/block-selector/all-tools.tsx +++ b/web/app/components/workflow/block-selector/all-tools.tsx @@ -3,12 +3,7 @@ import type { RefObject, SetStateAction, } from 'react' -import { - useEffect, - useMemo, - useRef, - useState, -} from 'react' +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import type { BlockEnum, @@ -35,6 +30,7 @@ import Divider from '@/app/components/base/divider' import { RiArrowRightUpLine } from '@remixicon/react' import { getMarketplaceUrl } from '@/utils/var' import { useGetLanguage } from '@/context/i18n' +import type { OnSelectBlock } from '@/app/components/workflow/types' const marketplaceFooterClassName = 'system-sm-medium z-10 flex h-8 flex-none cursor-pointer items-center rounded-b-lg border-[0.5px] border-t border-components-panel-border bg-components-panel-bg-blur px-4 py-1 text-text-accent-light-mode-only shadow-lg' @@ -202,6 +198,12 @@ const AllTools = ({ && (featuredLoading || featuredPlugins.length > 0) const shouldShowMarketplaceFooter = enable_marketplace && !hasFilter + const handleRAGSelect = useCallback((type, pluginDefaultValue) => { + if (!pluginDefaultValue) + return + onSelect(type, pluginDefaultValue as ToolDefaultValue) + }, [onSelect]) + return (
@@ -236,7 +238,7 @@ const AllTools = ({ {isShowRAGRecommendations && onTagsChange && ( )} @@ -274,7 +276,6 @@ const AllTools = ({ hasSearchText={hasSearchText} selectedTools={selectedTools} canChooseMCPTool={canChooseMCPTool} - isShowRAGRecommendations={isShowRAGRecommendations} /> )} diff --git a/web/app/components/workflow/block-selector/rag-tool-recommendations/list.tsx b/web/app/components/workflow/block-selector/rag-tool-recommendations/list.tsx index 19378caf48..8c98fa9d7c 100644 --- a/web/app/components/workflow/block-selector/rag-tool-recommendations/list.tsx +++ b/web/app/components/workflow/block-selector/rag-tool-recommendations/list.tsx @@ -1,7 +1,4 @@ -import { - useMemo, - useRef, -} from 'react' +import { useCallback, useMemo, useRef } from 'react' import type { BlockEnum, ToolWithProvider } from '../../types' import type { ToolDefaultValue } from '../types' import { ViewType } from '../view-type-select' @@ -12,9 +9,10 @@ import ToolListTreeView from '../tool/tool-list-tree-view/list' import ToolListFlatView from '../tool/tool-list-flat-view/list' import UninstalledItem from './uninstalled-item' import type { Plugin } from '@/app/components/plugins/types' +import type { OnSelectBlock } from '@/app/components/workflow/types' type ListProps = { - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: OnSelectBlock tools: ToolWithProvider[] viewType: ViewType unInstalledPlugins: Plugin[] @@ -62,6 +60,10 @@ const List = ({ const toolRefs = useRef({}) + const handleSelect = useCallback((type: BlockEnum, tool: ToolDefaultValue) => { + onSelect(type, tool) + }, [onSelect]) + return (
{!!tools.length && ( @@ -72,7 +74,7 @@ const List = ({ payload={listViewToolData} isShowLetterIndex={false} hasSearchText={false} - onSelect={onSelect} + onSelect={handleSelect} canNotSelectMultiple indexBar={null} /> @@ -80,7 +82,7 @@ const List = ({ ) diff --git a/web/app/components/workflow/block-selector/tools.tsx b/web/app/components/workflow/block-selector/tools.tsx index 0b1a0041f2..c62f6a67f9 100644 --- a/web/app/components/workflow/block-selector/tools.tsx +++ b/web/app/components/workflow/block-selector/tools.tsx @@ -1,9 +1,4 @@ -import { - memo, - useMemo, - useRef, -} from 'react' -import { useTranslation } from 'react-i18next' +import { memo, useMemo, useRef } from 'react' import type { BlockEnum, ToolWithProvider } from '../types' import IndexBar, { groupItems } from './index-bar' import type { ToolDefaultValue, ToolValue } from './types' @@ -28,7 +23,6 @@ type ToolsProps = { indexBarClassName?: string selectedTools?: ToolValue[] canChooseMCPTool?: boolean - isShowRAGRecommendations?: boolean } const Tools = ({ onSelect, @@ -43,10 +37,8 @@ const Tools = ({ indexBarClassName, selectedTools, canChooseMCPTool, - isShowRAGRecommendations = false, }: ToolsProps) => { // const tools: any = [] - const { t } = useTranslation() const language = useGetLanguage() const isFlatView = viewType === ViewType.flat const isShowLetterIndex = isFlatView && tools.length > 10 @@ -105,11 +97,6 @@ const Tools = ({
)} - {!!tools.length && isShowRAGRecommendations && ( -
- {t('tools.allTools')} -
- )} {!!tools.length && ( isFlatView ? (