From 3c00a0e5089624936f786de68a17cf7abf8b2fd0 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Thu, 21 Aug 2025 16:14:53 +0800 Subject: [PATCH] fix: enterprise credential --- .../model-auth/add-custom-model.tsx | 7 ++++-- .../model-auth/authorized/index.tsx | 3 +-- .../model-auth/config-provider.tsx | 4 ++-- .../switch-credential-in-load-balancing.tsx | 23 +++++++++++++++++-- .../model-load-balancing-configs.tsx | 12 ++++++++-- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx index d22b0ad61e..82376167fa 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx @@ -52,7 +52,9 @@ const AddCustomModel = ({ variant='ghost-accent' size='small' onClick={handleClick} - disabled={notAllowCustomCredential} + className={cn( + notAllowCustomCredential && 'cursor-not-allowed opacity-50', + )} > {t('common.modelProvider.addModel')} @@ -78,6 +80,7 @@ const AddCustomModel = ({ size='small' className={cn( open && 'bg-components-button-ghost-bg-hover', + notAllowCustomCredential && 'cursor-not-allowed opacity-50', )} > @@ -85,7 +88,7 @@ const AddCustomModel = ({ ) return Item - }, [t]) + }, [t, notAllowCustomCredential]) if (noModels) return ButtonComponent diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx index 8f4b47148f..068fcdb726 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx @@ -114,9 +114,8 @@ const Authorized = ({ const Trigger = useMemo(() => { const Item = ( ) + if (customModelCredential?.not_allowed_to_use) { + return ( + + {Item} + + ) + } + return Item }, [customModelCredential, t, credentials]) return ( diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx index c7d81e382f..78792a044a 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx @@ -29,6 +29,7 @@ import { useProviderContextSelector } from '@/context/provider-context' import { IS_CE_EDITION } from '@/config' import { AddCredentialInLoadBalancing } from '@/app/components/header/account-setting/model-provider-page/model-auth' import { useModelModalHandler } from '@/app/components/header/account-setting/model-provider-page/hooks' +import Badge from '@/app/components/base/badge/index' export type ModelLoadBalancingConfigsProps = { draftConfig?: ModelLoadBalancingConfig @@ -173,6 +174,7 @@ const ModelLoadBalancingConfigs = ({
{validDraftConfigList.map((config, index) => { const isProviderManaged = config.name === '__inherit__' + const credential = modelCredential.available_credentials.find(c => c.credential_id === config.credential_id) return (
@@ -191,15 +193,20 @@ const ModelLoadBalancingConfigs = ({ {isProviderManaged ? t('common.modelProvider.defaultConfig') : config.name}
{isProviderManaged && ( - {t('common.modelProvider.providerManaged')} + {t('common.modelProvider.providerManaged')} )} + { + credential?.from_enterprise && ( + Enterprise + ) + }
{!isProviderManaged && ( <>
{ - config.credential_id && ( + config.credential_id && !credential?.not_allowed_to_use && ( { @@ -238,6 +245,7 @@ const ModelLoadBalancingConfigs = ({ size='md' className='justify-self-end' onChange={value => toggleConfigEntryEnabled(index, value)} + disabled={credential?.not_allowed_to_use} /> )