|
|
|
|
@ -28,14 +28,14 @@ import Divider from '@/app/components/base/divider'
|
|
|
|
|
import Popover from '@/app/components/base/popover'
|
|
|
|
|
import Confirm from '@/app/components/base/confirm'
|
|
|
|
|
import Tooltip from '@/app/components/base/tooltip'
|
|
|
|
|
import { ToastContext } from '@/app/components/base/toast'
|
|
|
|
|
import Toast, { ToastContext } from '@/app/components/base/toast'
|
|
|
|
|
import type { ColorMap, IndicatorProps } from '@/app/components/header/indicator'
|
|
|
|
|
import Indicator from '@/app/components/header/indicator'
|
|
|
|
|
import { asyncRunSafe } from '@/utils'
|
|
|
|
|
import { formatNumber } from '@/utils/format'
|
|
|
|
|
import NotionIcon from '@/app/components/base/notion-icon'
|
|
|
|
|
import ProgressBar from '@/app/components/base/progress-bar'
|
|
|
|
|
import { ChuckingMode, DataSourceType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets'
|
|
|
|
|
import { ChuckingMode, DataSourceType, DocumentActionType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets'
|
|
|
|
|
import type { CommonResponse } from '@/models/common'
|
|
|
|
|
import useTimestamp from '@/hooks/use-timestamp'
|
|
|
|
|
import { useDatasetDetailContextWithSelector as useDatasetDetailContext } from '@/context/dataset-detail'
|
|
|
|
|
@ -103,11 +103,11 @@ export const StatusItem: FC<{
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)
|
|
|
|
|
if (!e)
|
|
|
|
|
if (!e) {
|
|
|
|
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
|
|
|
|
else
|
|
|
|
|
notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
|
|
|
|
|
onUpdate?.(operationName)
|
|
|
|
|
onUpdate?.(operationName)
|
|
|
|
|
}
|
|
|
|
|
else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => {
|
|
|
|
|
@ -219,13 +219,13 @@ export const OperationAction: FC<{
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentId: id }) as Promise<CommonResponse>)
|
|
|
|
|
if (!e)
|
|
|
|
|
if (!e) {
|
|
|
|
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
|
|
|
|
else
|
|
|
|
|
notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
|
|
|
|
|
onUpdate(operationName)
|
|
|
|
|
}
|
|
|
|
|
else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) }
|
|
|
|
|
if (operationName === 'delete')
|
|
|
|
|
setDeleting(false)
|
|
|
|
|
onUpdate(operationName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => {
|
|
|
|
|
@ -462,6 +462,37 @@ const DocumentList: FC<IDocumentListProps> = ({
|
|
|
|
|
else
|
|
|
|
|
onSelectedIdChange(uniq([...selectedIds, ...localDocs.map(doc => doc.id)]))
|
|
|
|
|
}, [isAllSelected, localDocs, onSelectedIdChange, selectedIds])
|
|
|
|
|
const { mutateAsync: archiveDocument } = useDocumentArchive()
|
|
|
|
|
const { mutateAsync: enableDocument } = useDocumentEnable()
|
|
|
|
|
const { mutateAsync: disableDocument } = useDocumentDisable()
|
|
|
|
|
const { mutateAsync: deleteDocument } = useDocumentDelete()
|
|
|
|
|
|
|
|
|
|
const handleAction = (actionName: DocumentActionType) => {
|
|
|
|
|
return async () => {
|
|
|
|
|
let opApi = deleteDocument
|
|
|
|
|
switch (actionName) {
|
|
|
|
|
case DocumentActionType.archive:
|
|
|
|
|
opApi = archiveDocument
|
|
|
|
|
break
|
|
|
|
|
case DocumentActionType.enable:
|
|
|
|
|
opApi = enableDocument
|
|
|
|
|
break
|
|
|
|
|
case DocumentActionType.disable:
|
|
|
|
|
opApi = disableDocument
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
opApi = deleteDocument
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
const [e] = await asyncRunSafe<CommonResponse>(opApi({ datasetId, documentIds: selectedIds }) as Promise<CommonResponse>)
|
|
|
|
|
|
|
|
|
|
if (!e) {
|
|
|
|
|
Toast.notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
|
|
|
|
onUpdate()
|
|
|
|
|
}
|
|
|
|
|
else { Toast.notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className='relative w-full h-full overflow-x-auto'>
|
|
|
|
|
@ -588,16 +619,10 @@ const DocumentList: FC<IDocumentListProps> = ({
|
|
|
|
|
<BatchAction
|
|
|
|
|
className='absolute left-0 bottom-16 z-20'
|
|
|
|
|
selectedIds={selectedIds}
|
|
|
|
|
onArchive={() => { }}
|
|
|
|
|
onBatchEnable={() => {
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
onBatchDisable={() => {
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
onBatchDelete={() => {
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
onArchive={handleAction(DocumentActionType.archive)}
|
|
|
|
|
onBatchEnable={handleAction(DocumentActionType.enable)}
|
|
|
|
|
onBatchDisable={handleAction(DocumentActionType.disable)}
|
|
|
|
|
onBatchDelete={handleAction(DocumentActionType.delete)}
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
onSelectedIdChange([])
|
|
|
|
|
}}
|
|
|
|
|
|