Skip to content

Commit

Permalink
prompt for new name on handleAddFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
chetbae committed Jul 7, 2023
1 parent 918fdf3 commit 2c9ceb3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Dashboard/DocumentSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 2c9ceb3

Please sign in to comment.