Преглед изворни кода

Merge branch 'feat/multiple-group-grant-for-page' into feat/136137-136541-page-tree-grant-update-for-multi-group-grant

Futa Arai пре 2 година
родитељ
комит
a730648ecf
2 измењених фајлова са 22 додато и 4 уклоњено
  1. 20 2
      apps/app/src/server/service/page-grant.ts
  2. 2 2
      apps/app/src/server/service/page.ts

+ 20 - 2
apps/app/src/server/service/page-grant.ts

@@ -77,7 +77,26 @@ type OperatorGrantInfo = {
   userGroupIds: Set<ObjectIdLike>,
 };
 
-class PageGrantService {
+export interface IPageGrantService {
+  isGrantNormalized: (
+    user,
+    targetPath: string,
+    grant?: PageGrant,
+    grantedUserIds?: ObjectIdLike[],
+    grantedGroupIds?: IGrantedGroup[],
+    shouldCheckDescendants?: boolean,
+    includeNotMigratedPages?: boolean,
+    previousGrantedGroupIds?: IGrantedGroup[]
+  ) => Promise<boolean>,
+  separateNormalizableAndNotNormalizablePages: (user, pages) => Promise<[(PageDocument & { _id: any })[], (PageDocument & { _id: any })[]]>,
+  generateUpdateGrantInfoToOverwriteDescendants: (
+    operator, updateGrant?: PageGrant, grantGroupIds?: IGrantedGroup[],
+  ) => Promise<UpdateGrantInfo>,
+  canOverwriteDescendants: (targetPath: string, operator: { _id: ObjectIdLike }, updateGrantInfo: UpdateGrantInfo) => Promise<boolean>,
+  validateGrantChange: (user, previousGrantedGroupIds: IGrantedGroup[], grant?: PageGrant, grantedGroupIds?: IGrantedGroup[]) => Promise<boolean>
+}
+
+class PageGrantService implements IPageGrantService {
 
   crowi!: any;
 
@@ -460,7 +479,6 @@ class PageGrantService {
    * @returns Promise<boolean>
    */
   async isGrantNormalized(
-      // eslint-disable-next-line max-len
       user,
       targetPath: string,
       grant?: PageGrant,

+ 2 - 2
apps/app/src/server/service/page.ts

@@ -51,7 +51,7 @@ import { V5ConversionError } from '../models/vo/v5-conversion-error';
 import { divideByType } from '../util/granted-group';
 
 import { configManager } from './config-manager';
-import PageGrantService from './page-grant';
+import { IPageGrantService } from './page-grant';
 import { preNotifyService } from './pre-notify';
 
 const debug = require('debug')('growi:services:page');
@@ -158,7 +158,7 @@ class PageService {
 
   activityEvent: any;
 
-  pageGrantService: PageGrantService;
+  pageGrantService: IPageGrantService;
 
   constructor(crowi) {
     this.crowi = crowi;