You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config-model.tsx 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { memo } from 'react'
  2. import {
  3. RiEqualizer2Line,
  4. RiScales3Line,
  5. } from '@remixicon/react'
  6. import { useTranslation } from 'react-i18next'
  7. import Button from '@/app/components/base/button'
  8. import Indicator from '@/app/components/header/indicator'
  9. import cn from '@/utils/classnames'
  10. type ConfigModelProps = {
  11. onClick?: () => void
  12. loadBalancingEnabled?: boolean
  13. loadBalancingInvalid?: boolean
  14. credentialRemoved?: boolean
  15. }
  16. const ConfigModel = ({
  17. onClick,
  18. loadBalancingEnabled,
  19. loadBalancingInvalid,
  20. credentialRemoved,
  21. }: ConfigModelProps) => {
  22. const { t } = useTranslation()
  23. if (loadBalancingInvalid) {
  24. return (
  25. <div
  26. className='system-2xs-medium-uppercase relative flex h-[18px] items-center rounded-[5px] border border-text-warning bg-components-badge-bg-dimm px-1.5 text-text-warning'
  27. onClick={onClick}
  28. >
  29. <RiScales3Line className='mr-0.5 h-3 w-3' />
  30. {t('common.modelProvider.auth.authorizationError')}
  31. <Indicator color='orange' className='absolute right-[-1px] top-[-1px] h-1.5 w-1.5' />
  32. </div>
  33. )
  34. }
  35. return (
  36. <Button
  37. variant='secondary'
  38. size='small'
  39. className={cn(
  40. 'hidden shrink-0 group-hover:flex',
  41. credentialRemoved && 'flex',
  42. )}
  43. onClick={onClick}
  44. >
  45. {
  46. credentialRemoved && (
  47. <>
  48. {t('common.modelProvider.auth.credentialRemoved')}
  49. <Indicator color='red' className='ml-2' />
  50. </>
  51. )
  52. }
  53. {
  54. !loadBalancingEnabled && !credentialRemoved && !loadBalancingInvalid && (
  55. <>
  56. <RiEqualizer2Line className='mr-1 h-4 w-4' />
  57. {t('common.operation.config')}
  58. </>
  59. )
  60. }
  61. {
  62. loadBalancingEnabled && !credentialRemoved && !loadBalancingInvalid && (
  63. <>
  64. <RiScales3Line className='mr-1 h-4 w-4' />
  65. {t('common.modelProvider.auth.configLoadBalancing')}
  66. </>
  67. )
  68. }
  69. </Button>
  70. )
  71. }
  72. export default memo(ConfigModel)