mirror of https://github.com/langgenius/dify.git
fix: enterprise credential
This commit is contained in:
parent
c9f1880baf
commit
c037e35e5d
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ const translation = {
|
|||
authRemoved: '凭据已移除',
|
||||
clientInfo: '由于未找到此工具提供者的系统客户端密钥,因此需要手动设置,对于 redirect_uri,请使用',
|
||||
oauthClient: 'OAuth 客户端',
|
||||
credentialUnavailable: '凭据当前不可用,请联系管理员。',
|
||||
credentialUnavailable: '自定义凭据当前不可用,请联系管理员。',
|
||||
customCredentialUnavailable: '自定义凭据当前不可用',
|
||||
unavailable: '不可用',
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue