diff --git a/web/app/components/plugins/plugin-detail-panel/action-list.tsx b/web/app/components/plugins/plugin-detail-panel/action-list.tsx index 13027803d2..c90f1ffb0d 100644 --- a/web/app/components/plugins/plugin-detail-panel/action-list.tsx +++ b/web/app/components/plugins/plugin-detail-panel/action-list.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useState } from 'react' +import React, { useState } from 'react' import useSWR from 'swr' import { useTranslation } from 'react-i18next' import { usePluginPageContext } from '@/app/components/plugins/plugin-page/context' @@ -10,6 +10,7 @@ import ToolItem from '@/app/components/tools/provider/tool-item' import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials' import { fetchBuiltInToolList, + fetchCollectionDetail, removeBuiltInToolCredential, updateBuiltInToolCredential, } from '@/service/tools' @@ -18,12 +19,10 @@ const ActionList = () => { const { t } = useTranslation() const { isCurrentWorkspaceManager } = useAppContext() const currentPluginDetail = usePluginPageContext(v => v.currentPluginDetail) - const providerDeclaration = useMemo(() => { - return { - ...currentPluginDetail.declaration.tool.identity, - name: `${currentPluginDetail.plugin_id}/${currentPluginDetail.name}`, - } - }, [currentPluginDetail.declaration.tool.identity, currentPluginDetail.name, currentPluginDetail.plugin_id]) + const { data: provider } = useSWR( + `builtin/${currentPluginDetail.plugin_id}/${currentPluginDetail.name}`, + fetchCollectionDetail, + ) const { data } = useSWR( `${currentPluginDetail.plugin_id}/${currentPluginDetail.name}`, fetchBuiltInToolList, @@ -33,7 +32,7 @@ const ActionList = () => { const handleCredentialSettingUpdate = () => {} - if (!data) + if (!data || !provider) return null return ( @@ -41,7 +40,7 @@ const ActionList = () => {
{t('plugin.detailPanel.actionNum', { num: data.length })} - {providerDeclaration.is_team_authorization && providerDeclaration.allow_delete && ( + {provider.is_team_authorization && provider.allow_delete && ( )}
- {!providerDeclaration.is_team_authorization && providerDeclaration.allow_delete && ( + {!provider.is_team_authorization && provider.allow_delete && (
{showSettingAuth && ( setShowSettingAuth(false)} onSaved={async (value) => { - await updateBuiltInToolCredential(providerDeclaration.name, value) + await updateBuiltInToolCredential(provider.name, value) Toast.notify({ type: 'success', message: t('common.api.actionSuccess'), @@ -88,7 +87,7 @@ const ActionList = () => { setShowSettingAuth(false) }} onRemove={async () => { - await removeBuiltInToolCredential(providerDeclaration.name) + await removeBuiltInToolCredential(provider.name) Toast.notify({ type: 'success', message: t('common.api.actionSuccess'), diff --git a/web/service/tools.ts b/web/service/tools.ts index 90221edec2..d6b2f2034b 100644 --- a/web/service/tools.ts +++ b/web/service/tools.ts @@ -15,6 +15,10 @@ export const fetchCollectionList = () => { return get('/workspaces/current/tool-providers') } +export const fetchCollectionDetail = (collectionName: string) => { + return get(`/workspaces/current/tool-provider/${collectionName}/info`) +} + export const fetchBuiltInToolList = (collectionName: string) => { return get(`/workspaces/current/tool-provider/builtin/${collectionName}/tools`) }