Limit workflow tool/trigger search to provider and item names

This commit is contained in:
lyzno1 2025-10-22 16:53:23 +08:00
parent 9cdb62da93
commit 52b180104a
No known key found for this signature in database
2 changed files with 4 additions and 27 deletions

View File

@ -22,7 +22,6 @@ 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'
import type { Plugin } from '../../plugins/types'
@ -80,7 +79,6 @@ const AllTools = ({
onFeaturedInstallSuccess,
}: AllToolsProps) => {
const { t } = useTranslation()
const language = useGetLanguage()
const tabs = useToolTabs()
const [activeTab, setActiveTab] = useState(ToolTypeEnum.All)
const [activeView, setActiveView] = useState<ViewType>(ViewType.flat)
@ -120,9 +118,7 @@ const AllTools = ({
return mergedTools.filter(toolWithProvider => toolWithProvider.tools.length > 0)
return mergedTools.reduce<ToolWithProvider[]>((acc, toolWithProvider) => {
const providerLabel = toolWithProvider.label?.[language] || ''
const providerMatches = isMatchingKeywords(toolWithProvider.name, normalizedSearch)
|| (providerLabel && isMatchingKeywords(providerLabel, normalizedSearch))
if (providerMatches) {
if (toolWithProvider.tools.length > 0)
@ -131,13 +127,7 @@ const AllTools = ({
}
const matchedTools = toolWithProvider.tools.filter((tool) => {
const toolLabel = tool.label?.[language] || ''
const toolDescription = typeof tool.description === 'object' ? tool.description?.[language] : ''
return (
(toolLabel && toolLabel.toLowerCase().includes(normalizedSearch))
|| tool.name.toLowerCase().includes(normalizedSearch)
|| (typeof toolDescription === 'string' && toolDescription.toLowerCase().includes(normalizedSearch))
)
return tool.name.toLowerCase().includes(normalizedSearch)
})
if (matchedTools.length > 0) {
@ -149,7 +139,7 @@ const AllTools = ({
return acc
}, [])
}, [activeTab, buildInTools, customTools, workflowTools, mcpTools, trimmedSearchText, language, hasFilter])
}, [activeTab, buildInTools, customTools, workflowTools, mcpTools, trimmedSearchText, hasFilter])
const {
queryPluginsWithDebounced: fetchPlugins,

View File

@ -4,7 +4,6 @@ import { useAllTriggerPlugins } from '@/service/use-triggers'
import TriggerPluginItem from './item'
import type { BlockEnum } from '../../types'
import type { TriggerDefaultValue, TriggerWithProvider } from '../types'
import { useGetLanguage } from '@/context/i18n'
type TriggerPluginListProps = {
onSelect: (type: BlockEnum, trigger?: TriggerDefaultValue) => void
@ -19,7 +18,6 @@ const TriggerPluginList = ({
onContentStateChange,
}: TriggerPluginListProps) => {
const { data: triggerPluginsData } = useAllTriggerPlugins()
const language = useGetLanguage()
const normalizedSearch = searchText.trim().toLowerCase()
const triggerPlugins = useMemo(() => {
@ -32,9 +30,7 @@ const TriggerPluginList = ({
if (triggerWithProvider.events.length === 0)
return acc
const providerLabel = triggerWithProvider.label?.[language] || ''
const providerMatches = triggerWithProvider.name.toLowerCase().includes(normalizedSearch)
|| (providerLabel && providerLabel.toLowerCase().includes(normalizedSearch))
if (providerMatches) {
acc.push(triggerWithProvider)
@ -42,16 +38,7 @@ const TriggerPluginList = ({
}
const matchedEvents = triggerWithProvider.events.filter((event) => {
const rawLabel = event.label?.[language]
const eventLabel = typeof rawLabel === 'string' ? rawLabel.toLowerCase() : ''
const rawDescription = event.description?.[language]
const eventDescription = typeof rawDescription === 'string' ? rawDescription.toLowerCase() : ''
return (
eventLabel.includes(normalizedSearch)
|| event.name.toLowerCase().includes(normalizedSearch)
|| eventDescription.includes(normalizedSearch)
)
return event.name.toLowerCase().includes(normalizedSearch)
})
if (matchedEvents.length > 0) {
@ -63,7 +50,7 @@ const TriggerPluginList = ({
return acc
}, [])
}, [triggerPluginsData, normalizedSearch, language])
}, [triggerPluginsData, normalizedSearch])
const hasContent = triggerPlugins.length > 0