Kaynağa Gözat

Improved utility

Taichi Masuyama 4 yıl önce
ebeveyn
işleme
8050742662

+ 3 - 3
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,7 +216,7 @@ 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 recursiveAuthority = prepareDeleteConfigValuesForCalc(pageCompleteDeletionAuthority, pageRecursiveCompleteDeletionAuthority);
 
     return this.canDeleteLogic(creatorId, operator, isRecursively, pageCompleteDeletionAuthority, recursiveAuthority);
   }
@@ -225,7 +225,7 @@ class PageService {
     const pageDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageDeletionAuthority');
     const pageRecursiveDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageRecursiveDeletionAuthority');
 
-    const recursiveAuthority = calcRecursiveDeleteConfigValue(pageDeletionAuthority, pageRecursiveDeletionAuthority);
+    const recursiveAuthority = prepareDeleteConfigValuesForCalc(pageDeletionAuthority, pageRecursiveDeletionAuthority);
 
     return this.canDeleteLogic(creatorId, operator, isRecursively, pageDeletionAuthority, recursiveAuthority);
   }

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

@@ -51,12 +51,12 @@ export const validateDeleteConfigs = (
  * @param confForRecursive IPageDeleteConfigValue
  * @returns IPageDeleteConfigValueToProcessValidation
  */
-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];
 };