Release/e-1.8.1 (#25613)
Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: GareArc <chen4851@purdue.edu> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com>
This commit is contained in:
@@ -92,10 +92,10 @@ const CredentialItem = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
showAction && (
|
||||
showAction && !credential.from_enterprise && (
|
||||
<div className='ml-2 hidden shrink-0 items-center group-hover:flex'>
|
||||
{
|
||||
!disableEdit && !credential.not_allowed_to_use && !credential.from_enterprise && (
|
||||
!disableEdit && !credential.not_allowed_to_use && (
|
||||
<Tooltip popupContent={t('common.operation.edit')}>
|
||||
<ActionButton
|
||||
disabled={disabled}
|
||||
@@ -110,7 +110,7 @@ const CredentialItem = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
!disableDelete && !credential.from_enterprise && (
|
||||
!disableDelete && (
|
||||
<Tooltip popupContent={disableDeleteWhenSelected ? disableDeleteTip : t('common.operation.delete')}>
|
||||
<ActionButton
|
||||
className='hover:bg-transparent'
|
||||
|
||||
@@ -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 = (
|
||||
<Button
|
||||
variant='secondary'
|
||||
className={cn(
|
||||
'shrink-0 space-x-1',
|
||||
authRemoved && 'text-components-button-destructive-secondary-text',
|
||||
customModelCredential?.not_allowed_to_use && 'cursor-not-allowed opacity-50',
|
||||
(authRemoved || unavailable) && 'text-components-button-destructive-secondary-text',
|
||||
empty && 'cursor-not-allowed opacity-50',
|
||||
)}
|
||||
>
|
||||
<Indicator
|
||||
className='mr-2'
|
||||
color={color as any}
|
||||
/>
|
||||
{
|
||||
authRemoved && !customModelCredential?.not_allowed_to_use && t('common.modelProvider.auth.authRemoved')
|
||||
!empty && (
|
||||
<Indicator
|
||||
className='mr-2'
|
||||
color={color as any}
|
||||
/>
|
||||
)
|
||||
}
|
||||
{
|
||||
!authRemoved && customModelCredential?.not_allowed_to_use && t('plugin.auth.credentialUnavailable')
|
||||
authRemoved && t('common.modelProvider.auth.authRemoved')
|
||||
}
|
||||
{
|
||||
!authRemoved && !customModelCredential?.not_allowed_to_use && customModelCredential?.credential_name
|
||||
(unavailable || empty) && t('plugin.auth.credentialUnavailableInButton')
|
||||
}
|
||||
{
|
||||
customModelCredential?.from_enterprise && (
|
||||
!authRemoved && !unavailable && !empty && customModelCredential?.credential_name
|
||||
}
|
||||
{
|
||||
currentCredential?.from_enterprise && (
|
||||
<Badge className='ml-2'>Enterprise</Badge>
|
||||
)
|
||||
}
|
||||
<RiArrowDownSLine className='h-4 w-4' />
|
||||
</Button>
|
||||
)
|
||||
if (customModelCredential?.not_allowed_to_use) {
|
||||
if (empty && notAllowCustomCredential) {
|
||||
return (
|
||||
<Tooltip
|
||||
asChild
|
||||
@@ -92,7 +98,7 @@ const SwitchCredentialInLoadBalancing = ({
|
||||
)
|
||||
}
|
||||
return Item
|
||||
}, [customModelCredential, t, credentials])
|
||||
}, [customModelCredential, t, credentials, notAllowCustomCredential])
|
||||
|
||||
return (
|
||||
<Authorized
|
||||
@@ -123,6 +129,7 @@ const SwitchCredentialInLoadBalancing = ({
|
||||
enableAddModelCredential
|
||||
showItemSelectedIcon
|
||||
popupTitle={t('common.modelProvider.auth.modelCredentials')}
|
||||
triggerOnlyOpenModal={!credentials?.length}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ const ModelModal: FC<ModelModalProps> = ({
|
||||
const formRef1 = useRef<FormRefObject>(null)
|
||||
const [selectedCredential, setSelectedCredential] = useState<Credential & { addNewCredential?: boolean } | undefined>()
|
||||
const formRef2 = useRef<FormRefObject>(null)
|
||||
const isEditMode = !!Object.keys(formValues).filter((key) => {
|
||||
const isEditMode = !!credential && !!Object.keys(formSchemasValue || {}).filter((key) => {
|
||||
return key !== '__model_name' && key !== '__model_type' && !!formValues[key]
|
||||
}).length && isCurrentWorkspaceManager
|
||||
|
||||
@@ -376,16 +376,16 @@ const ModelModal: FC<ModelModalProps> = ({
|
||||
<a
|
||||
href={provider.help?.url[language] || provider.help?.url.en_US}
|
||||
target='_blank' rel='noopener noreferrer'
|
||||
className='system-xs-regular mt-2 inline-flex items-center text-text-accent'
|
||||
className='system-xs-regular mt-2 inline-block align-middle text-text-accent'
|
||||
onClick={e => !provider.help.url && e.preventDefault()}
|
||||
>
|
||||
{provider.help.title?.[language] || provider.help.url[language] || provider.help.title?.en_US || provider.help.url.en_US}
|
||||
<LinkExternal02 className='ml-1 h-3 w-3' />
|
||||
<LinkExternal02 className='ml-1 mt-[-2px] inline-block h-3 w-3' />
|
||||
</a>
|
||||
)
|
||||
: <div />
|
||||
}
|
||||
<div className='flex items-center justify-end space-x-2'>
|
||||
<div className='ml-2 flex items-center justify-end space-x-2'>
|
||||
{
|
||||
isEditMode && (
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user