diff --git a/web/app/components/tools/setting/build-in/config-credentials.tsx b/web/app/components/tools/setting/build-in/config-credentials.tsx index 09c95d2125..23ef867feb 100644 --- a/web/app/components/tools/setting/build-in/config-credentials.tsx +++ b/web/app/components/tools/setting/build-in/config-credentials.tsx @@ -7,11 +7,12 @@ import type { Collection } from '../../types' import cn from '@/utils/classnames' import Drawer from '@/app/components/base/drawer-plus' import Button from '@/app/components/base/button' +import Toast from '@/app/components/base/toast' import { fetchBuiltInToolCredential, fetchBuiltInToolCredentialSchema } from '@/service/tools' import Loading from '@/app/components/base/loading' import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form' import { LinkExternal02 } from '@/app/components/base/icons/src/vender/line/general' -import { useAppContext } from '@/context/app-context' +import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' type Props = { collection: Collection @@ -29,8 +30,8 @@ const ConfigCredential: FC = ({ onRemove = () => { }, }) => { const { t } = useTranslation() + const language = useLanguage() const [credentialSchema, setCredentialSchema] = useState(null) - const { isCurrentWorkspaceManager } = useAppContext() const { name: collectionName } = collection const [tempCredential, setTempCredential] = React.useState({}) useEffect(() => { @@ -44,6 +45,16 @@ const ConfigCredential: FC = ({ }) }, []) + const handleSave = () => { + for (const field of credentialSchema) { + if (field.required && !tempCredential[field.name]) { + Toast.notify({ type: 'error', message: t('common.errorMsg.fieldRequired', { field: field.label[language] || field.label.en_US }) }) + return + } + } + onSaved(tempCredential) + } + return ( = ({ } < div className='flex space-x-2'> - +