Skip to content

Commit 6a4c28a

Browse files
committed
added check to restrict creation of files with same name inside same folder
1 parent 0ebe839 commit 6a4c28a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

platform/firecamp-platform/src/components/activity-bar/explorer/menus/CollectionMenu.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)