mirror of
https://github.com/langgenius/dify.git
synced 2026-07-30 08:49:31 +08:00
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import { Button } from '@langgenius/dify-ui/button'
|
|
import { cn } from '@langgenius/dify-ui/cn'
|
|
import { StatusDot } from '@langgenius/dify-ui/status-dot'
|
|
import { RiEqualizer2Line, RiScales3Line } from '@remixicon/react'
|
|
import { memo } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
type ConfigModelProps = {
|
|
onClick?: () => void
|
|
loadBalancingEnabled?: boolean
|
|
loadBalancingInvalid?: boolean
|
|
credentialRemoved?: boolean
|
|
}
|
|
const ConfigModel = ({
|
|
onClick,
|
|
loadBalancingEnabled,
|
|
loadBalancingInvalid,
|
|
credentialRemoved,
|
|
}: ConfigModelProps) => {
|
|
const { t } = useTranslation()
|
|
|
|
if (loadBalancingInvalid) {
|
|
return (
|
|
<div
|
|
className="relative flex h-[18px] cursor-pointer items-center rounded-[5px] border border-text-warning bg-components-badge-bg-dimm px-1.5 system-2xs-medium-uppercase text-text-warning"
|
|
onClick={onClick}
|
|
>
|
|
<RiScales3Line className="mr-0.5 size-3" />
|
|
{t(($) => $['modelProvider.auth.authorizationError'], { ns: 'common' })}
|
|
<StatusDot status="warning" className="absolute -top-px -right-px size-1.5" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
variant="secondary"
|
|
size="small"
|
|
className={cn('hidden shrink-0 group-hover:flex', credentialRemoved && 'flex')}
|
|
onClick={onClick}
|
|
>
|
|
{credentialRemoved && (
|
|
<>
|
|
{t(($) => $['modelProvider.auth.credentialRemoved'], { ns: 'common' })}
|
|
<StatusDot status="error" className="ml-2" />
|
|
</>
|
|
)}
|
|
{!loadBalancingEnabled && !credentialRemoved && !loadBalancingInvalid && (
|
|
<>
|
|
<RiEqualizer2Line className="mr-1 size-4" />
|
|
{t(($) => $['operation.config'], { ns: 'common' })}
|
|
</>
|
|
)}
|
|
{loadBalancingEnabled && !credentialRemoved && !loadBalancingInvalid && (
|
|
<>
|
|
<RiScales3Line className="mr-1 size-4" />
|
|
{t(($) => $['modelProvider.auth.configLoadBalancing'], { ns: 'common' })}
|
|
</>
|
|
)}
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
export default memo(ConfigModel)
|