# All files / src/components/snippet-manager SelectionControls.tsx

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

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
    74
    75

     import { Button } from '@/components/ui/button'
    import { FolderOpen } from '@phosphor-icons/react'
    import {
      DropdownMenu,
      DropdownMenuContent,
      DropdownMenuItem,
      DropdownMenuTrigger,
    } from '@/components/ui/dropdown-menu'
    import { Namespace } from '@/lib/types'

    interface SelectionControlsProps {
      selectedIds: string[]
      totalFilteredCount: number
      namespaces: Namespace[]
      currentNamespaceId: string | null
      onSelectAll: () => void
      onBulkMove: (namespaceId: string) => void
    }

    export function SelectionControls({
      selectedIds,
      totalFilteredCount,
      namespaces,
      currentNamespaceId,
      onSelectAll,
      onBulkMove,
    }: SelectionControlsProps) {
      return (
        <div className="flex items-center gap-2 p-4 bg-muted/50 rounded-lg" data-testid="selection-controls">
          <Button
            variant="outline"
            size="sm"
            onClick={onSelectAll}
            data-testid="select-all-btn"
            aria-label={selectedIds.length === totalFilteredCount ? 'Deselect all snippets' : 'Select all snippets'}
          >
            {selectedIds.length === totalFilteredCount ? 'Deselect All' : 'Select All'}
          </Button>
          {selectedIds.length > 0 && (
            <>
              <span className="text-sm text-muted-foreground" data-testid="selection-count">
                {selectedIds.length} selected
              </span>
              <DropdownMenu>
                <DropdownMenuTrigger asChild>
                  <Button
                    variant="outline"
                    size="sm"
                    className="gap-2"
                    data-testid="bulk-move-menu-trigger"
                    aria-label="Move selected snippets to another namespace"
                  >
                    <FolderOpen weight="bold" className="h-4 w-4" aria-hidden="true" />
                    Move to...
                  </Button>
                </DropdownMenuTrigger>
                <DropdownMenuContent data-testid="bulk-move-menu">
                  {namespaces.map((namespace) => (
                    <DropdownMenuItem
                      key={namespace.id}
                      onClick={() => onBulkMove(namespace.id)}
                      disabled={namespace.id === currentNamespaceId}
                      data-testid={`bulk-move-to-namespace-${namespace.id}`}
                    >
                      {namespace.name} {namespace.isDefault && '(Default)'}
                    </DropdownMenuItem>
                  ))}
                </DropdownMenuContent>
              </DropdownMenu>
            </>
          )}
        </div>
      )
    }