| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  | 'use client' | 
					
						
							|  |  |  | import type { FC } from 'react' | 
					
						
							|  |  |  | import React from 'react' | 
					
						
							|  |  |  | import Link from 'next/link' | 
					
						
							|  |  |  | import { RiArrowRightUpLine } from '@remixicon/react' | 
					
						
							|  |  |  | import cn from '@/utils/classnames' | 
					
						
							|  |  |  | import AppIcon from '@/app/components/base/app-icon' | 
					
						
							|  |  |  | import type { RelatedApp } from '@/models/datasets' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type ILikedItemProps = { | 
					
						
							|  |  |  |   appStatus?: boolean | 
					
						
							|  |  |  |   detail: RelatedApp | 
					
						
							|  |  |  |   isMobile: boolean | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const appTypeMap = { | 
					
						
							|  |  |  |   'chat': 'Chatbot', | 
					
						
							|  |  |  |   'completion': 'Completion', | 
					
						
							|  |  |  |   'agent-chat': 'Agent', | 
					
						
							|  |  |  |   'advanced-chat': 'Chatflow', | 
					
						
							|  |  |  |   'workflow': 'Workflow', | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const LikedItem = ({ | 
					
						
							|  |  |  |   detail, | 
					
						
							|  |  |  |   isMobile, | 
					
						
							|  |  |  | }: ILikedItemProps) => { | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |     <Link className={cn('group/link-item flex h-8 w-full cursor-pointer items-center justify-between rounded-lg px-2 hover:bg-state-base-hover', isMobile && 'justify-center')} href={`/app/${detail?.id}/overview`}> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |       <div className='flex items-center'> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         <div className={cn('relative h-6 w-6 rounded-md')}> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |           <AppIcon size='tiny' iconType={detail.icon_type} icon={detail.icon} background={detail.icon_background} imageUrl={detail.icon_url} /> | 
					
						
							|  |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         {!isMobile && <div className={cn(' system-sm-medium ml-2 truncate text-text-primary')}>{detail?.name || '--'}</div>} | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |       </div> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |       <div className='system-2xs-medium-uppercase shrink-0 text-text-tertiary group-hover/link-item:hidden'>{appTypeMap[detail.mode]}</div> | 
					
						
							|  |  |  |       <RiArrowRightUpLine className='hidden h-4 w-4 text-text-tertiary group-hover/link-item:block' /> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |     </Link> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type Props = { | 
					
						
							|  |  |  |   relatedApps: RelatedApp[] | 
					
						
							|  |  |  |   isMobile: boolean | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const LinkedAppsPanel: FC<Props> = ({ | 
					
						
							|  |  |  |   relatedApps, | 
					
						
							|  |  |  |   isMobile, | 
					
						
							|  |  |  | }) => { | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |     <div className='w-[320px] rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-1 shadow-lg  backdrop-blur-[5px]'> | 
					
						
							| 
									
										
										
										
											2024-12-26 12:01:51 +08:00
										 |  |  |       {relatedApps.map((item, index) => ( | 
					
						
							|  |  |  |         <LikedItem key={index} detail={item} isMobile={isMobile} /> | 
					
						
							|  |  |  |       ))} | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | export default React.memo(LinkedAppsPanel) |