Răsfoiți Sursa

remove option

itizawa 5 ani în urmă
părinte
comite
05b2c7aeda
3 a modificat fișierele cu 6 adăugiri și 14 ștergeri
  1. 1 9
      src/server/models/page.js
  2. 1 1
      src/server/service/page.js
  3. 4 4
      src/test/models/page.test.js

+ 1 - 9
src/server/models/page.js

@@ -717,20 +717,12 @@ module.exports = function(crowi) {
    * find pages that is match with `path` and its descendants whitch user is able to manage
    */
   pageSchema.statics.findManageableListWithDescendants = async function(page, user, option = {}) {
-    const onlyDescendants = option.onlyDescendants || false;
-
     if (user == null) {
       return null;
     }
 
     const builder = new PageQueryBuilder(this.find());
-
-    if (onlyDescendants) {
-      builder.addConditionToListOnlyDescendants(page.path, option);
-    }
-    else {
-      builder.addConditionToListWithDescendants(page.path, option);
-    }
+    builder.addConditionToListWithDescendants(page.path, option);
     builder.addConditionToExcludeRedirect();
 
     // add grant conditions

+ 1 - 1
src/server/service/page.js

@@ -84,7 +84,7 @@ class PageService {
     const Revision = this.crowi.model('Revision');
     const newPagePathPrefix = newPagePath;
     const pathRegExp = new RegExp(`^${escapeStringRegexp(page.path)}`, 'i');
-    const pages = await Page.findManageableListWithDescendants(page, user, { onlyDescendants: true });
+    const pages = await Page.findManageableListWithDescendants(page, user);
     const revisions = await Revision.find({ path: pathRegExp });
 
     // Mapping to set to the body of the new revision

+ 4 - 4
src/test/models/page.test.js

@@ -333,7 +333,7 @@ describe('Page', () => {
   describe('PageQueryBuilder.addConditionToListWithDescendants', () => {
     test('can retrieve descendants of /page', async() => {
       const builder = new PageQueryBuilder(Page.find());
-      builder.addConditionToListWithDescendants('/page', {});
+      builder.addConditionToListWithDescendants('/page');
 
       const result = await builder.query.exec();
 
@@ -346,7 +346,7 @@ describe('Page', () => {
 
     test('can retrieve descendants of /page1', async() => {
       const builder = new PageQueryBuilder(Page.find());
-      builder.addConditionToListWithDescendants('/page1/', {});
+      builder.addConditionToListWithDescendants('/page1/');
 
       const result = await builder.query.exec();
 
@@ -362,7 +362,7 @@ describe('Page', () => {
   describe('PageQueryBuilder.addConditionToListOnlyDescendants', () => {
     test('can retrieve only descendants of /page', async() => {
       const builder = new PageQueryBuilder(Page.find());
-      builder.addConditionToListOnlyDescendants('/page', {});
+      builder.addConditionToListOnlyDescendants('/page');
 
       const result = await builder.query.exec();
 
@@ -375,7 +375,7 @@ describe('Page', () => {
 
     test('can retrieve only descendants of /page1', async() => {
       const builder = new PageQueryBuilder(Page.find());
-      builder.addConditionToListOnlyDescendants('/page1', {});
+      builder.addConditionToListOnlyDescendants('/page1');
 
       const result = await builder.query.exec();