list.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. /* eslint-disable no-mixed-operators */
  2. 'use client'
  3. import type { FC, SVGProps } from 'react'
  4. import React, { useCallback, useEffect, useState } from 'react'
  5. import { useBoolean, useDebounceFn } from 'ahooks'
  6. import { ArrowDownIcon, TrashIcon } from '@heroicons/react/24/outline'
  7. import { ExclamationCircleIcon } from '@heroicons/react/24/solid'
  8. import { pick } from 'lodash-es'
  9. import {
  10. RiMoreFill,
  11. RiQuestionLine,
  12. } from '@remixicon/react'
  13. import { useContext } from 'use-context-selector'
  14. import { useRouter } from 'next/navigation'
  15. import { useTranslation } from 'react-i18next'
  16. import cn from 'classnames'
  17. import dayjs from 'dayjs'
  18. import { Edit03 } from '../../base/icons/src/vender/solid/general'
  19. import TooltipPlus from '../../base/tooltip-plus'
  20. import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel'
  21. import s from './style.module.css'
  22. import RenameModal from './rename-modal'
  23. import Switch from '@/app/components/base/switch'
  24. import Divider from '@/app/components/base/divider'
  25. import Popover from '@/app/components/base/popover'
  26. import Modal from '@/app/components/base/modal'
  27. import Button from '@/app/components/base/button'
  28. import Tooltip from '@/app/components/base/tooltip'
  29. import { ToastContext } from '@/app/components/base/toast'
  30. import type { IndicatorProps } from '@/app/components/header/indicator'
  31. import Indicator from '@/app/components/header/indicator'
  32. import { asyncRunSafe } from '@/utils'
  33. import { formatNumber } from '@/utils/format'
  34. import { archiveDocument, deleteDocument, disableDocument, enableDocument, syncDocument, syncWebsite, unArchiveDocument } from '@/service/datasets'
  35. import NotionIcon from '@/app/components/base/notion-icon'
  36. import ProgressBar from '@/app/components/base/progress-bar'
  37. import { DataSourceType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets'
  38. import type { CommonResponse } from '@/models/common'
  39. import useTimestamp from '@/hooks/use-timestamp'
  40. export const SettingsIcon = ({ className }: SVGProps<SVGElement>) => {
  41. return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>
  42. <path d="M2 5.33325L10 5.33325M10 5.33325C10 6.43782 10.8954 7.33325 12 7.33325C13.1046 7.33325 14 6.43782 14 5.33325C14 4.22868 13.1046 3.33325 12 3.33325C10.8954 3.33325 10 4.22868 10 5.33325ZM6 10.6666L14 10.6666M6 10.6666C6 11.7712 5.10457 12.6666 4 12.6666C2.89543 12.6666 2 11.7712 2 10.6666C2 9.56202 2.89543 8.66659 4 8.66659C5.10457 8.66659 6 9.56202 6 10.6666Z" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  43. </svg>
  44. }
  45. export const SyncIcon = () => {
  46. return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
  47. <path d="M5.69773 13.1783C7.29715 13.8879 9.20212 13.8494 10.8334 12.9075C13.5438 11.3427 14.4724 7.87704 12.9076 5.16672L12.7409 4.87804M3.09233 10.8335C1.52752 8.12314 2.45615 4.65746 5.16647 3.09265C6.7978 2.15081 8.70277 2.11227 10.3022 2.82185M1.66226 10.8892L3.48363 11.3773L3.97166 9.5559M12.0284 6.44393L12.5164 4.62256L14.3378 5.1106" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
  48. </svg>
  49. }
  50. export const FilePlusIcon = ({ className }: SVGProps<SVGElement>) => {
  51. return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>
  52. <path d="M13.3332 6.99992V4.53325C13.3332 3.41315 13.3332 2.85309 13.1152 2.42527C12.9234 2.04895 12.6175 1.74299 12.2412 1.55124C11.8133 1.33325 11.2533 1.33325 10.1332 1.33325H5.8665C4.7464 1.33325 4.18635 1.33325 3.75852 1.55124C3.3822 1.74299 3.07624 2.04895 2.88449 2.42527C2.6665 2.85309 2.6665 3.41315 2.6665 4.53325V11.4666C2.6665 12.5867 2.6665 13.1467 2.88449 13.5746C3.07624 13.9509 3.3822 14.2569 3.75852 14.4486C4.18635 14.6666 4.7464 14.6666 5.8665 14.6666H7.99984M9.33317 7.33325H5.33317M6.6665 9.99992H5.33317M10.6665 4.66659H5.33317M11.9998 13.9999V9.99992M9.99984 11.9999H13.9998" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  53. </svg>
  54. }
  55. export const ArchiveIcon = ({ className }: SVGProps<SVGElement>) => {
  56. return <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>
  57. <path d="M2.66683 5.33106C2.55749 5.32824 2.47809 5.32191 2.40671 5.30771C1.87779 5.2025 1.46432 4.78904 1.35912 4.26012C1.3335 4.13132 1.3335 3.97644 1.3335 3.66667C1.3335 3.3569 1.3335 3.20201 1.35912 3.07321C1.46432 2.54429 1.87779 2.13083 2.40671 2.02562C2.53551 2 2.69039 2 3.00016 2H13.0002C13.3099 2 13.4648 2 13.5936 2.02562C14.1225 2.13083 14.536 2.54429 14.6412 3.07321C14.6668 3.20201 14.6668 3.3569 14.6668 3.66667C14.6668 3.97644 14.6668 4.13132 14.6412 4.26012C14.536 4.78904 14.1225 5.2025 13.5936 5.30771C13.5222 5.32191 13.4428 5.32824 13.3335 5.33106M6.66683 8.66667H9.3335M2.66683 5.33333H13.3335V10.8C13.3335 11.9201 13.3335 12.4802 13.1155 12.908C12.9238 13.2843 12.6178 13.5903 12.2415 13.782C11.8137 14 11.2536 14 10.1335 14H5.86683C4.74672 14 4.18667 14 3.75885 13.782C3.38252 13.5903 3.07656 13.2843 2.88482 12.908C2.66683 12.4802 2.66683 11.9201 2.66683 10.8V5.33333Z" stroke="#667085" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  58. </svg>
  59. }
  60. export const useIndexStatus = () => {
  61. const { t } = useTranslation()
  62. return {
  63. queuing: { color: 'orange', text: t('datasetDocuments.list.status.queuing') }, // waiting
  64. indexing: { color: 'blue', text: t('datasetDocuments.list.status.indexing') }, // indexing splitting parsing cleaning
  65. paused: { color: 'orange', text: t('datasetDocuments.list.status.paused') }, // paused
  66. error: { color: 'red', text: t('datasetDocuments.list.status.error') }, // error
  67. available: { color: 'green', text: t('datasetDocuments.list.status.available') }, // completed,archived = false,enabled = true
  68. enabled: { color: 'green', text: t('datasetDocuments.list.status.enabled') }, // completed,archived = false,enabled = true
  69. disabled: { color: 'gray', text: t('datasetDocuments.list.status.disabled') }, // completed,archived = false,enabled = false
  70. archived: { color: 'gray', text: t('datasetDocuments.list.status.archived') }, // completed,archived = true
  71. }
  72. }
  73. // status item for list
  74. export const StatusItem: FC<{
  75. status: DocumentDisplayStatus
  76. reverse?: boolean
  77. scene?: 'list' | 'detail'
  78. textCls?: string
  79. errorMessage?: string
  80. }> = ({ status, reverse = false, scene = 'list', textCls = '', errorMessage }) => {
  81. const DOC_INDEX_STATUS_MAP = useIndexStatus()
  82. const localStatus = status.toLowerCase() as keyof typeof DOC_INDEX_STATUS_MAP
  83. return <div className={
  84. cn('flex items-center',
  85. reverse ? 'flex-row-reverse' : '',
  86. scene === 'detail' ? s.statusItemDetail : '')
  87. }>
  88. <Indicator color={DOC_INDEX_STATUS_MAP[localStatus]?.color as IndicatorProps['color']} className={reverse ? 'ml-2' : 'mr-2'} />
  89. <span className={cn('text-gray-700 text-sm', textCls)}>{DOC_INDEX_STATUS_MAP[localStatus]?.text}</span>
  90. {
  91. errorMessage && (
  92. <Tooltip
  93. selector='dataset-document-detail-item-status'
  94. htmlContent={
  95. <div className='max-w-[260px] break-all'>{errorMessage}</div>
  96. }
  97. >
  98. <RiQuestionLine className='ml-1 w-[14px] h-[14px] text-gray-700' />
  99. </Tooltip>
  100. )
  101. }
  102. </div>
  103. }
  104. type OperationName = 'delete' | 'archive' | 'enable' | 'disable' | 'sync' | 'un_archive'
  105. // operation action for list and detail
  106. export const OperationAction: FC<{
  107. embeddingAvailable: boolean
  108. detail: {
  109. name: string
  110. enabled: boolean
  111. archived: boolean
  112. id: string
  113. data_source_type: string
  114. doc_form: string
  115. }
  116. datasetId: string
  117. onUpdate: (operationName?: string) => void
  118. scene?: 'list' | 'detail'
  119. className?: string
  120. }> = ({ embeddingAvailable, datasetId, detail, onUpdate, scene = 'list', className = '' }) => {
  121. const { id, enabled = false, archived = false, data_source_type } = detail || {}
  122. const [showModal, setShowModal] = useState(false)
  123. const { notify } = useContext(ToastContext)
  124. const { t } = useTranslation()
  125. const router = useRouter()
  126. const isListScene = scene === 'list'
  127. const onOperate = async (operationName: OperationName) => {
  128. let opApi = deleteDocument
  129. switch (operationName) {
  130. case 'archive':
  131. opApi = archiveDocument
  132. break
  133. case 'un_archive':
  134. opApi = unArchiveDocument
  135. break
  136. case 'enable':
  137. opApi = enableDocument
  138. break
  139. case 'disable':
  140. opApi = disableDocument
  141. break
  142. case 'sync':
  143. if (data_source_type === 'notion_import')
  144. opApi = syncDocument
  145. else
  146. opApi = syncWebsite
  147. break
  148. default:
  149. opApi = deleteDocument
  150. break
  151. }
  152. const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)
  153. if (!e)
  154. notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
  155. else
  156. notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
  157. onUpdate(operationName)
  158. }
  159. const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => {
  160. if (operationName === 'enable' && enabled)
  161. return
  162. if (operationName === 'disable' && !enabled)
  163. return
  164. onOperate(operationName)
  165. }, { wait: 500 })
  166. const [currDocument, setCurrDocument] = useState<{
  167. id: string
  168. name: string
  169. } | null>(null)
  170. const [isShowRenameModal, {
  171. setTrue: setShowRenameModalTrue,
  172. setFalse: setShowRenameModalFalse,
  173. }] = useBoolean(false)
  174. const handleShowRenameModal = useCallback((doc: {
  175. id: string
  176. name: string
  177. }) => {
  178. setCurrDocument(doc)
  179. setShowRenameModalTrue()
  180. }, [setShowRenameModalTrue])
  181. const handleRenamed = useCallback(() => {
  182. onUpdate()
  183. }, [onUpdate])
  184. return <div className='flex items-center' onClick={e => e.stopPropagation()}>
  185. {isListScene && !embeddingAvailable && (
  186. <Switch defaultValue={false} onChange={() => { }} disabled={true} size='md' />
  187. )}
  188. {isListScene && embeddingAvailable && (
  189. <>
  190. {archived
  191. ? <Tooltip selector={`list-switch-${id}`} content={t('datasetDocuments.list.action.enableWarning') as string} className='!font-semibold'>
  192. <div>
  193. <Switch defaultValue={false} onChange={() => { }} disabled={true} size='md' />
  194. </div>
  195. </Tooltip>
  196. : <Switch defaultValue={enabled} onChange={v => handleSwitch(v ? 'enable' : 'disable')} size='md' />
  197. }
  198. <Divider className='!ml-4 !mr-2 !h-3' type='vertical' />
  199. </>
  200. )}
  201. {embeddingAvailable && (
  202. <Popover
  203. htmlContent={
  204. <div className='w-full py-1'>
  205. {!isListScene && <>
  206. <div className='flex justify-between items-center mx-4 pt-2'>
  207. <span className={cn(s.actionName, 'font-medium')}>
  208. {!archived && enabled ? t('datasetDocuments.list.index.enable') : t('datasetDocuments.list.index.disable')}
  209. </span>
  210. <Tooltip
  211. selector={`detail-switch-${id}`}
  212. content={t('datasetDocuments.list.action.enableWarning') as string}
  213. className='!font-semibold'
  214. disabled={!archived}
  215. >
  216. <div>
  217. <Switch
  218. defaultValue={archived ? false : enabled}
  219. onChange={v => !archived && handleSwitch(v ? 'enable' : 'disable')}
  220. disabled={archived}
  221. size='md'
  222. />
  223. </div>
  224. </Tooltip>
  225. </div>
  226. <div className='mx-4 pb-1 pt-0.5 text-xs text-gray-500'>
  227. {!archived && enabled ? t('datasetDocuments.list.index.enableTip') : t('datasetDocuments.list.index.disableTip')}
  228. </div>
  229. <Divider />
  230. </>}
  231. {!archived && (
  232. <>
  233. <div className={s.actionItem} onClick={() => {
  234. handleShowRenameModal({
  235. id: detail.id,
  236. name: detail.name,
  237. })
  238. }}>
  239. <Edit03 className='w-4 h-4 text-gray-500' />
  240. <span className={s.actionName}>{t('datasetDocuments.list.table.rename')}</span>
  241. </div>
  242. <div className={s.actionItem} onClick={() => router.push(`/datasets/${datasetId}/documents/${detail.id}/settings`)}>
  243. <SettingsIcon />
  244. <span className={s.actionName}>{t('datasetDocuments.list.action.settings')}</span>
  245. </div>
  246. {['notion_import', DataSourceType.WEB].includes(data_source_type) && (
  247. <div className={s.actionItem} onClick={() => onOperate('sync')}>
  248. <SyncIcon />
  249. <span className={s.actionName}>{t('datasetDocuments.list.action.sync')}</span>
  250. </div>
  251. )}
  252. <Divider className='my-1' />
  253. </>
  254. )}
  255. {!archived && <div className={s.actionItem} onClick={() => onOperate('archive')}>
  256. <ArchiveIcon />
  257. <span className={s.actionName}>{t('datasetDocuments.list.action.archive')}</span>
  258. </div>}
  259. {archived && (
  260. <div className={s.actionItem} onClick={() => onOperate('un_archive')}>
  261. <ArchiveIcon />
  262. <span className={s.actionName}>{t('datasetDocuments.list.action.unarchive')}</span>
  263. </div>
  264. )}
  265. <div className={cn(s.actionItem, s.deleteActionItem, 'group')} onClick={() => setShowModal(true)}>
  266. <TrashIcon className={'w-4 h-4 stroke-current text-gray-500 stroke-2 group-hover:text-red-500'} />
  267. <span className={cn(s.actionName, 'group-hover:text-red-500')}>{t('datasetDocuments.list.action.delete')}</span>
  268. </div>
  269. </div>
  270. }
  271. trigger='click'
  272. position='br'
  273. btnElement={
  274. <div className={cn(s.commonIcon)}>
  275. <RiMoreFill className='w-4 h-4 text-gray-700' />
  276. </div>
  277. }
  278. btnClassName={open => cn(isListScene ? s.actionIconWrapperList : s.actionIconWrapperDetail, open ? '!bg-gray-100 !shadow-none' : '!bg-transparent')}
  279. className={`flex justify-end !w-[200px] h-fit !z-20 ${className}`}
  280. />
  281. )}
  282. {showModal && <Modal isShow={showModal} onClose={() => setShowModal(false)} className={s.delModal} closable>
  283. <div>
  284. <div className={s.warningWrapper}>
  285. <ExclamationCircleIcon className={s.warningIcon} />
  286. </div>
  287. <div className='text-xl font-semibold text-gray-900 mb-1'>{t('datasetDocuments.list.delete.title')}</div>
  288. <div className='text-sm text-gray-500 mb-10'>{t('datasetDocuments.list.delete.content')}</div>
  289. <div className='flex gap-2 justify-end'>
  290. <Button onClick={() => setShowModal(false)}>{t('common.operation.cancel')}</Button>
  291. <Button
  292. variant='warning'
  293. onClick={() => onOperate('delete')}
  294. className='border-red-700'
  295. >
  296. {t('common.operation.sure')}
  297. </Button>
  298. </div>
  299. </div>
  300. </Modal>}
  301. {isShowRenameModal && currDocument && (
  302. <RenameModal
  303. datasetId={datasetId}
  304. documentId={currDocument.id}
  305. name={currDocument.name}
  306. onClose={setShowRenameModalFalse}
  307. onSaved={handleRenamed}
  308. />
  309. )}
  310. </div>
  311. }
  312. export const renderTdValue = (value: string | number | null, isEmptyStyle = false) => {
  313. return (
  314. <div className={cn(isEmptyStyle ? 'text-gray-400' : 'text-gray-700', s.tdValue)}>
  315. {value ?? '-'}
  316. </div>
  317. )
  318. }
  319. const renderCount = (count: number | undefined) => {
  320. if (!count)
  321. return renderTdValue(0, true)
  322. if (count < 1000)
  323. return count
  324. return `${formatNumber((count / 1000).toFixed(1))}k`
  325. }
  326. type LocalDoc = SimpleDocumentDetail & { percent?: number }
  327. type IDocumentListProps = {
  328. embeddingAvailable: boolean
  329. documents: LocalDoc[]
  330. datasetId: string
  331. onUpdate: () => void
  332. }
  333. /**
  334. * Document list component including basic information
  335. */
  336. const DocumentList: FC<IDocumentListProps> = ({ embeddingAvailable, documents = [], datasetId, onUpdate }) => {
  337. const { t } = useTranslation()
  338. const { formatTime } = useTimestamp()
  339. const router = useRouter()
  340. const [localDocs, setLocalDocs] = useState<LocalDoc[]>(documents)
  341. const [enableSort, setEnableSort] = useState(false)
  342. useEffect(() => {
  343. setLocalDocs(documents)
  344. }, [documents])
  345. const onClickSort = () => {
  346. setEnableSort(!enableSort)
  347. if (!enableSort) {
  348. const sortedDocs = [...localDocs].sort((a, b) => dayjs(a.created_at).isBefore(dayjs(b.created_at)) ? -1 : 1)
  349. setLocalDocs(sortedDocs)
  350. }
  351. else {
  352. setLocalDocs(documents)
  353. }
  354. }
  355. const [currDocument, setCurrDocument] = useState<LocalDoc | null>(null)
  356. const [isShowRenameModal, {
  357. setTrue: setShowRenameModalTrue,
  358. setFalse: setShowRenameModalFalse,
  359. }] = useBoolean(false)
  360. const handleShowRenameModal = useCallback((doc: LocalDoc) => {
  361. setCurrDocument(doc)
  362. setShowRenameModalTrue()
  363. }, [setShowRenameModalTrue])
  364. const handleRenamed = useCallback(() => {
  365. onUpdate()
  366. }, [onUpdate])
  367. return (
  368. <div className='w-full h-full overflow-x-auto'>
  369. <table className={`min-w-[700px] max-w-full w-full border-collapse border-0 text-sm mt-3 ${s.documentTable}`}>
  370. <thead className="h-8 leading-8 border-b border-gray-200 text-gray-500 font-medium text-xs uppercase">
  371. <tr>
  372. <td className='w-12'>#</td>
  373. <td>
  374. <div className='flex'>
  375. {t('datasetDocuments.list.table.header.fileName')}
  376. </div>
  377. </td>
  378. <td className='w-24'>{t('datasetDocuments.list.table.header.words')}</td>
  379. <td className='w-44'>{t('datasetDocuments.list.table.header.hitCount')}</td>
  380. <td className='w-44'>
  381. <div className='flex justify-between items-center'>
  382. {t('datasetDocuments.list.table.header.uploadTime')}
  383. <ArrowDownIcon className={cn('h-3 w-3 stroke-current stroke-2 cursor-pointer', enableSort ? 'text-gray-500' : 'text-gray-300')} onClick={onClickSort} />
  384. </div>
  385. </td>
  386. <td className='w-40'>{t('datasetDocuments.list.table.header.status')}</td>
  387. <td className='w-20'>{t('datasetDocuments.list.table.header.action')}</td>
  388. </tr>
  389. </thead>
  390. <tbody className="text-gray-700">
  391. {localDocs.map((doc) => {
  392. const isFile = doc.data_source_type === DataSourceType.FILE
  393. const fileType = isFile ? doc.data_source_detail_dict?.upload_file.extension : ''
  394. return <tr
  395. key={doc.id}
  396. className={'border-b border-gray-200 h-8 hover:bg-gray-50 cursor-pointer'}
  397. onClick={() => {
  398. router.push(`/datasets/${datasetId}/documents/${doc.id}`)
  399. }}>
  400. <td className='text-left align-middle text-gray-500 text-xs'>{doc.position}</td>
  401. <td>
  402. <div className='group flex items-center justify-between'>
  403. <span className={s.tdValue}>
  404. {doc?.data_source_type === DataSourceType.NOTION && <NotionIcon className='inline-flex -mt-[3px] mr-1.5 align-middle' type='page' src={doc.data_source_info.notion_page_icon} />
  405. }
  406. {doc?.data_source_type === DataSourceType.FILE && <div className={cn(s[`${doc?.data_source_info?.upload_file?.extension ?? fileType}Icon`], s.commonIcon, 'mr-1.5')}></div>}
  407. {doc?.data_source_type === DataSourceType.WEB && <Globe01 className='inline-flex -mt-[3px] mr-1.5 align-middle' />
  408. }
  409. {
  410. doc.name
  411. }
  412. </span>
  413. <div className='group-hover:flex hidden'>
  414. <TooltipPlus popupContent={t('datasetDocuments.list.table.rename')}>
  415. <div
  416. className='p-1 rounded-md cursor-pointer hover:bg-black/5'
  417. onClick={(e) => {
  418. e.stopPropagation()
  419. handleShowRenameModal(doc)
  420. }}
  421. >
  422. <Edit03 className='w-4 h-4 text-gray-500' />
  423. </div>
  424. </TooltipPlus>
  425. </div>
  426. </div>
  427. </td>
  428. <td>{renderCount(doc.word_count)}</td>
  429. <td>{renderCount(doc.hit_count)}</td>
  430. <td className='text-gray-500 text-[13px]'>
  431. {formatTime(doc.created_at, t('datasetHitTesting.dateTimeFormat') as string)}
  432. </td>
  433. <td>
  434. {
  435. (['indexing', 'splitting', 'parsing', 'cleaning'].includes(doc.indexing_status) && doc?.data_source_type === DataSourceType.NOTION)
  436. ? <ProgressBar percent={doc.percent || 0} />
  437. : <StatusItem status={doc.display_status} />
  438. }
  439. </td>
  440. <td>
  441. <OperationAction
  442. embeddingAvailable={embeddingAvailable}
  443. datasetId={datasetId}
  444. detail={pick(doc, ['name', 'enabled', 'archived', 'id', 'data_source_type', 'doc_form'])}
  445. onUpdate={onUpdate}
  446. />
  447. </td>
  448. </tr>
  449. })}
  450. </tbody>
  451. </table>
  452. {isShowRenameModal && currDocument && (
  453. <RenameModal
  454. datasetId={datasetId}
  455. documentId={currDocument.id}
  456. name={currDocument.name}
  457. onClose={setShowRenameModalFalse}
  458. onSaved={handleRenamed}
  459. />
  460. )}
  461. </div>
  462. )
  463. }
  464. export default DocumentList