Files
snippet-pastebin/src/components/features/namespace-manager/DeleteNamespaceDialog.tsx
johndoe6345789 e023b2da41 Add data-testid and accessibility improvements across components
Enhancements include:
- Added data-testid attributes to all interactive components for improved e2e testing
- Improved ARIA labels and semantic HTML attributes throughout
- Added aria-label, aria-hidden, aria-describedby, and aria-current where appropriate
- Enhanced form elements with proper aria-invalid and error associations
- Added role attributes to semantic containers
- Improved navigation accessibility with aria-expanded and aria-controls
- Added proper aria-pressed to toggle buttons

Modified components:
- Dialog components (SnippetDialog, CreateNamespaceDialog, DeleteNamespaceDialog)
- Navigation components (NavigationSidebar, Navigation toggle)
- Snippet display components (SnippetCard, SnippetCardActions)
- Snippet manager components (SnippetToolbar, SnippetGrid)
- Snippet editor components (SnippetFormFields, InputParameterList, InputParameterItem)
- Namespace management (NamespaceSelector)
- Layout components (PageLayout)

These changes improve both automated testing capabilities and accessibility for users with disabilities.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-20 18:12:59 +00:00

73 lines
2.0 KiB
TypeScript

import { Button } from '@/components/ui/button'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { Trash } from '@phosphor-icons/react'
import { Namespace } from '@/lib/types'
interface DeleteNamespaceDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
namespace: Namespace | null
onDeleteNamespace: () => void
loading: boolean
showTrigger?: boolean
onOpenDialog?: () => void
}
export function DeleteNamespaceDialog({
open,
onOpenChange,
namespace,
onDeleteNamespace,
loading,
showTrigger = false,
onOpenDialog,
}: DeleteNamespaceDialogProps) {
return (
<>
{showTrigger && (
<Button
variant="outline"
size="icon"
onClick={onOpenDialog}
data-testid="delete-namespace-trigger"
aria-label="Delete namespace"
>
<Trash weight="bold" aria-hidden="true" />
</Button>
)}
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent data-testid="delete-namespace-dialog">
<AlertDialogHeader>
<AlertDialogTitle>Delete Namespace</AlertDialogTitle>
<AlertDialogDescription>
Are you sure you want to delete "{namespace?.name}"? All snippets in this namespace will be moved to the default namespace.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel data-testid="delete-namespace-cancel-btn">
Cancel
</AlertDialogCancel>
<AlertDialogAction
onClick={onDeleteNamespace}
disabled={loading}
data-testid="delete-namespace-confirm-btn"
>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
)
}