From 8a43aedc1560dff47a5b021d70eddc0df3def124 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Fri, 12 Sep 2025 15:42:16 +0800 Subject: [PATCH] Fix/enterprise model credential (#25591) --- .../switch-credential-in-load-balancing.tsx | 41 +++++++++++-------- .../model-provider-page/model-modal/index.tsx | 6 +-- .../plugin-auth/authorized-in-node.tsx | 20 ++++++++- .../plugins/plugin-auth/authorized/index.tsx | 3 +- web/i18n/en-US/plugin.ts | 1 + web/i18n/zh-Hans/plugin.ts | 1 + 6 files changed, 49 insertions(+), 23 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx index 6ca120aea6..5d2da57adb 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/switch-credential-in-load-balancing.tsx @@ -37,51 +37,57 @@ const SwitchCredentialInLoadBalancing = ({ onRemove, }: SwitchCredentialInLoadBalancingProps) => { const { t } = useTranslation() - + const notAllowCustomCredential = provider.allow_custom_token === false const handleItemClick = useCallback((credential: Credential) => { setCustomModelCredential(credential) }, [setCustomModelCredential]) const renderTrigger = useCallback(() => { const selectedCredentialId = customModelCredential?.credential_id - const authRemoved = !selectedCredentialId && !!credentials?.length + const currentCredential = credentials?.find(c => c.credential_id === selectedCredentialId) + const empty = !credentials?.length + const authRemoved = selectedCredentialId && !currentCredential && !empty + const unavailable = currentCredential?.not_allowed_to_use + let color = 'green' - if (authRemoved && !customModelCredential?.not_allowed_to_use) + if (authRemoved || unavailable) color = 'red' - if (customModelCredential?.not_allowed_to_use) - color = 'gray' const Item = ( ) - if (customModelCredential?.not_allowed_to_use) { + if (empty && notAllowCustomCredential) { return ( ) } diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx index 4ffbc8f191..ccf742bb2d 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx @@ -376,16 +376,16 @@ const ModelModal: FC = ({ !provider.help.url && e.preventDefault()} > {provider.help.title?.[language] || provider.help.url[language] || provider.help.title?.en_US || provider.help.url.en_US} - + ) :
} -
+
{ isEditMode && (