import type { FC } from 'react' 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 Button from '@/app/components/base/button' import Confirm from '@/app/components/base/confirm' import Divider from '@/app/components/base/divider' import { SearchLinesSparkle } from '@/app/components/base/icons/src/vender/knowledge' import { IS_CE_EDITION } from '@/config' import { cn } from '@/utils/classnames' 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 && ( )}
{ isShowDeleteConfirm && ( ) }
) } export default React.memo(BatchAction)