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 52ebe3608f..8c0f930251 100644 --- a/web/app/components/plugins/plugin-detail-panel/action-list.tsx +++ b/web/app/components/plugins/plugin-detail-panel/action-list.tsx @@ -1,37 +1,98 @@ -import React 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' +import { useAppContext } from '@/context/app-context' import Button from '@/app/components/base/button' +import Toast from '@/app/components/base/toast' import Indicator from '@/app/components/header/indicator' - -const ActionCard = () => { - return ( -
-
Notion Page Search
-
A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.
-
- ) -} +import ToolItem from '@/app/components/tools/provider/tool-item' +import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials' +import { + fetchBuiltInToolList, + removeBuiltInToolCredential, + updateBuiltInToolCredential, +} from '@/service/tools' const ActionList = () => { const { t } = useTranslation() - // TODO use tool-item add api in tool providers + const { isCurrentWorkspaceManager } = useAppContext() + const currentPluginDetail = usePluginPageContext(v => v.currentPluginDetail) + const providerDeclaration = currentPluginDetail.declaration.tool.identity + const { data } = useSWR( + `/workspaces/current/tool-provider/builtin/${currentPluginDetail.plugin_id}/${currentPluginDetail.name}/tools`, + fetchBuiltInToolList, + ) + + const [showSettingAuth, setShowSettingAuth] = useState(false) + + const handleCredentialSettingUpdate = () => {} + + if (!data) + return null + return (
- {t('plugin.detailPanel.actionNum', { num: 3 })} - + {t('plugin.detailPanel.actionNum', { num: data.length })} + {providerDeclaration.is_team_authorization && ( + + )}
- + {!providerDeclaration.is_team_authorization && ( + + )}
- - - + {data.map(tool => ( + + ))}
+ {showSettingAuth && ( + setShowSettingAuth(false)} + onSaved={async (value) => { + await updateBuiltInToolCredential(providerDeclaration.name, value) + Toast.notify({ + type: 'success', + message: t('common.api.actionSuccess'), + }) + handleCredentialSettingUpdate() + setShowSettingAuth(false) + }} + onRemove={async () => { + await removeBuiltInToolCredential(providerDeclaration.name) + Toast.notify({ + type: 'success', + message: t('common.api.actionSuccess'), + }) + handleCredentialSettingUpdate() + setShowSettingAuth(false) + }} + /> + )}
) }