diff --git a/ui/client-app/src/components/FileSystemNavigator.js b/ui/client-app/src/components/FileSystemNavigator.js index 2266e35..7de06e2 100644 --- a/ui/client-app/src/components/FileSystemNavigator.js +++ b/ui/client-app/src/components/FileSystemNavigator.js @@ -13,6 +13,7 @@ const [selectedFile, setSelectedFile] = useState(null); // { path, content } const [isEditing, setIsEditing] = useState(false); const [newItemModal, setNewItemModal] = useState(null); // { parentPath, isDir } + const [deleteModal, setDeleteModal] = useState(null); // path const [operationLoading, setOperationLoading] = useState(false); const fetchLevel = useCallback(async (path) => { @@ -55,13 +56,21 @@ const handleCreateFinal = async (name) => { if (!name || !newItemModal) return; const { parentPath, isDir } = newItemModal; - const fullPath = parentPath === "." ? name : `${parentPath}/${name}`; + + // Ensure parentPath is correctly handled for the root + let fullPath; + if (parentPath === "." || parentPath === "" || !parentPath) { + fullPath = name; + } else { + fullPath = `${parentPath}/${name}`; + } + setOperationLoading(true); setError(null); try { await nodeFsTouch(nodeId, fullPath, "", isDir); setNewItemModal(null); - loadRoot(); // Refresh + setTimeout(loadRoot, 500); // Small delay to let gRPC propagate } catch (err) { setError(`Failed to create: ${err.message}`); } finally { @@ -69,13 +78,15 @@ } }; - const handleDelete = async (path) => { - if (!window.confirm(`Delete ${path}?`)) return; + const handleDeleteFinal = async () => { + if (!deleteModal) return; + const path = deleteModal; setOperationLoading(true); setError(null); try { await nodeFsRm(nodeId, path); - loadRoot(); // Refresh + setDeleteModal(null); + setTimeout(loadRoot, 500); } catch (err) { setError(`Failed to delete: ${err.message}`); } finally { @@ -142,8 +153,8 @@ > {!node.is_dir && ( )} {node.name} @@ -160,7 +171,7 @@ )} - @@ -288,6 +299,38 @@ )} + + {/* Delete Confirmation Modal */} + {deleteModal && ( +
+
+
+
+ +
+

Confirm Delete

+

+ Are you sure you want to delete {deleteModal}? This action cannot be undone. +

+
+ + +
+
+
+
+ )} ); };