import React, { useEffect, useState } from 'react'; import { useI18n } from '../../application/i18n/I18nProvider'; import { hostTreeInlineGroupDeleteStore, useHostTreeInlineGroupDeleteTarget, } from '../../application/state/hostTreeInlineGroupDeleteStore'; import { Button } from '../ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '../ui/dialog'; type HostTreeGroupDeleteDialogProps = { managedGroupPaths?: Set; onConfirmDelete: (groupPath: string, deleteHosts: boolean) => void | Promise; }; export const HostTreeGroupDeleteDialog: React.FC = ({ managedGroupPaths, onConfirmDelete, }) => { const { t } = useI18n(); const targetPath = useHostTreeInlineGroupDeleteTarget(); const [deleteHosts, setDeleteHosts] = useState(false); const isOpen = Boolean(targetPath); const isManaged = Boolean(targetPath && managedGroupPaths?.has(targetPath)); useEffect(() => { if (!isOpen) { setDeleteHosts(false); } }, [isOpen]); return ( { if (!open) hostTreeInlineGroupDeleteStore.close(); }} > {t('vault.groups.deleteDialogTitle')} {isManaged ? t('vault.groups.deleteDialog.managedDesc') : t('vault.groups.deleteDialog.desc')}
{targetPath && ( <>

{t('vault.groups.pathLabel')}:{' '} {targetPath}

{!isManaged && ( )} )}
); };