mirror of
https://github.com/outline/outline.git
synced 2026-11-30 17:10:36 +03:00
Merge branch 'outline:main' into main
This commit is contained in:
4 files changed
+8
-83
No files matched your search
@@ -3,7 +3,7 @@ Business Source License 1.1
|
||||
Parameters
|
||||
|
||||
Licensor: General Outline, Inc.
|
||||
Licensed Work: Outline 0.60.1
|
||||
Licensed Work: Outline 0.62.0
|
||||
The Licensed Work is (c) 2020 General Outline, Inc.
|
||||
Additional Use Grant: You may make use of the Licensed Work, provided that
|
||||
you may not use the Licensed Work for a Document
|
||||
@@ -15,7 +15,7 @@ Additional Use Grant: You may make use of the Licensed Work, provided that
|
||||
Licensed Work by creating teams and documents
|
||||
controlled by such third parties.
|
||||
|
||||
Change Date: 2025-11-11
|
||||
Change Date: 2026-03-01
|
||||
|
||||
Change License: Apache License, Version 2.0
|
||||
|
||||
|
||||
@@ -85,56 +85,6 @@ describe("getDocumentTree", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isChildDocument", () => {
|
||||
test("should return false with unexpected data", async () => {
|
||||
const document = await buildDocument();
|
||||
const collection = await buildCollection({
|
||||
documentStructure: [document.toJSON()],
|
||||
});
|
||||
expect(collection.isChildDocument(document.id, document.id)).toEqual(false);
|
||||
expect(collection.isChildDocument(document.id, undefined)).toEqual(false);
|
||||
expect(collection.isChildDocument(undefined, document.id)).toEqual(false);
|
||||
});
|
||||
|
||||
test("should return false if sibling", async () => {
|
||||
const one = await buildDocument();
|
||||
const document = await buildDocument();
|
||||
const collection = await buildCollection({
|
||||
documentStructure: [one.toJSON(), document.toJSON()],
|
||||
});
|
||||
expect(collection.isChildDocument(one.id, document.id)).toEqual(false);
|
||||
expect(collection.isChildDocument(document.id, one.id)).toEqual(false);
|
||||
});
|
||||
|
||||
test("should return true if direct child of parent", async () => {
|
||||
const parent = await buildDocument();
|
||||
const document = await buildDocument();
|
||||
const collection = await buildCollection({
|
||||
documentStructure: [
|
||||
{ ...parent.toJSON(), children: [document.toJSON()] },
|
||||
],
|
||||
});
|
||||
expect(collection.isChildDocument(parent.id, document.id)).toEqual(true);
|
||||
expect(collection.isChildDocument(document.id, parent.id)).toEqual(false);
|
||||
});
|
||||
|
||||
test("should return true if nested child of parent", async () => {
|
||||
const parent = await buildDocument();
|
||||
const nested = await buildDocument();
|
||||
const document = await buildDocument();
|
||||
const collection = await buildCollection({
|
||||
documentStructure: [
|
||||
{
|
||||
...parent.toJSON(),
|
||||
children: [{ ...nested.toJSON(), children: [document.toJSON()] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(collection.isChildDocument(parent.id, document.id)).toEqual(true);
|
||||
expect(collection.isChildDocument(document.id, parent.id)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#addDocumentToStructure", () => {
|
||||
test("should add as last element without index", async () => {
|
||||
const { collection } = await seed();
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -542,10 +542,12 @@ async function loadDocument({
|
||||
// shared then includeChildDocuments must be enabled and the document must
|
||||
// still be nested within the shared document
|
||||
if (share.document.id !== document.id) {
|
||||
if (
|
||||
!share.includeChildDocuments ||
|
||||
!collection.isChildDocument(share.document.id, document.id)
|
||||
) {
|
||||
if (!share.includeChildDocuments) {
|
||||
throw AuthorizationError();
|
||||
}
|
||||
|
||||
const childDocumentIds = await share.document.getChildDocumentIds();
|
||||
if (!childDocumentIds.includes(document.id)) {
|
||||
throw AuthorizationError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user