index.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import Link from 'next/link'
  5. import { useTranslation } from 'react-i18next'
  6. import { RiArrowRightUpLine } from '@remixicon/react'
  7. import cn from '@/utils/classnames'
  8. import AppIcon from '@/app/components/base/app-icon'
  9. import type { RelatedApp } from '@/models/datasets'
  10. type ILikedItemProps = {
  11. appStatus?: boolean
  12. detail: RelatedApp
  13. isMobile: boolean
  14. }
  15. const appTypeMap = {
  16. 'chat': 'Chatbot',
  17. 'completion': 'Completion',
  18. 'agent-chat': 'Agent',
  19. 'advanced-chat': 'Chatflow',
  20. 'workflow': 'Workflow',
  21. }
  22. const LikedItem = ({
  23. detail,
  24. isMobile,
  25. }: ILikedItemProps) => {
  26. return (
  27. <Link className={cn('group/link-item flex items-center justify-between w-full h-8 rounded-lg hover:bg-state-base-hover cursor-pointer px-2', isMobile && 'justify-center')} href={`/app/${detail?.id}/overview`}>
  28. <div className='flex items-center'>
  29. <div className={cn('relative w-6 h-6 rounded-md')}>
  30. <AppIcon size='tiny' iconType={detail.icon_type} icon={detail.icon} background={detail.icon_background} imageUrl={detail.icon_url} />
  31. </div>
  32. {!isMobile && <div className={cn(' ml-2 truncate system-sm-medium text-text-primary')}>{detail?.name || '--'}</div>}
  33. </div>
  34. <div className='group-hover/link-item:hidden shrink-0 system-2xs-medium-uppercase text-text-tertiary'>{appTypeMap[detail.mode]}</div>
  35. <RiArrowRightUpLine className='hidden group-hover/link-item:block w-4 h-4 text-text-tertiary' />
  36. </Link>
  37. )
  38. }
  39. type Props = {
  40. relatedApps: RelatedApp[]
  41. isMobile: boolean
  42. }
  43. const LinkedAppsPanel: FC<Props> = ({
  44. relatedApps,
  45. isMobile,
  46. }) => {
  47. const { t } = useTranslation()
  48. return (
  49. <div className='p-1 w-[320px] bg-components-panel-bg-blur border-[0.5px] border-components-panel-border shadow-lg rounded-xl backdrop-blur-[5px]'>
  50. <div className='mt-1 mb-0.5 pl-2 system-xs-medium-uppercase text-text-tertiary'>{relatedApps.length || '--'} {t('common.datasetMenus.relatedApp')}</div>
  51. {relatedApps.map((item, index) => (
  52. <LikedItem key={index} detail={item} isMobile={isMobile} />
  53. ))}
  54. </div>
  55. )
  56. }
  57. export default React.memo(LinkedAppsPanel)