File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ const CollectionMenu = ({
4545 prefix : ( ) => < FolderPlus size = { 14 } /> ,
4646 name : 'Add Folder' ,
4747 onClick : ( ) => {
48- console . log ( collectionId , folderId ) ;
48+ // console.log(collectionId, folderId);
4949 if ( ! platformContext . app . user . isLoggedIn ( ) ) {
5050 return platformContext . app . modals . openSignIn ( ) ;
5151 }
@@ -64,6 +64,23 @@ const CollectionMenu = ({
6464 } ;
6565 }
6666 const isValid = Regex . FolderName . test ( val ) ;
67+
68+ const existingFolders = useExplorerStore . getState ( ) . explorer . folders ;
69+ const parentFolderId = folderId || collectionId ;
70+ // console.log(parentFolderId, "parentfolderid")
71+ const isDuplicateName = existingFolders . some (
72+ ( folder ) =>
73+ // console.log(`folder name ${folder.name} and folder parent id ${folder.__ref.collectionId}`),
74+
75+ folder . name === val && folder . __ref . collectionId === parentFolderId
76+ ) ;
77+
78+ if ( isDuplicateName ) {
79+ return {
80+ isValid : false ,
81+ message : 'A folder with the same name already exists in this location.' ,
82+ } ;
83+ }
6784 return {
6885 isValid,
6986 message :
You can’t perform that action at this time.
0 commit comments