mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
be51810be5
React File Tree - Validate new folder names and renames GitOrigin-RevId: f040eb08e2daefb3dfd639e18aaef95d7123d727
13 lines
436 B
JavaScript
13 lines
436 B
JavaScript
import { findInTree } from '../util/find-in-tree'
|
|
|
|
export function isNameUniqueInFolder(tree, parentFolderId, name) {
|
|
if (tree._id !== parentFolderId) {
|
|
tree = findInTree(tree, parentFolderId).entity
|
|
}
|
|
|
|
if (tree.docs.some(entity => entity.name === name)) return false
|
|
if (tree.fileRefs.some(entity => entity.name === name)) return false
|
|
if (tree.folders.some(entity => entity.name === name)) return false
|
|
|
|
return true
|
|
}
|