From 9fea2fd44b2091d38da52f61a92d707ffdffb72a Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 3 Apr 2024 11:56:54 +0800 Subject: [PATCH] feat: change from creditical schema value from api --- .../tools/setting/build-in/config-credentials.tsx | 10 ++++++---- web/service/tools.ts | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) 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 7bb5d1733b..b663f96afe 100644 --- a/web/app/components/tools/setting/build-in/config-credentials.tsx +++ b/web/app/components/tools/setting/build-in/config-credentials.tsx @@ -7,7 +7,7 @@ import { addDefaultValue, toolCredentialToFormSchemas } from '../../utils/to-for import type { Collection } from '../../types' import Drawer from '@/app/components/base/drawer-plus' import Button from '@/app/components/base/button' -import { fetchBuiltInToolCredentialSchema } from '@/service/tools' +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' @@ -29,11 +29,13 @@ const ConfigCredential: FC = ({ }) => { const { t } = useTranslation() const [credentialSchema, setCredentialSchema] = useState(null) - const { team_credentials: credentialValue, name: collectionName } = collection - const [tempCredential, setTempCredential] = React.useState(credentialValue) + const { name: collectionName } = collection + const [tempCredential, setTempCredential] = React.useState({}) useEffect(() => { - fetchBuiltInToolCredentialSchema(collectionName).then((res) => { + fetchBuiltInToolCredentialSchema(collectionName).then(async (res) => { const toolCredentialSchemas = toolCredentialToFormSchemas(res) + const credentialValue = await fetchBuiltInToolCredential(collectionName) + setTempCredential(credentialValue) const defaultCredentials = addDefaultValue(credentialValue, toolCredentialSchemas) setCredentialSchema(toolCredentialSchemas) setTempCredential(defaultCredentials) diff --git a/web/service/tools.ts b/web/service/tools.ts index 53430f89f5..36b918d9e5 100644 --- a/web/service/tools.ts +++ b/web/service/tools.ts @@ -22,6 +22,9 @@ export const fetchBuiltInToolCredentialSchema = (collectionName: string) => { return get(`/workspaces/current/tool-provider/builtin/${collectionName}/credentials_schema`) } +export const fetchBuiltInToolCredential = (collectionName: string) => { + return get(`/workspaces/current/tool-provider/builtin/${collectionName}/credentials`) +} export const updateBuiltInToolCredential = (collectionName: string, credential: Record) => { return post(`/workspaces/current/tool-provider/builtin/${collectionName}/update`, { body: {