# All files / src/components SnippetManagerRedux.tsx

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

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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140

     import { SnippetDialog } from '@/components/features/snippet-editor/SnippetDialog'
    import { SnippetViewer } from '@/components/features/snippet-viewer/SnippetViewer'
    import { EmptyState } from '@/components/features/snippet-display/EmptyState'
    import { NamespaceSelector } from '@/components/features/namespace-manager/NamespaceSelector'
    import { SnippetTemplate } from '@/lib/types'
    import templatesData from '@/data/templates.json'
    import { useSnippetManager } from '@/hooks/useSnippetManager'
    import { SnippetToolbar } from '@/components/snippet-manager/SnippetToolbar'
    import { SelectionControls } from '@/components/snippet-manager/SelectionControls'
    import { SnippetGrid } from '@/components/snippet-manager/SnippetGrid'

    const templates = templatesData as SnippetTemplate[]

    export function SnippetManagerRedux() {
      const {
        snippets,
        filteredSnippets,
        loading,
        selectionMode,
        selectedIds,
        namespaces,
        selectedNamespaceId,
        dialogOpen,
        viewerOpen,
        editingSnippet,
        viewingSnippet,
        searchQuery,
        handleSaveSnippet,
        handleEditSnippet,
        handleDeleteSnippet,
        handleCopyCode,
        handleViewSnippet,
        handleMoveSnippet,
        handleCreateNew,
        handleCreateFromTemplate,
        handleToggleSelectionMode,
        handleToggleSnippetSelection,
        handleSelectAll,
        handleBulkMove,
        handleNamespaceChange,
        handleSearchChange,
        handleDialogClose,
        handleViewerClose,
      } = useSnippetManager(templates)

      if (loading) {
        return (
          <div className="text-center py-20" data-testid="snippet-manager-loading">
            <p className="text-muted-foreground">Loading snippets...</p>
          </div>
        )
      }

      if (snippets.length === 0) {
        return (
          <>
            <div className="mb-6">
              <NamespaceSelector
                selectedNamespaceId={selectedNamespaceId}
                onNamespaceChange={handleNamespaceChange}
              />
            </div>
            <EmptyState
              onCreateClick={handleCreateNew}
              onCreateFromTemplate={handleCreateFromTemplate}
            />
            <SnippetDialog
              open={dialogOpen}
              onOpenChange={handleDialogClose}
              onSave={handleSaveSnippet}
              editingSnippet={editingSnippet}
            />
          </>
        )
      }

      return (
        <div className="space-y-6" data-testid="snippet-manager">
          <NamespaceSelector
            selectedNamespaceId={selectedNamespaceId}
            onNamespaceChange={handleNamespaceChange}
          />

          <SnippetToolbar
            searchQuery={searchQuery}
            onSearchChange={handleSearchChange}
            selectionMode={selectionMode}
            onToggleSelectionMode={handleToggleSelectionMode}
            onCreateNew={handleCreateNew}
            onCreateFromTemplate={handleCreateFromTemplate}
            templates={templates}
          />

          {selectionMode && (
            <SelectionControls
              selectedIds={selectedIds}
              totalFilteredCount={filteredSnippets.length}
              namespaces={namespaces}
              currentNamespaceId={selectedNamespaceId}
              onSelectAll={handleSelectAll}
              onBulkMove={handleBulkMove}
            />
          )}

          {filteredSnippets.length === 0 && searchQuery && (
            <div className="text-center py-20">
              <p className="text-muted-foreground">No snippets found matching "{searchQuery}"</p>
            </div>
          )}

          <SnippetGrid
            snippets={filteredSnippets}
            onView={handleViewSnippet}
            onEdit={handleEditSnippet}
            onDelete={handleDeleteSnippet}
            onCopy={handleCopyCode}
            onMove={handleMoveSnippet}
            selectionMode={selectionMode}
            selectedIds={selectedIds}
            onToggleSelect={handleToggleSnippetSelection}
          />

          <SnippetDialog
            open={dialogOpen}
            onOpenChange={handleDialogClose}
            onSave={handleSaveSnippet}
            editingSnippet={editingSnippet}
          />

          <SnippetViewer
            open={viewerOpen}
            onOpenChange={handleViewerClose}
            snippet={viewingSnippet}
            onEdit={handleEditSnippet}
            onCopy={handleCopyCode}
          />
        </div>
      )
    }