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 { useSuspenseQuery } from '@tanstack/react-query' 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 { systemFeaturesQueryOptions } from '@/features/system-features/client' 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 { data: deploymentEdition } = useSuspenseQuery({ ...systemFeaturesQueryOptions(), select: ({ deployment_edition }) => deployment_edition, }) const isNonCloudEdition = deploymentEdition === 'COMMUNITY' || deploymentEdition === 'ENTERPRISE' const [isShowDeleteConfirm, { setTrue: showDeleteConfirm, setFalse: hideDeleteConfirm }] = useBoolean(false) const [isDeleting, { setTrue: setIsDeleting }] = useBoolean(false) const handleBatchDelete = async () => { if (!onBatchDelete) return setIsDeleting() await onBatchDelete() hideDeleteConfirm() } return (
{selectedIds.length} {t(($) => $[`${i18nPrefix}.selected`], { ns: 'dataset' })}
{onBatchEnable && ( )} {onBatchDisable && ( )} {onEditMetadata && ( )} {onBatchSummary && isNonCloudEdition && ( )} {onArchive && ( )} {onBatchReIndex && ( )} {onBatchDownload && ( )} {onBatchDelete && ( )}
{onBatchDelete && ( !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)