use all tool list api

pull/22091/head
JzoNg 11 months ago
parent f0c89fe4e5
commit d4f666a480

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

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

Loading…
Cancel
Save