Feature request: Add delete confirmation dialog to file manager #344
Reference in New Issue
Block a user
Delete Branch "feature/file-manager-delete-confirmation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add Confirmation Dialog for File Manager Delete Operations
🎯 Overview
This PR adds a safety confirmation dialog before deleting files and folders in the File Manager, preventing accidental data loss.
📝 Changes
🔧 Technical Details
useConfirmationhook for consistent UXconfirmWithToastwith destructive styling (red action button)📦 Files Changed
src/ui/Desktop/Apps/File Manager/FileManager.tsx- Added confirmation logic tohandleDeleteFilessrc/locales/en/translation.json- Added new translation keys for confirmation messages🌐 New Translation Keys
confirmDeleteSingleItem- Single file confirmationconfirmDeleteMultipleItems- Multiple items confirmationconfirmDeleteFolder- Folder deletion with contents warningpermanentDeleteWarning- Universal permanent deletion warning✅ Testing Checklist
📸 User Experience
Before
Pressing Delete or using right-click delete would immediately remove files permanently without any confirmation.
After
Users now see:
💡 Example Messages
Single File:
Folder:
Multiple Items:
🔗 Related Issues
Addresses user request for safer file deletion workflow with confirmation prompts to prevent accidental permanent data loss.
📝 Notes
Branch:
feature/file-manager-delete-confirmationType: Feature Enhancement
Priority: High (Safety Feature)
Summary of Changes
Hello @thorved, I'm Gemini Code Assist1 ! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a crucial safety feature to the File Manager by adding a confirmation dialog before any file or folder deletion. This enhancement aims to prevent accidental data loss by explicitly prompting users to confirm their intent, providing context-specific warnings, and ensuring a consistent user experience across all deletion methods. The change significantly improves the robustness and user-friendliness of the file management system.
Highlights
useConfirmationhook was integrated, utilizingconfirmWithToastwith destructive styling for the action button, ensuring a consistent user experience.Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either
/gemini <command>or@gemini-code-assist <command>. Below is a summary of the supported commands on the current page./gemini review/gemini summary/gemini helpCustomization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a
.gemini/folder in the base of the repository. Detailed instructions can be found here.Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩︎
Code Review
This pull request introduces a confirmation dialog for file and folder deletion, which is a great safety improvement. The implementation correctly uses the
useConfirmationhook and provides context-specific messages for single files, single folders, and multiple items. My main feedback is to enhance the confirmation message for multiple-item deletions that include folders to be more explicit about deleting folder contents, further preventing accidental data loss.@@ -587,54 +589,88 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {async function handleDeleteFiles(files: FileItem[]) {When multiple items are selected for deletion, the confirmation message is generic (
Are you sure you want to permanently delete N items?). If the selection includes one or more folders, this message doesn't warn the user that deleting a folder also deletes all of its contents. This could lead to accidental data loss, which this PR aims to prevent.To improve this, you could check if any of the selected items are directories and show a more specific warning. This would likely require a new translation key.
For example, you could adjust the logic like this:
And the new translation key in
translation.jsoncould be:"confirmDeleteMultipleItemsWithFolders": "Are you sure you want to permanently delete {{count}} items? This includes folders and their contents."@@ -587,54 +589,88 @@ function FileManagerContent({ initialHost, onClose }: FileManagerProps) {async function handleDeleteFiles(files: FileItem[]) {