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

Revert "update page operation type"

This reverts commit 63eaf4f2639f0396b749a54a123741cc4d775a5b.
ryoji-s 2 лет назад
Родитель
Сommit
c5c495d8bc

+ 1 - 9
apps/app/src/client/services/page-operation.ts

@@ -88,15 +88,7 @@ export const resumeRenameOperation = async(pageId: string): Promise<void> => {
 };
 
 // TODO: define return type
-export const createPage = async(
-    pagePath: string,
-    markdown: string,
-    tmpParams: OptionsToSave,
-): Promise<{
-  page: any,
-  tags: any,
-  revision: any
-}> => {
+export const createPage = async(pagePath: string, markdown: string, tmpParams: OptionsToSave) => {
   // clone
   const params = Object.assign(tmpParams, {
     path: pagePath,

+ 4 - 24
apps/app/src/server/routes/apiv3/pages.js

@@ -176,7 +176,6 @@ module.exports = (crowi) => {
       body('slackChannels').if(value => value != null).isString().withMessage('slackChannels must be string'),
       body('pageTags').if(value => value != null).isArray().withMessage('pageTags must be array'),
       body('shouldGeneratePath').optional().isBoolean().withMessage('shouldGeneratePath is must be boolean or undefined'),
-      body('shouldReturnIfPathExists').optional().isBoolean().withMessage('shouldReturnIfPathExists is must be boolean or undefined'),
     ],
     renamePage: [
       body('pageId').isMongoId().withMessage('pageId is required'),
@@ -240,15 +239,11 @@ module.exports = (crowi) => {
     return [];
   }
 
-  async function checkIsPathExists(path) {
-    const Page = mongoose.model('Page');
-    const response = await Page.findByPath(path);
-    return response != null;
-  }
-
   async function generateUniquePath(basePath, index = 1) {
+    const Page = mongoose.model('Page');
     const path = basePath + index;
-    const isPathExists = await checkIsPathExists(path);
+    const response = await Page.findByPath(path);
+    const isPathExists = response != null;
     if (isPathExists) {
       return generateUniquePath(basePath, index + 1);
     }
@@ -286,9 +281,6 @@ module.exports = (crowi) => {
    *                  shouldGeneratePath:
    *                    type: boolean
    *                    description: Determine whether a new path should be generated
-   *                  shouldReturnIfPathExists:
-   *                    type: boolean
-   *                    description: Determine whether a should return response if path exists
    *                required:
    *                  - body
    *                  - path
@@ -315,7 +307,7 @@ module.exports = (crowi) => {
    */
   router.post('/', accessTokenParser, loginRequiredStrictly, excludeReadOnlyUser, addActivity, validator.createPage, apiV3FormValidator, async(req, res) => {
     const {
-      body, grant, grantUserGroupId, overwriteScopesOfDescendants, isSlackEnabled, slackChannels, pageTags, shouldGeneratePath, shouldReturnIfPathExists,
+      body, grant, grantUserGroupId, overwriteScopesOfDescendants, isSlackEnabled, slackChannels, pageTags, shouldGeneratePath,
     } = req.body;
 
     let { path } = req.body;
@@ -323,18 +315,6 @@ module.exports = (crowi) => {
     // check whether path starts slash
     path = addHeadingSlash(path);
 
-    if (shouldReturnIfPathExists) {
-      try {
-        const isPathExists = await checkIsPathExists(path);
-        if (isPathExists) {
-          return res.apiv3({}, 200);
-        }
-      }
-      catch (err) {
-        return res.apiv3Err(err);
-      }
-    }
-
     if (shouldGeneratePath) {
       try {
         const rootPath = '/';