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 = ({
45
45
prefix : ( ) => < FolderPlus size = { 14 } /> ,
46
46
name : 'Add Folder' ,
47
47
onClick : ( ) => {
48
- console . log ( collectionId , folderId ) ;
48
+ // console.log(collectionId, folderId);
49
49
if ( ! platformContext . app . user . isLoggedIn ( ) ) {
50
50
return platformContext . app . modals . openSignIn ( ) ;
51
51
}
@@ -64,6 +64,23 @@ const CollectionMenu = ({
64
64
} ;
65
65
}
66
66
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
+ }
67
84
return {
68
85
isValid,
69
86
message :
You can’t perform that action at this time.
0 commit comments