Skip to content

Conversation

@290Priyansh
Copy link

@290Priyansh 290Priyansh commented Jan 5, 2026

Fixes: #939
Adds a warning and confirmation dialog before folder deletion to prevent accidental data loss.
Does not affect files on disk.

Before

delete1.mp4

After

delete2.mp4

Summary by CodeRabbit

  • New Features
    • Introduced a confirmation dialog for folder deletion in library management. The dialog displays the affected folder path and provides a clear explanation of what happens when you delete a folder and its associated content. Users must explicitly confirm their action before folders are permanently removed from the library.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added enhancement New feature or request frontend good first issue Good for newcomers labels Jan 5, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

Adds a confirmation dialog component for folder deletion and integrates it into the folder management UI. Users now see a warning dialog before deletion is executed, replacing immediate deletion with a two-step confirmation flow.

Changes

Cohort / File(s) Summary
New Confirmation Dialog
frontend/src/components/Dialog/DeleteFolderDialog.tsx
New React functional component implementing a styled modal dialog with folder path display, warning message, and action buttons (Cancel, Delete from Library). Handles open/close state and confirm callback.
Folder Management Integration
frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx
Introduces deletion confirmation flow with local state (deleteDialogOpen, folderToDelete) and handlers (handleDeleteClick, handleConfirmDelete). Integrates DeleteFolderDialog component, changing delete button action from immediate deletion to dialog trigger. Minor fix to percent display default value.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

frontend, enhancement

Poem

🐰 A dialog appears with a warning so clear,
"Delete this folder?" now holds no fear.
Confirmation clicked twice, intentions confirmed,
Safe deletion achieved—no data burned! 🗑️✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a confirmation dialog before folder deletion.
Linked Issues check ✅ Passed All objectives from issue #939 are met: warning message, explicit confirmation dialog, and deletion only after user confirmation are all implemented.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the confirmation dialog feature requested in issue #939; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
frontend/src/components/Dialog/DeleteFolderDialog.tsx (3)

27-30: Consider handling async deletion with loading states.

The handleConfirm function calls onConfirm() and immediately closes the dialog. If the deletion operation is asynchronous, users won't see loading feedback or errors within the dialog context. Consider:

  1. Making onConfirm return a Promise
  2. Showing a loading state while the operation completes
  3. Handling errors before closing the dialog

This would provide better user feedback during slow operations or failures.

💡 Example async handling pattern
+  const [isDeleting, setIsDeleting] = useState(false);
+
-  const handleConfirm = () => {
+  const handleConfirm = async () => {
+    setIsDeleting(true);
+    try {
+      await onConfirm();
-    onConfirm();
      setIsOpen(false);
+    } catch (error) {
+      // Handle error (show message, etc.)
+    } finally {
+      setIsDeleting(false);
+    }
  };

And update the button:

  <Button
    variant="destructive"
    onClick={handleConfirm}
+   disabled={isDeleting}
    className="cursor-pointer"
  >
-   Delete from Library
+   {isDeleting ? 'Deleting...' : 'Delete from Library'}
  </Button>

42-67: Consider accessibility of complex content in DialogDescription.

The DialogDescription component contains complex structured content including styled divs, lists, and multiple sections. For optimal accessibility, DialogDescription typically maps to aria-describedby and works best with simpler text content.

Consider moving the complex warning content outside of DialogDescription but still within DialogContent, keeping only a brief description text in DialogDescription.

💡 Example structure
  <DialogHeader>
    <div className="flex items-center gap-3">
      <div className="flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/20">
        <AlertTriangle className="h-5 w-5 text-red-600 dark:text-red-400" />
      </div>
      <DialogTitle className="text-xl">Delete Folder?</DialogTitle>
    </div>
    <DialogDescription className="pt-4 text-left">
-     <div className="space-y-3">
-       <p className="font-medium text-foreground">
-         You are about to remove this folder from your library:
-       </p>
-       ...
-     </div>
+     You are about to remove this folder from your library. This action will remove the folder and all associated data from PictoPy, but your files on disk will remain safe.
    </DialogDescription>
  </DialogHeader>
+ <div className="space-y-3 px-6">
+   {/* Move detailed content here */}
+ </div>

71-84: Minor: Redundant cursor-pointer classes on buttons.

The className="cursor-pointer" on both buttons is redundant since buttons have cursor: pointer by default in the UI library.

  <Button
    variant="outline"
    onClick={() => setIsOpen(false)}
-   className="cursor-pointer"
  >
    Cancel
  </Button>
  <Button
    variant="destructive"
    onClick={handleConfirm}
-   className="cursor-pointer"
  >
    Delete from Library
  </Button>
frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx (1)

44-49: Consider awaiting the async delete operation.

The handleConfirmDelete function calls deleteFolder and immediately clears the state. If deleteFolder is asynchronous (suggested by the deleteFolderPending state), consider awaiting it to:

  1. Keep the dialog open during the operation
  2. Handle errors gracefully before clearing state
  3. Provide user feedback on success/failure
💡 Example async handling
- const handleConfirmDelete = () => {
+ const handleConfirmDelete = async () => {
    if (folderToDelete) {
-     deleteFolder(folderToDelete.folder_id);
+     try {
+       await deleteFolder(folderToDelete.folder_id);
+     } catch (error) {
+       // Error handling might be done in the hook itself
+       console.error('Failed to delete folder:', error);
+     }
      setFolderToDelete(null);
    }
  };

Note: This also requires updating the onConfirm prop type in DeleteFolderDialog to accept async functions.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe45e2f and fae2466.

📒 Files selected for processing (2)
  • frontend/src/components/Dialog/DeleteFolderDialog.tsx
  • frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/components/Dialog/DeleteFolderDialog.tsx (1)
frontend/src/components/ui/dialog.tsx (6)
  • Dialog (133-133)
  • DialogContent (135-135)
  • DialogHeader (138-138)
  • DialogTitle (141-141)
  • DialogDescription (136-136)
  • DialogFooter (137-137)
🔇 Additional comments (2)
frontend/src/pages/SettingsPage/components/FolderManagementCard.tsx (2)

90-90: Excellent implementation of the confirmation flow.

The change from directly calling deleteFolder to opening the confirmation dialog via handleDeleteClick properly implements the safety mechanism requested in issue #939. Users now get an explicit warning and confirmation step before deletion occurs.


154-160: LGTM: Dialog integration is clean and complete.

The DeleteFolderDialog component is properly integrated with all required props. The defensive use of optional chaining (folderToDelete?.folder_path || '') for the folder path is good practice, even though the dialog should only be open when a folder is selected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request frontend good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confirmation before deleating a folder

1 participant