Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

status-indicators.tsx 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import Tooltip from '@/app/components/base/tooltip'
  2. import Link from 'next/link'
  3. import { SwitchPluginVersion } from '@/app/components/workflow/nodes/_base/components/switch-plugin-version'
  4. import { useInstalledPluginList } from '@/service/use-plugins'
  5. import { RiErrorWarningFill } from '@remixicon/react'
  6. type StatusIndicatorsProps = {
  7. needsConfiguration: boolean
  8. modelProvider: boolean
  9. inModelList: boolean
  10. disabled: boolean
  11. pluginInfo: any
  12. t: any
  13. }
  14. const StatusIndicators = ({ needsConfiguration, modelProvider, inModelList, disabled, pluginInfo, t }: StatusIndicatorsProps) => {
  15. const { data: pluginList } = useInstalledPluginList()
  16. const renderTooltipContent = (title: string, description?: string, linkText?: string, linkHref?: string) => {
  17. return (
  18. <div className='flex w-[240px] max-w-[240px] flex-col gap-1 px-1 py-1.5' onClick={e => e.stopPropagation()}>
  19. <div className='title-xs-semi-bold text-text-primary'>{title}</div>
  20. {description && (
  21. <div className='body-xs-regular min-w-[200px] text-text-secondary'>
  22. {description}
  23. </div>
  24. )}
  25. {linkText && linkHref && (
  26. <div className='body-xs-regular z-[100] cursor-pointer text-text-accent'>
  27. <Link
  28. href={linkHref}
  29. onClick={(e) => {
  30. e.stopPropagation()
  31. }}
  32. >
  33. {linkText}
  34. </Link>
  35. </div>
  36. )}
  37. </div>
  38. )
  39. }
  40. // const installedPluginUniqueIdentifier = pluginList?.plugins.find(plugin => plugin.name === pluginInfo.name)?.plugin_unique_identifier
  41. return (
  42. <>
  43. {/* plugin installed and model is in model list but disabled */}
  44. {/* plugin installed from github/local and model is not in model list */}
  45. {!needsConfiguration && modelProvider && disabled && (
  46. <>
  47. {inModelList ? (
  48. <Tooltip
  49. popupContent={t('workflow.nodes.agent.modelSelectorTooltips.deprecated')}
  50. asChild={false}
  51. needsDelay={false}
  52. >
  53. <RiErrorWarningFill className='h-4 w-4 text-text-destructive' />
  54. </Tooltip>
  55. ) : !pluginInfo ? (
  56. <Tooltip
  57. popupContent={renderTooltipContent(
  58. t('workflow.nodes.agent.modelNotSupport.title'),
  59. t('workflow.nodes.agent.modelNotSupport.desc'),
  60. t('workflow.nodes.agent.linkToPlugin'),
  61. '/plugins',
  62. )}
  63. asChild={false}
  64. >
  65. <RiErrorWarningFill className='h-4 w-4 text-text-destructive' />
  66. </Tooltip>
  67. ) : (
  68. <SwitchPluginVersion
  69. tooltip={renderTooltipContent(
  70. t('workflow.nodes.agent.modelNotSupport.title'),
  71. t('workflow.nodes.agent.modelNotSupport.descForVersionSwitch'),
  72. )}
  73. uniqueIdentifier={pluginList?.plugins.find(plugin => plugin.name === pluginInfo.name)?.plugin_unique_identifier ?? ''}
  74. />
  75. )}
  76. </>
  77. )}
  78. {!modelProvider && !pluginInfo && (
  79. <Tooltip
  80. popupContent={renderTooltipContent(
  81. t('workflow.nodes.agent.modelNotInMarketplace.title'),
  82. t('workflow.nodes.agent.modelNotInMarketplace.desc'),
  83. t('workflow.nodes.agent.linkToPlugin'),
  84. '/plugins',
  85. )}
  86. asChild={false}
  87. >
  88. <RiErrorWarningFill className='h-4 w-4 text-text-destructive' />
  89. </Tooltip>
  90. )}
  91. </>
  92. )
  93. }
  94. export default StatusIndicators