-
-
Notifications
You must be signed in to change notification settings - Fork 615
fix: added confirmation modal for folder deletion-955 #1233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| import React from 'react'; | ||
| import React, { useState } from 'react'; | ||
| import { Folder, Trash2, Check } from 'lucide-react'; | ||
|
|
||
| import { Switch } from '@/components/ui/switch'; | ||
| import { Button } from '@/components/ui/button'; | ||
| import { Progress } from '@/components/ui/progress'; | ||
| import { useSelector } from 'react-redux'; | ||
| import { RootState } from '@/app/store'; | ||
| import { RootState } from '@/store/store'; | ||
| // import { RootState } from '@/app/store'; | ||
| import FolderPicker from '@/components/FolderPicker/FolderPicker'; | ||
|
|
||
| import { useFolderOperations } from '@/hooks/useFolderOperations'; | ||
|
|
@@ -16,6 +17,10 @@ import SettingsCard from './SettingsCard'; | |
| * Component for managing folder operations in settings | ||
| */ | ||
| const FolderManagementCard: React.FC = () => { | ||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const [selectedFolder, setSelectedFolder] = useState<string | null>(null); | ||
| // const [selectedFolder, setSelectedFolder] = useState<any>(null); | ||
| // const taggingStatus = useSelector((state: any) => state.folders.taggingStatus || {}); | ||
| const { | ||
| folders, | ||
| toggleAITagging, | ||
|
|
@@ -68,7 +73,11 @@ const FolderManagementCard: React.FC = () => { | |
| </div> | ||
|
|
||
| <Button | ||
| onClick={() => deleteFolder(folder.folder_id)} | ||
| // onClick={() => deleteFolder(folder.folder_id)} | ||
| onClick={() => { | ||
| setSelectedFolder(folder.folder_id); | ||
| setIsModalOpen(true); | ||
| }} | ||
|
Comment on lines
75
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include the specific folder path in the confirmation dialog. The modal currently shows generic text only (Line 151-153). Issue Proposed fix-const [selectedFolder, setSelectedFolder] = useState<string | null>(null);
+const [selectedFolder, setSelectedFolder] = useState<{
+ folder_id: string;
+ folder_path: string;
+} | null>(null);
- onClick={() => {
- setSelectedFolder(folder.folder_id);
- setIsModalOpen(true);
- }}
+ onClick={() => {
+ setSelectedFolder({
+ folder_id: folder.folder_id,
+ folder_path: folder.folder_path,
+ });
+ setIsModalOpen(true);
+ }}
- if (selectedFolder) deleteFolder(selectedFolder);
+ if (selectedFolder) deleteFolder(selectedFolder.folder_id);
- Are you sure? This will remove the folder from the library but not
- from your computer.
+ Are you sure you want to remove this folder from the library?
+ <span className="mt-2 block font-mono text-xs break-all">
+ {selectedFolder?.folder_path}
+ </span>
+ This does not delete files from disk.As per coding guidelines, "Confirm that the code meets the project's requirements and objectives". Also applies to: 144-153 🤖 Prompt for AI Agents |
||
| variant="outline" | ||
| size="sm" | ||
| className="h-8 w-8 cursor-pointer text-gray-500 hover:border-red-300 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400" | ||
|
|
@@ -131,6 +140,37 @@ const FolderManagementCard: React.FC = () => { | |
| <div className="border-border mt-6 border-t pt-6"> | ||
| <FolderPicker /> | ||
| </div> | ||
|
|
||
| {isModalOpen && ( | ||
| <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm"> | ||
| <div className="w-full max-w-sm rounded-xl border border-gray-200 bg-white p-6 shadow-2xl dark:border-gray-800 dark:bg-gray-900"> | ||
| <h3 className="mb-2 text-lg font-semibold text-gray-900 dark:text-white"> | ||
| Delete Folder? | ||
| </h3> | ||
| <p className="mb-6 text-sm text-gray-500 dark:text-gray-400"> | ||
| Are you sure? This will remove the folder from the library but not | ||
| from your computer. | ||
| </p> | ||
| <div className="flex justify-end gap-3"> | ||
| <button | ||
| onClick={() => setIsModalOpen(false)} | ||
| className="rounded-md px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800" | ||
| > | ||
| Cancel | ||
| </button> | ||
| <button | ||
| onClick={() => { | ||
| if (selectedFolder) deleteFolder(selectedFolder); | ||
| setIsModalOpen(false); | ||
| }} | ||
| className="rounded-md bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700" | ||
| > | ||
| Delete | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| )} | ||
|
Comment on lines
+144
to
+173
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add automated tests for the new delete-confirmation flow. This PR introduces critical destructive-action behavior, but no tests are included for: opening modal, cancel behavior, and confirm-triggered deletion for selected folder. As per coding guidelines, "Ensure that test code is automated, comprehensive, and follows testing best practices" and "Verify that all critical functionality is covered by tests". 🤖 Prompt for AI Agents |
||
| </SettingsCard> | ||
| ); | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the
RootStateimport path to prevent a build break.Line 8 imports
RootStatefrom@/store/store, but the store type is exported fromfrontend/src/app/store.ts. This path mismatch will fail type-check/compile.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents