status-indicators.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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] gap-1 flex-col px-1 py-1.5' onClick={e => e.stopPropagation()}>
  19. <div className='text-text-primary title-xs-semi-bold'>{title}</div>
  20. {description && (
  21. <div className='min-w-[200px] text-text-secondary body-xs-regular'>
  22. {description}
  23. </div>
  24. )}
  25. {linkText && linkHref && (
  26. <div className='text-text-accent body-xs-regular cursor-pointer z-[100]'>
  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='w-4 h-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. needsDelay={true}
  65. >
  66. <RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
  67. </Tooltip>
  68. ) : (
  69. <SwitchPluginVersion
  70. tooltip={renderTooltipContent(
  71. t('workflow.nodes.agent.modelNotSupport.title'),
  72. t('workflow.nodes.agent.modelNotSupport.descForVersionSwitch'),
  73. )}
  74. uniqueIdentifier={pluginList?.plugins.find(plugin => plugin.name === pluginInfo.name)?.plugin_unique_identifier ?? ''}
  75. />
  76. )}
  77. </>
  78. )}
  79. {!modelProvider && !pluginInfo && (
  80. <Tooltip
  81. popupContent={renderTooltipContent(
  82. t('workflow.nodes.agent.modelNotInMarketplace.title'),
  83. t('workflow.nodes.agent.modelNotInMarketplace.desc'),
  84. t('workflow.nodes.agent.linkToPlugin'),
  85. '/plugins',
  86. )}
  87. asChild={false}
  88. needsDelay
  89. >
  90. <RiErrorWarningFill className='w-4 h-4 text-text-destructive' />
  91. </Tooltip>
  92. )}
  93. </>
  94. )
  95. }
  96. export default StatusIndicators