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