| | |
| | | if (onSuccess) |
| | | onSuccess() |
| | | } |
| | | catch { |
| | | catch (e: any) { |
| | | } |
| | | setShowConfirmDelete(false) |
| | | }, [dataset.id, notify, onSuccess, t]) |
| | |
| | | } |
| | | return ( |
| | | <div className="relative w-full py-1" onMouseLeave={onMouseLeave}> |
| | | <div className='mx-1 flex h-8 cursor-pointer items-center gap-2 rounded-lg px-3 py-[6px] hover:bg-state-base-hover' onClick={onClickRename}> |
| | | <span className='text-sm text-text-secondary'>{t('common.operation.settings')}</span> |
| | | <div className='h-8 py-[6px] px-3 mx-1 flex items-center gap-2 hover:bg-gray-100 rounded-lg cursor-pointer' onClick={onClickRename}> |
| | | <span className='text-gray-700 text-sm'>{t('common.operation.settings')}</span> |
| | | </div> |
| | | {props.showDelete && ( |
| | | <> |
| | | <Divider className="!my-1" /> |
| | | <div |
| | | className='group mx-1 flex h-8 cursor-pointer items-center gap-2 rounded-lg px-3 py-[6px] hover:bg-state-destructive-hover' |
| | | className='group h-8 py-[6px] px-3 mx-1 flex items-center gap-2 hover:bg-red-50 rounded-lg cursor-pointer' |
| | | onClick={onClickDelete} |
| | | > |
| | | <span className={cn('text-sm text-text-secondary', 'group-hover:text-text-destructive')}> |
| | | <span className={cn('text-gray-700 text-sm', 'group-hover:text-red-500')}> |
| | | {t('common.operation.delete')} |
| | | </span> |
| | | </div> |
| | |
| | | return ( |
| | | <> |
| | | <div |
| | | className='group relative col-span-1 flex min-h-[160px] cursor-pointer flex-col rounded-xl border-[0.5px] border-solid border-components-card-border bg-components-card-bg shadow-sm transition-all duration-200 ease-in-out hover:shadow-lg' |
| | | className='group relative col-span-1 bg-components-card-bg border-[0.5px] border-solid border-components-card-border rounded-xl shadow-sm min-h-[160px] flex flex-col transition-all duration-200 ease-in-out cursor-pointer hover:shadow-lg' |
| | | data-disable-nprogress={true} |
| | | onClick={(e) => { |
| | | e.preventDefault() |
| | |
| | | }} |
| | | > |
| | | {isExternalProvider(dataset.provider) && <CornerLabel label='External' className='absolute right-0' labelClassName='rounded-tr-xl' />} |
| | | <div className='flex h-[66px] shrink-0 grow-0 items-center gap-3 px-[14px] pb-3 pt-[14px]'> |
| | | <div className='flex pt-[14px] px-[14px] pb-3 h-[66px] items-center gap-3 grow-0 shrink-0'> |
| | | <div className={cn( |
| | | 'flex shrink-0 items-center justify-center rounded-md border-[0.5px] border-[#E0EAFF] bg-[#F5F8FF] p-2.5', |
| | | 'shrink-0 flex items-center justify-center p-2.5 bg-[#F5F8FF] rounded-md border-[0.5px] border-[#E0EAFF]', |
| | | !dataset.embedding_available && 'opacity-50 hover:opacity-100', |
| | | )}> |
| | | <Folder className='h-5 w-5 text-[#444CE7]' /> |
| | | <Folder className='w-5 h-5 text-[#444CE7]' /> |
| | | </div> |
| | | <div className='w-0 grow py-[1px]'> |
| | | <div className='flex items-center text-sm font-semibold leading-5 text-text-secondary'> |
| | | <div className={cn('truncate', !dataset.embedding_available && 'text-text-tertiary opacity-50 hover:opacity-100')} title={dataset.name}>{dataset.name}</div> |
| | | <div className='grow w-0 py-[1px]'> |
| | | <div className='flex items-center text-sm leading-5 font-semibold text-text-secondary'> |
| | | <div className={cn('truncate', !dataset.embedding_available && 'opacity-50 hover:opacity-100 text-text-tertiary')} title={dataset.name}>{dataset.name}</div> |
| | | {!dataset.embedding_available && ( |
| | | <Tooltip |
| | | popupContent={t('dataset.unavailableTip')} |
| | | > |
| | | <span className='ml-1 inline-flex w-max shrink-0 rounded-md border border-divider-regular px-1 text-xs font-normal leading-[18px] text-text-tertiary'>{t('dataset.unavailable')}</span> |
| | | <span className='shrink-0 inline-flex w-max ml-1 px-1 border border-gray-200 rounded-md text-gray-500 text-xs font-normal leading-[18px]'>{t('dataset.unavailable')}</span> |
| | | </Tooltip> |
| | | )} |
| | | </div> |
| | | <div className='mt-[1px] flex items-center text-xs leading-[18px] text-text-tertiary'> |
| | | <div className='flex items-center mt-[1px] text-xs leading-[18px] text-text-tertiary'> |
| | | <div |
| | | className={cn('truncate', (!dataset.embedding_available || !dataset.document_count) && 'opacity-50')} |
| | | title={dataset.provider === 'external' ? `${dataset.app_count}${t('dataset.appCount')}` : `${dataset.document_count}${t('dataset.documentCount')} · ${Math.round(dataset.word_count / 1000)}${t('dataset.wordCount')} · ${dataset.app_count}${t('dataset.appCount')}`} |
| | |
| | | </> |
| | | : <> |
| | | <span>{dataset.document_count}{t('dataset.documentCount')}</span> |
| | | <span className='mx-0.5 w-1 shrink-0 text-text-tertiary'>·</span> |
| | | <span className='shrink-0 mx-0.5 w-1 text-gray-400'>·</span> |
| | | <span>{Math.round(dataset.word_count / 1000)}{t('dataset.wordCount')}</span> |
| | | <span className='mx-0.5 w-1 shrink-0 text-text-tertiary'>·</span> |
| | | <span className='shrink-0 mx-0.5 w-1 text-gray-400'>·</span> |
| | | <span>{dataset.app_count}{t('dataset.appCount')}</span> |
| | | </> |
| | | } |
| | |
| | | </div> |
| | | <div |
| | | className={cn( |
| | | 'mb-2 max-h-[72px] grow px-[14px] text-xs leading-normal text-text-tertiary group-hover:line-clamp-2 group-hover:max-h-[36px]', |
| | | 'grow mb-2 px-[14px] max-h-[72px] text-xs leading-normal text-text-tertiary group-hover:line-clamp-2 group-hover:max-h-[36px]', |
| | | tags.length ? 'line-clamp-2' : 'line-clamp-4', |
| | | !dataset.embedding_available && 'opacity-50 hover:opacity-100', |
| | | )} |
| | |
| | | {dataset.description} |
| | | </div> |
| | | <div className={cn( |
| | | 'mt-4 h-[42px] shrink-0 items-center pb-[6px] pl-[14px] pr-[6px] pt-1', |
| | | 'items-center shrink-0 mt-1 pt-1 pl-[14px] pr-[6px] pb-[6px] h-[42px]', |
| | | tags.length ? 'flex' : '!hidden group-hover:!flex', |
| | | )}> |
| | | <div className={cn('flex w-0 grow items-center gap-1', !dataset.embedding_available && 'opacity-50 hover:opacity-100')} onClick={(e) => { |
| | | <div className={cn('grow flex items-center gap-1 w-0', !dataset.embedding_available && 'opacity-50 hover:opacity-100')} onClick={(e) => { |
| | | e.stopPropagation() |
| | | e.preventDefault() |
| | | }}> |
| | | <div className={cn( |
| | | 'mr-[41px] w-full grow group-hover:!mr-0 group-hover:!block', |
| | | 'group-hover:!block group-hover:!mr-0 mr-[41px] grow w-full', |
| | | tags.length ? '!block' : '!hidden', |
| | | )}> |
| | | <TagSelector |
| | |
| | | /> |
| | | </div> |
| | | </div> |
| | | <div className='mx-1 !hidden h-[14px] w-[1px] shrink-0 bg-divider-regular group-hover:!flex' /> |
| | | <div className='!hidden shrink-0 group-hover:!flex'> |
| | | <div className='!hidden group-hover:!flex shrink-0 mx-1 w-[1px] h-[14px] bg-gray-200' /> |
| | | <div className='!hidden group-hover:!flex shrink-0'> |
| | | <CustomPopover |
| | | htmlContent={<Operations showDelete={!isCurrentWorkspaceDatasetOperator} />} |
| | | position="br" |
| | | trigger="click" |
| | | btnElement={ |
| | | <div |
| | | className='flex h-8 w-8 cursor-pointer items-center justify-center rounded-md' |
| | | className='flex items-center justify-center w-8 h-8 cursor-pointer rounded-md' |
| | | > |
| | | <RiMoreFill className='h-4 w-4 text-text-secondary' /> |
| | | <RiMoreFill className='w-4 h-4 text-gray-700' /> |
| | | </div> |
| | | } |
| | | btnClassName={open => |
| | | cn( |
| | | open ? '!bg-black/5 !shadow-none' : '!bg-transparent', |
| | | 'h-8 w-8 rounded-md border-none !p-2 hover:!bg-black/5', |
| | | 'h-8 w-8 !p-2 rounded-md border-none hover:!bg-black/5', |
| | | ) |
| | | } |
| | | className={'!z-20 h-fit !w-[128px]'} |
| | | className={'!w-[128px] h-fit !z-20'} |
| | | /> |
| | | </div> |
| | | </div> |