import type { FC } from 'react' import { AlertDialog, AlertDialogActions, AlertDialogCancelButton, AlertDialogConfirmButton, AlertDialogContent, AlertDialogDescription, AlertDialogTitle, } from '@langgenius/dify-ui/alert-dialog' import { Button } from '@langgenius/dify-ui/button' import { cn } from '@langgenius/dify-ui/cn' import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine, RiDownload2Line, RiDraftLine, RiRefreshLine } from '@remixicon/react' import { useBoolean } from 'ahooks' import * as React from 'react' import { useTranslation } from 'react-i18next' import Divider from '@/app/components/base/divider' import { SearchLinesSparkle } from '@/app/components/base/icons/src/vender/knowledge' import { IS_CE_EDITION } from '@/config' const i18nPrefix = 'batchAction' type IBatchActionProps = { className?: string selectedIds: string[] onBatchEnable: () => void onBatchDisable: () => void onBatchDownload?: () => void onBatchDelete: () => Promise onBatchSummary?: () => void onArchive?: () => void onEditMetadata?: () => void onBatchReIndex?: () => void onCancel: () => void } const BatchAction: FC = ({ className, selectedIds, onBatchEnable, onBatchDisable, onBatchSummary, onBatchDownload, onArchive, onBatchDelete, onEditMetadata, onBatchReIndex, onCancel, }) => { const { t } = useTranslation() const [isShowDeleteConfirm, { setTrue: showDeleteConfirm, setFalse: hideDeleteConfirm, }] = useBoolean(false) const [isDeleting, { setTrue: setIsDeleting, }] = useBoolean(false) const handleBatchDelete = async () => { setIsDeleting() await onBatchDelete() hideDeleteConfirm() } return (
{selectedIds.length} {t(`${i18nPrefix}.selected`, { ns: 'dataset' })}
{onEditMetadata && ( )} {onBatchSummary && IS_CE_EDITION && ( )} {onArchive && ( )} {onBatchReIndex && ( )} {onBatchDownload && ( )}
!open && hideDeleteConfirm()}>
{t('list.delete.title', { ns: 'datasetDocuments' })} {t('list.delete.content', { ns: 'datasetDocuments' })}
{t('operation.cancel', { ns: 'common' })} {t('operation.sure', { ns: 'common' })}
) } export default React.memo(BatchAction)