Przeglądaj źródła

Update parent when used to be grant_restricted

Taichi Masuyama 4 lat temu
rodzic
commit
83b2fdb1ca
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      packages/app/src/server/models/page.ts

+ 7 - 1
packages/app/src/server/models/page.ts

@@ -1053,9 +1053,10 @@ export default (crowi: Crowi): any => {
       throw Error('Crowi is not set up');
     }
 
+    const isExRestricted = pageData.grant === GRANT_RESTRICTED;
     const isPageMigrated = pageData.parent != null;
     const isV5Compatible = crowi.configManager.getConfig('crowi', 'app:isV5Compatible');
-    if (!isV5Compatible || !isPageMigrated) {
+    if (!isExRestricted && (!isV5Compatible || !isPageMigrated)) {
       // v4 compatible process
       return this.updatePageV4(pageData, body, previousBody, user, options);
     }
@@ -1088,6 +1089,11 @@ export default (crowi: Crowi): any => {
       if (!isGrantNormalized) {
         throw Error('The selected grant or grantedGroup is not assignable to this page.');
       }
+
+      if (isExRestricted) {
+        const newParent = await this.getParentAndFillAncestors(newPageData.path, user);
+        newPageData.parent = newParent._id;
+      }
     }
 
     newPageData.applyScope(user, grant, grantUserGroupId);