From 6a4c28a79d4a4c70f9bfaeea1affb754b49f279b Mon Sep 17 00:00:00 2001 From: Nikhil Kadam Date: Fri, 3 Nov 2023 13:54:18 +0530 Subject: [PATCH 1/2] added check to restrict creation of files with same name inside same folder --- .../explorer/menus/CollectionMenu.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx b/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx index 7a70a8c15..001e624dd 100644 --- a/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx +++ b/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx @@ -45,7 +45,7 @@ const CollectionMenu = ({ prefix: () => , name: 'Add Folder', onClick: () => { - console.log(collectionId, folderId); + // console.log(collectionId, folderId); if (!platformContext.app.user.isLoggedIn()) { return platformContext.app.modals.openSignIn(); } @@ -64,6 +64,23 @@ const CollectionMenu = ({ }; } const isValid = Regex.FolderName.test(val); + + const existingFolders = useExplorerStore.getState().explorer.folders; + const parentFolderId = folderId || collectionId; + // console.log(parentFolderId, "parentfolderid") + const isDuplicateName = existingFolders.some( + (folder) => + // console.log(`folder name ${folder.name} and folder parent id ${folder.__ref.collectionId}`), + + folder.name === val && folder.__ref.collectionId === parentFolderId + ); + + if (isDuplicateName) { + return { + isValid: false, + message: 'A folder with the same name already exists in this location.', + }; + } return { isValid, message: From e0d69341d69fae5fb67253ebfd331f683005289a Mon Sep 17 00:00:00 2001 From: Nikhil Kadam Date: Fri, 3 Nov 2023 13:56:41 +0530 Subject: [PATCH 2/2] added check to restrict creation of files with same name inside same folder --- .../explorer/menus/CollectionMenu.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx b/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx index 001e624dd..f2050eba8 100644 --- a/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx +++ b/platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx @@ -67,20 +67,17 @@ const CollectionMenu = ({ const existingFolders = useExplorerStore.getState().explorer.folders; const parentFolderId = folderId || collectionId; - // console.log(parentFolderId, "parentfolderid") const isDuplicateName = existingFolders.some( - (folder) => - // console.log(`folder name ${folder.name} and folder parent id ${folder.__ref.collectionId}`), - + (folder) => folder.name === val && folder.__ref.collectionId === parentFolderId - ); + ); - if (isDuplicateName) { - return { - isValid: false, - message: 'A folder with the same name already exists in this location.', - }; - } + if (isDuplicateName) { + return { + isValid: false, + message: 'A folder with the same name already exists in this location.', + }; + } return { isValid, message: