From 2c9ceb333dab208f5698d89f58f4fa794ac9d94c Mon Sep 17 00:00:00 2001 From: Max Zhang <48145854+chetbae@users.noreply.github.com> Date: Fri, 7 Jul 2023 15:37:39 -0400 Subject: [PATCH] prompt for new name on handleAddFolder --- src/Dashboard/DocumentSelector.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Dashboard/DocumentSelector.ts b/src/Dashboard/DocumentSelector.ts index bbbceeec..21d0034d 100644 --- a/src/Dashboard/DocumentSelector.ts +++ b/src/Dashboard/DocumentSelector.ts @@ -32,7 +32,7 @@ let shiftKeyIsPressed = false; openButton!.addEventListener('click', handleOpenDocuments); deleteButton!.addEventListener('click', handleDeleteDocuments); uploadDocumentsButton!.addEventListener('click', handleUploadDocuments); -newFolderButton!.addEventListener('click', handleCreateFolder) +newFolderButton!.addEventListener('click', handleAddFolder) function handleUploadDocuments() { const isImmutable = currentPath.at(-1).metadata['immutable']; @@ -348,7 +348,7 @@ function updateNavPath(currentPath: IFolder[]): void { }); } -function handleCreateFolder() { +function handleAddFolder() { // abort if parent folder const isImmutable = currentPath.at(-1).metadata['immutable']; if (isImmutable) { @@ -357,9 +357,16 @@ function handleCreateFolder() { return false; } - const folder = fs_functions.createFolder('new file'); - fs_functions.addEntry(folder, currentPath.at(-1)); - updateDocumentSelector(); + const folderName = promptNewName(); + if (folderName) { + const folder = fs_functions.createFolder(folderName); + const succeeded = fs_functions.addEntry(folder, currentPath.at(-1)); + if (succeeded) { + updateDocumentSelector(); + return true; + } + } + return false; } // opens prompt to rename entry in file system, persist in local storage, and updates tile name