Просмотр исходного кода

Merge pull request #4886 from weseek/fix/v5-migration-update-only-public

fix: V5 migration update only public & Rendering error when non-migrated pages found
Yuki Takei 4 лет назад
Родитель
Сommit
69793c3e8c

+ 7 - 1
packages/app/src/components/Sidebar/PageTree/ItemsTree.tsx

@@ -29,7 +29,12 @@ const generateInitialNodeAfterResponse = (ancestorsChildren: Record<string, Part
   const paths = Object.keys(ancestorsChildren);
 
   let currentNode = rootNode;
-  paths.forEach((path) => {
+  paths.every((path) => {
+    // stop rendering when non-migrated pages found
+    if (currentNode == null) {
+      return false;
+    }
+
     const childPages = ancestorsChildren[path];
     currentNode.children = ItemNode.generateNodesFromPages(childPages);
 
@@ -37,6 +42,7 @@ const generateInitialNodeAfterResponse = (ancestorsChildren: Record<string, Part
       return paths.includes(node.page.path as string);
     })[0];
     currentNode = nextNode;
+    return true;
   });
 
   return rootNode;

+ 10 - 5
packages/app/src/server/service/page.js

@@ -952,13 +952,18 @@ class PageService {
             parentPath = parentPath.replace(bracket, `\\${bracket}`);
           });
 
+          const filter = {
+            // regexr.com/6889f
+            // ex. /parent/any_child OR /any_level1
+            path: { $regex: new RegExp(`^${parentPath}(\\/[^/]+)\\/?$`, 'g') },
+          };
+          if (grant != null) {
+            filter.grant = grant;
+          }
+
           return {
             updateMany: {
-              filter: {
-                // regexr.com/6889f
-                // ex. /parent/any_child OR /any_level1
-                path: { $regex: new RegExp(`^${parentPath}(\\/[^/]+)\\/?$`, 'g') },
-              },
+              filter,
               update: {
                 parent: parentId,
               },