use all tool list api

This commit is contained in:
JzoNg
2025-06-24 20:19:35 +08:00
parent f0c89fe4e5
commit d4f666a480
2 changed files with 7 additions and 12 deletions

View File

@ -4,7 +4,7 @@ import NewMCPCard from './create-card'
import MCPCard from './provider-card'
import MCPDetailPanel from './detail/provider-detail'
import {
useAllMCPTools,
useAllToolProviders,
} from '@/service/use-tools'
import type { ToolWithProvider } from '@/app/components/workflow/types'
import cn from '@/utils/classnames'
@ -34,15 +34,15 @@ function renderDefaultCard() {
const MCPList = ({
searchText,
}: Props) => {
const { data: list = [], refetch } = useAllMCPTools()
const { data: list = [] as ToolWithProvider[], refetch } = useAllToolProviders()
const [isCreation, setIsCreation] = useState<boolean>(false)
const filteredList = useMemo(() => {
return list.filter((collection) => {
if (searchText)
return Object.values(collection.name).some(value => (value as string).toLowerCase().includes(searchText.toLowerCase()))
return true
})
return collection.type === 'mcp'
}) as ToolWithProvider[]
}, [list, searchText])
const [currentProviderID, setCurrentProviderID] = useState<string>()
@ -70,7 +70,7 @@ const MCPList = ({
<MCPCard
key={provider.id}
data={provider}
currentProvider={currentProvider}
currentProvider={currentProvider as ToolWithProvider}
handleSelect={setCurrentProviderID}
onUpdate={refetch}
/>
@ -79,7 +79,7 @@ const MCPList = ({
</div>
{currentProvider && (
<MCPDetailPanel
detail={currentProvider}
detail={currentProvider as ToolWithProvider}
onHide={() => setCurrentProviderID(undefined)}
onUpdate={refetch}
isCreation={isCreation}

View File

@ -1,7 +1,6 @@
'use client'
import { useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useSearchParams } from 'next/navigation'
import type { Collection } from './types'
import Marketplace from './marketplace'
import cn from '@/utils/classnames'
@ -26,12 +25,8 @@ const ProviderList = () => {
const { enable_marketplace } = useGlobalPublicStore(s => s.systemFeatures)
const containerRef = useRef<HTMLDivElement>(null)
const searchParams = useSearchParams()
const authCode = searchParams.get('code') || ''
const providerID = searchParams.get('state') || ''
const [activeTab, setActiveTab] = useTabSearchParams({
defaultTab: authCode && providerID ? 'mcp' : 'builtin',
defaultTab: 'builtin',
})
const options = [
{ value: 'builtin', text: t('tools.type.builtIn') },