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

Merge branch 'feat/add-compare-method-for-deletion-config' into feat/90959

Shun Miyazawa 4 лет назад
Родитель
Сommit
38ebe0ae1e

+ 5 - 5
packages/app/src/server/service/page.ts

@@ -27,7 +27,7 @@ import {
 } from '~/interfaces/page-delete-config';
 import PageOperation, { PageActionStage, PageActionType } from '../models/page-operation';
 import ActivityDefine from '../util/activityDefine';
-import { calcRecursiveDeleteConfigValue } from '~/utils/page-delete-config';
+import { prepareDeleteConfigValuesForCalc } from '~/utils/page-delete-config';
 
 const debug = require('debug')('growi:services:page');
 
@@ -216,18 +216,18 @@ class PageService {
     const pageCompleteDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageCompleteDeletionAuthority');
     const pageRecursiveCompleteDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageRecursiveCompleteDeletionAuthority');
 
-    const recursiveAuthority = calcRecursiveDeleteConfigValue(pageCompleteDeletionAuthority, pageRecursiveCompleteDeletionAuthority);
+    const [singleAuthority, recursiveAuthority] = prepareDeleteConfigValuesForCalc(pageCompleteDeletionAuthority, pageRecursiveCompleteDeletionAuthority);
 
-    return this.canDeleteLogic(creatorId, operator, isRecursively, pageCompleteDeletionAuthority, recursiveAuthority);
+    return this.canDeleteLogic(creatorId, operator, isRecursively, singleAuthority, recursiveAuthority);
   }
 
   canDelete(creatorId: ObjectIdLike, operator, isRecursively: boolean): boolean {
     const pageDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageDeletionAuthority');
     const pageRecursiveDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageRecursiveDeletionAuthority');
 
-    const recursiveAuthority = calcRecursiveDeleteConfigValue(pageDeletionAuthority, pageRecursiveDeletionAuthority);
+    const [singleAuthority, recursiveAuthority] = prepareDeleteConfigValuesForCalc(pageDeletionAuthority, pageRecursiveDeletionAuthority);
 
-    return this.canDeleteLogic(creatorId, operator, isRecursively, pageDeletionAuthority, recursiveAuthority);
+    return this.canDeleteLogic(creatorId, operator, isRecursively, singleAuthority, recursiveAuthority);
   }
 
   private canDeleteLogic(

+ 5 - 5
packages/app/src/utils/page-delete-config.ts

@@ -49,14 +49,14 @@ export const validateDeleteConfigs = (
  * Convert IPageDeleteConfigValue.Inherit to the calculable value
  * @param confForSingle IPageDeleteConfigValueToProcessValidation
  * @param confForRecursive IPageDeleteConfigValue
- * @returns IPageDeleteConfigValueToProcessValidation
+ * @returns [(value for single), (value for recursive)]
  */
-export const calcRecursiveDeleteConfigValue = (
+export const prepareDeleteConfigValuesForCalc = (
     confForSingle: IPageDeleteConfigValueToProcessValidation, confForRecursive: IPageDeleteConfigValue,
-): IPageDeleteConfigValueToProcessValidation => {
+): [IPageDeleteConfigValueToProcessValidation, IPageDeleteConfigValueToProcessValidation] => {
   if (confForRecursive === Value.Inherit) {
-    return confForSingle;
+    return [confForSingle, confForSingle];
   }
 
-  return confForRecursive;
+  return [confForSingle, confForRecursive];
 };