diff --git a/web/app/components/tools/provider-list.tsx b/web/app/components/tools/provider-list.tsx index 8f222bb637..4ca28991cc 100644 --- a/web/app/components/tools/provider-list.tsx +++ b/web/app/components/tools/provider-list.tsx @@ -1,7 +1,6 @@ 'use client' import { useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { RiCloseLine } from '@remixicon/react' import type { Collection } from './types' import Marketplace from './marketplace' import cn from '@/utils/classnames' @@ -9,18 +8,15 @@ import { useTabSearchParams } from '@/hooks/use-tab-searchparams' import TabSliderNew from '@/app/components/base/tab-slider-new' import LabelFilter from '@/app/components/tools/labels/filter' import SearchInput from '@/app/components/base/search-input' -// import CustomCreateCard from '@/app/components/tools/provider/custom-create-card' import ProviderDetail from '@/app/components/tools/provider/detail' import Empty from '@/app/components/tools/add-tool-modal/empty' import { fetchCollectionList } from '@/service/tools' import Card from '@/app/components/plugins/card' -import { useGetLanguage } from '@/context/i18n' import CardMoreInfo from '@/app/components/plugins/card/card-more-info' import { useSelector as useAppContextSelector } from '@/context/app-context' const ProviderList = () => { const { t } = useTranslation() - const language = useGetLanguage() const containerRef = useRef(null) const { enable_marketplace } = useAppContextSelector(s => s.systemFeatures) @@ -97,7 +93,6 @@ const ProviderList = () => { 'relative grid content-start grid-cols-1 gap-4 px-12 pt-2 pb-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 grow shrink-0', currentProvider && 'pr-6 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3', )}> - {/* {activeTab === 'api' && } */} {filteredCollectionList.map(collection => (
{ ) }
-
- {currentProvider && } -
-
setCurrentProvider(undefined)}>
+ {currentProvider && ( + setCurrentProvider(undefined)} + onRefreshData={getProviderList} + /> + )} ) } diff --git a/web/app/components/tools/provider/detail.tsx b/web/app/components/tools/provider/detail.tsx index 566fe4623a..35f333912a 100644 --- a/web/app/components/tools/provider/detail.tsx +++ b/web/app/components/tools/provider/detail.tsx @@ -17,6 +17,7 @@ import ConfigCredential from '@/app/components/tools/setting/build-in/config-cre import EditCustomToolModal from '@/app/components/tools/edit-custom-collection-modal' import WorkflowToolModal from '@/app/components/tools/workflow-tool' import Toast from '@/app/components/base/toast' +import Drawer from '@/app/components/base/drawer' import { deleteWorkflowTool, fetchBuiltInToolList, @@ -38,11 +39,13 @@ import { useAppContext } from '@/context/app-context' type Props = { collection: Collection + onHide: () => void onRefreshData: () => void } const ProviderDetail = ({ collection, + onHide, onRefreshData, }: Props) => { const { t } = useTranslation() @@ -213,164 +216,174 @@ const ProviderDetail = ({ }, [collection.name, collection.type, getCustomProvider, getProviderToolList, getWorkflowToolProvider]) return ( -
-
-
- {typeof collection.icon === 'string' && ( -
- )} - {typeof collection.icon !== 'string' && ( - - )} -
-
-
-
{collection.label[language]}
-
-
-
-
{collection.description[language]}
-
- {(collection.type === CollectionType.builtIn) && needAuth && ( - - )} - {collection.type === CollectionType.custom && !isDetailLoading && ( - - )} - {collection.type === CollectionType.workflow && !isDetailLoading && customCollection && ( - <> - - - - )} -
- {/* Tools */} -
- {isDetailLoading &&
} - {!isDetailLoading && ( -
- {collection.type === CollectionType.workflow && {t('tools.createTool.toolInput.title').toLocaleUpperCase()}} - {collection.type !== CollectionType.workflow && {t('tools.includeToolNum', { num: toolList.length }).toLocaleUpperCase()}} - {needAuth && (isBuiltIn || isModel) && !isAuthed && ( - <> - · - {t('tools.auth.setup').toLocaleUpperCase()} - + +
+
+
+ {typeof collection.icon === 'string' && ( +
+ )} + {typeof collection.icon !== 'string' && ( + )}
- )} - {!isDetailLoading && ( -
- {collection.type !== CollectionType.workflow && toolList.map(tool => ( - - ))} - {collection.type === CollectionType.workflow && (customCollection as WorkflowToolProviderResponse)?.tool?.parameters.map(item => ( -
-
- {item.name} - {item.type} - {item.required ? t('tools.createTool.toolInput.required') : ''} -
-
{item.llm_description}
-
- ))} +
+
+
{collection.label[language]}
+
+
+
{collection.description[language]}
+
+ {(collection.type === CollectionType.builtIn) && needAuth && ( + + )} + {collection.type === CollectionType.custom && !isDetailLoading && ( + + )} + {collection.type === CollectionType.workflow && !isDetailLoading && customCollection && ( + <> + + + + )} +
+ {/* Tools */} +
+ {isDetailLoading &&
} + {!isDetailLoading && ( +
+ {collection.type === CollectionType.workflow && {t('tools.createTool.toolInput.title').toLocaleUpperCase()}} + {collection.type !== CollectionType.workflow && {t('tools.includeToolNum', { num: toolList.length }).toLocaleUpperCase()}} + {needAuth && (isBuiltIn || isModel) && !isAuthed && ( + <> + · + {t('tools.auth.setup').toLocaleUpperCase()} + + )} +
+ )} + {!isDetailLoading && ( +
+ {collection.type !== CollectionType.workflow && toolList.map(tool => ( + + ))} + {collection.type === CollectionType.workflow && (customCollection as WorkflowToolProviderResponse)?.tool?.parameters.map(item => ( +
+
+ {item.name} + {item.type} + {item.required ? t('tools.createTool.toolInput.required') : ''} +
+
{item.llm_description}
+
+ ))} +
+ )} +
+ {showSettingAuth && ( + setShowSettingAuth(false)} + onSaved={async (value) => { + await updateBuiltInToolCredential(collection.name, value) + Toast.notify({ + type: 'success', + message: t('common.api.actionSuccess'), + }) + await onRefreshData() + setShowSettingAuth(false) + }} + onRemove={async () => { + await removeBuiltInToolCredential(collection.name) + Toast.notify({ + type: 'success', + message: t('common.api.actionSuccess'), + }) + await onRefreshData() + setShowSettingAuth(false) + }} + /> + )} + {isShowEditCollectionToolModal && ( + setIsShowEditCustomCollectionModal(false)} + onEdit={doUpdateCustomToolCollection} + onRemove={onClickCustomToolDelete} + /> + )} + {isShowEditWorkflowToolModal && ( + setIsShowEditWorkflowToolModal(false)} + onRemove={onClickWorkflowToolDelete} + onSave={updateWorkflowToolProvider} + /> + )} + {showConfirmDelete && ( + setShowConfirmDelete(false)} + /> )}
- {showSettingAuth && ( - setShowSettingAuth(false)} - onSaved={async (value) => { - await updateBuiltInToolCredential(collection.name, value) - Toast.notify({ - type: 'success', - message: t('common.api.actionSuccess'), - }) - await onRefreshData() - setShowSettingAuth(false) - }} - onRemove={async () => { - await removeBuiltInToolCredential(collection.name) - Toast.notify({ - type: 'success', - message: t('common.api.actionSuccess'), - }) - await onRefreshData() - setShowSettingAuth(false) - }} - /> - )} - {isShowEditCollectionToolModal && ( - setIsShowEditCustomCollectionModal(false)} - onEdit={doUpdateCustomToolCollection} - onRemove={onClickCustomToolDelete} - /> - )} - {isShowEditWorkflowToolModal && ( - setIsShowEditWorkflowToolModal(false)} - onRemove={onClickWorkflowToolDelete} - onSave={updateWorkflowToolProvider} - /> - )} - {showConfirmDelete && ( - setShowConfirmDelete(false)} - /> - )} -
+ ) } export default ProviderDetail