From a8efcd4dd2cc71510037f2c85f546a65270bb259 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 17 Jan 2026 22:18:29 +0000 Subject: [PATCH] Split NamespaceSelector.tsx into dialog components Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- .../CreateNamespaceDialog.tsx | 64 ++++++++++++ .../DeleteNamespaceDialog.tsx | 64 ++++++++++++ .../namespace-manager/NamespaceSelector.tsx | 97 ++++--------------- 3 files changed, 148 insertions(+), 77 deletions(-) create mode 100644 src/components/features/namespace-manager/CreateNamespaceDialog.tsx create mode 100644 src/components/features/namespace-manager/DeleteNamespaceDialog.tsx diff --git a/src/components/features/namespace-manager/CreateNamespaceDialog.tsx b/src/components/features/namespace-manager/CreateNamespaceDialog.tsx new file mode 100644 index 0000000..63750a7 --- /dev/null +++ b/src/components/features/namespace-manager/CreateNamespaceDialog.tsx @@ -0,0 +1,64 @@ +import { Button } from '@/components/ui/button' +import { Input } from '@/components/ui/input' +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@/components/ui/dialog' +import { Plus } from '@phosphor-icons/react' + +interface CreateNamespaceDialogProps { + open: boolean + onOpenChange: (open: boolean) => void + namespaceName: string + onNamespaceNameChange: (name: string) => void + onCreateNamespace: () => void + loading: boolean +} + +export function CreateNamespaceDialog({ + open, + onOpenChange, + namespaceName, + onNamespaceNameChange, + onCreateNamespace, + loading, +}: CreateNamespaceDialogProps) { + return ( + + + + + + + Create Namespace + + Create a new namespace to organize your snippets + + +
+ onNamespaceNameChange(e.target.value)} + onKeyPress={(e) => e.key === 'Enter' && onCreateNamespace()} + /> +
+ + + + +
+
+ ) +} diff --git a/src/components/features/namespace-manager/DeleteNamespaceDialog.tsx b/src/components/features/namespace-manager/DeleteNamespaceDialog.tsx new file mode 100644 index 0000000..adcd495 --- /dev/null +++ b/src/components/features/namespace-manager/DeleteNamespaceDialog.tsx @@ -0,0 +1,64 @@ +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 && ( + + )} + + + + + Delete Namespace + + Are you sure you want to delete "{namespace?.name}"? All snippets in this namespace will be moved to the default namespace. + + + + Cancel + + Delete + + + + + + ) +} diff --git a/src/components/features/namespace-manager/NamespaceSelector.tsx b/src/components/features/namespace-manager/NamespaceSelector.tsx index 6f27172..0d034c1 100644 --- a/src/components/features/namespace-manager/NamespaceSelector.tsx +++ b/src/components/features/namespace-manager/NamespaceSelector.tsx @@ -1,6 +1,4 @@ import { useState, useEffect } from 'react' -import { Button } from '@/components/ui/button' -import { Input } from '@/components/ui/input' import { Select, SelectContent, @@ -8,26 +6,7 @@ import { SelectTrigger, SelectValue, } from '@/components/ui/select' -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from '@/components/ui/dialog' -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from '@/components/ui/alert-dialog' -import { Plus, Trash, Folder } from '@phosphor-icons/react' +import { Folder } from '@phosphor-icons/react' import { toast } from 'sonner' import { Namespace } from '@/lib/types' import { @@ -35,6 +14,8 @@ import { createNamespace, deleteNamespace, } from '@/lib/db' +import { CreateNamespaceDialog } from './CreateNamespaceDialog' +import { DeleteNamespaceDialog } from './DeleteNamespaceDialog' interface NamespaceSelectorProps { selectedNamespaceId: string | null @@ -149,67 +130,29 @@ export function NamespaceSelector({ selectedNamespaceId, onNamespaceChange }: Na - - - - - - - Create Namespace - - Create a new namespace to organize your snippets - - -
- setNewNamespaceName(e.target.value)} - onKeyPress={(e) => e.key === 'Enter' && handleCreateNamespace()} - /> -
- - - - -
-
+ {selectedNamespace && !selectedNamespace.isDefault && ( - + /> )} - - - - - Delete Namespace - - Are you sure you want to delete "{namespaceToDelete?.name}"? All snippets in this namespace will be moved to the default namespace. - - - - Cancel - - Delete - - - - ) }