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

Merge pull request #9996 from weseek/support/remove-unnecessary-option-for-rename

support: Remove unnecessary option for rename API
mergify[bot] пре 10 месеци
родитељ
комит
2db1e3b2bf

+ 0 - 5
apps/app/src/server/routes/apiv3/pages/index.js

@@ -86,7 +86,6 @@ module.exports = (crowi) => {
       body('isRecursively').if(value => value != null).isBoolean().withMessage('isRecursively must be boolean'),
       body('isRenameRedirect').if(value => value != null).isBoolean().withMessage('isRenameRedirect must be boolean'),
       body('updateMetadata').if(value => value != null).isBoolean().withMessage('updateMetadata must be boolean'),
-      body('isMoveMode').if(value => value != null).isBoolean().withMessage('isMoveMode must be boolean'),
     ],
     resumeRenamePage: [
       body('pageId').isMongoId().withMessage('pageId is required'),
@@ -256,9 +255,6 @@ module.exports = (crowi) => {
    *                  isRecursively:
    *                    type: boolean
    *                    description: whether rename page with descendants
-   *                  isMoveMode:
-   *                    type: boolean
-   *                    description: whether rename page with moving
    *                required:
    *                  - pageId
    *                  - revisionId
@@ -285,7 +281,6 @@ module.exports = (crowi) => {
       isRecursively: req.body.isRecursively,
       createRedirectPage: req.body.isRenameRedirect,
       updateMetadata: req.body.updateMetadata,
-      isMoveMode: req.body.isMoveMode,
     };
 
     const activityParameters = {

+ 1 - 11
apps/app/src/server/service/page/index.ts

@@ -82,7 +82,7 @@ export * from './page-service';
 const logger = loggerFactory('growi:services:page');
 const {
   isTrashPage, isTopPage, omitDuplicateAreaPageFromPages, getUsernameByPath,
-  canMoveByPath, isUsersTopPage, isMovablePage, isUsersHomepage, hasSlash, generateChildrenRegExp,
+  isUsersTopPage, isMovablePage, isUsersHomepage, hasSlash, generateChildrenRegExp,
 } = pagePathUtils;
 
 const { addTrailingSlash } = pathUtils;
@@ -551,16 +551,6 @@ class PageService implements IPageService {
       return this.renamePageV4(page, newPagePath, user, options);
     }
 
-    if (options.isMoveMode) {
-      const fromPath = page.path;
-      const toPath = newPagePath;
-      const canMove = canMoveByPath(fromPath, toPath) && await Page.exists({ path: newPagePath });
-
-      if (!canMove) {
-        throw Error('Cannot move to this path.');
-      }
-    }
-
     const canOperate = await this.crowi.pageOperationService.canOperate(true, page.path, newPagePath);
     if (!canOperate) {
       throw Error(`Cannot operate rename to path "${newPagePath}" right now.`);