# All files / src/components/features/namespace-manager DeleteNamespaceDialog.tsx

0% Statements 0/72
0% Branches 0/1
0% Functions 0/1
0% Lines 0/72

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73

     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>
        </>
      )
    }