fix: enterprise credential

This commit is contained in:
zxhlyh 2025-08-20 17:53:22 +08:00
parent c9f1880baf
commit c037e35e5d
3 changed files with 15 additions and 25 deletions

View File

@ -39,16 +39,20 @@ const AddCustomModel = ({
const {
handleOpenModal,
} = useAuth(provider, configurationMethod, currentCustomConfigurationModelFixedFields, true)
const handleClick = useCallback(() => {
handleOpenModal()
}, [handleOpenModal])
const notAllowCustomCredential = provider.allow_custom_token === false
const handleClick = useCallback(() => {
if (notAllowCustomCredential)
return
handleOpenModal()
}, [handleOpenModal, notAllowCustomCredential])
const ButtonComponent = useMemo(() => {
const Item = (
<Button
variant='ghost-accent'
size='small'
onClick={handleClick}
disabled={notAllowCustomCredential}
>
<RiAddCircleFill className='mr-1 h-3.5 w-3.5' />
{t('common.modelProvider.addModel')}
@ -72,24 +76,16 @@ const AddCustomModel = ({
<Button
variant='ghost'
size='small'
className={cn(open && 'bg-components-button-ghost-bg-hover')}
className={cn(
open && 'bg-components-button-ghost-bg-hover',
)}
>
<RiAddCircleFill className='mr-1 h-3.5 w-3.5' />
{t('common.modelProvider.addModel')}
</Button>
)
if (notAllowCustomCredential) {
return (
<Tooltip
asChild
popupContent={t('plugin.auth.credentialUnavailable')}
>
{Item}
</Tooltip>
)
}
return Item
}, [notAllowCustomCredential, t])
}, [t])
if (noModels)
return ButtonComponent

View File

@ -112,19 +112,18 @@ const Authorized = ({
const notAllowCustomCredential = provider.allow_custom_token === false
const Trigger = useMemo(() => {
const hasValidCredential = items.some(item => item.credentials.some(credential => !credential.not_allowed_to_use))
const Item = (
<Button
className='grow'
size='small'
disabled={notAllowCustomCredential && !hasValidCredential}
disabled={notAllowCustomCredential}
>
<RiEqualizer2Line className='mr-1 h-3.5 w-3.5' />
{t('common.operation.config')}
</Button>
)
if (notAllowCustomCredential && !hasValidCredential) {
if (notAllowCustomCredential) {
return (
<Tooltip
asChild
@ -135,7 +134,7 @@ const Authorized = ({
)
}
return Item
}, [notAllowCustomCredential, t, items])
}, [notAllowCustomCredential, t])
return (
<>
@ -148,11 +147,6 @@ const Authorized = ({
>
<PortalToFollowElemTrigger
onClick={() => {
if (notAllowCustomCredential) {
const hasValidCredential = items.some(item => item.credentials.some(credential => !credential.not_allowed_to_use))
if (!hasValidCredential)
return
}
setMergedIsOpen(!mergedIsOpen)
}}
asChild

View File

@ -297,7 +297,7 @@ const translation = {
authRemoved: '凭据已移除',
clientInfo: '由于未找到此工具提供者的系统客户端密钥,因此需要手动设置,对于 redirect_uri请使用',
oauthClient: 'OAuth 客户端',
credentialUnavailable: '凭据当前不可用,请联系管理员。',
credentialUnavailable: '自定义凭据当前不可用,请联系管理员。',
customCredentialUnavailable: '自定义凭据当前不可用',
unavailable: '不可用',
},