'use client' 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 { useState } from 'react' import { useTranslation } from 'react-i18next' import Divider from '@/app/components/base/divider' type AccessRulesBatchActionProps = { className?: string selectedCount: number onDelete: () => Promise onCancel: () => void } export default function AccessRulesBatchAction({ className, selectedCount, onDelete, onCancel, }: AccessRulesBatchActionProps) { const { t } = useTranslation() const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = useState(false) const [isDeleting, setIsDeleting] = useState(false) const handleDelete = async () => { setIsDeleting(true) try { await onDelete() setIsDeleteConfirmOpen(false) } finally { setIsDeleting(false) } } return (
$['operation.selectCount'], { ns: 'common', count: selectedCount, })} className="pointer-events-auto flex items-center gap-1 rounded-[10px] border border-components-actionbar-border-accent bg-components-actionbar-bg-accent p-1 shadow-xl shadow-shadow-shadow-5" >
{selectedCount} {t(($) => $['accessRule.selected'], { ns: 'permission' })}
{ if (!isDeleting) setIsDeleteConfirmOpen(open) }} >
{t(($) => $['accessRule.batchRemoveTitle'], { ns: 'permission' })} {t(($) => $['accessRule.batchRemoveDescription'], { ns: 'permission', count: selectedCount, })}
{t(($) => $['operation.cancel'], { ns: 'common' })} {t(($) => $['operation.sure'], { ns: 'common' })}
) }