chore: change the way that share permissions are checked on child documents to use the parentId field of documents rather than the collection structure (#3294)

This commit is contained in:
Nan Yu
2022-03-28 10:18:59 -07:00
committed by GitHub
parent 3d478246bf
commit 096b35e08e
3 changed files with 6 additions and 81 deletions

View File

@@ -506,33 +506,6 @@ class Collection extends ParanoidModel {
return result;
};
isChildDocument = function (
parentDocumentId?: string,
documentId?: string
): boolean {
let result = false;
const loopChildren = (documents: NavigationNode[], input: string[]) => {
if (result) {
return;
}
documents.forEach((document) => {
const parents = [...input];
if (document.id === documentId && parentDocumentId) {
result = parents.includes(parentDocumentId);
} else {
parents.push(document.id);
loopChildren(document.children, parents);
}
});
};
loopChildren(this.documentStructure, []);
return result;
};
/**
* Update document's title and url in the documentStructure
*/