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

Merge pull request #437 from weseek/master

release v3.1.1
Yuki Takei 7 лет назад
Родитель
Сommit
83ef89e66c

+ 8 - 2
CHANGES.md

@@ -1,11 +1,17 @@
 CHANGES
 ========
 
-## 3.1.0-RC
+## 3.1.1-RC
+
+* Improvement: Add 'future' theme
+* Improvement: List up pages which restricted for Group ACL
+* Fix: PageGroupRelation didn't remove when page is removed completely
+
+
+## 3.1.0
 
 * Improvement: Group Access Control List - Select group modal
 * Improvement: Better input on mobile
-* Improvement: Add 'future' theme
 * Improvement: Detach code blocks correctly
 * Improvement: Auto-format markdown table which includes multibyte text
 * Improvement: Show icon when auto-format markdown table is activated

+ 1 - 1
config/logger/config.prod.js

@@ -1,3 +1,3 @@
 module.exports = {
-  default: 'info',
+  default: 'warn',
 };

+ 1 - 0
config/webpack.common.js

@@ -31,6 +31,7 @@ module.exports = function(options) {
       'style-theme-nature':   './resource/styles/scss/theme/nature.scss',
       'style-theme-mono-blue':   './resource/styles/scss/theme/mono-blue.scss',
       'style-theme-future': './resource/styles/scss/theme/future.scss',
+      'style-theme-blue-night': './resource/styles/scss/theme/blue-night.scss',
       'style-presentation':   './resource/styles/scss/style-presentation.scss',
     },
     externals: {

+ 46 - 67
lib/models/page.js

@@ -767,6 +767,7 @@ module.exports = function(crowi) {
         {grant: GRANT_RESTRICTED, grantedUsers: userData._id},
         {grant: GRANT_SPECIFIED, grantedUsers: userData._id},
         {grant: GRANT_OWNER, grantedUsers: userData._id},
+        {grant: GRANT_USER_GROUP},
       ], })
       .and({
         $or: pathCondition
@@ -917,10 +918,10 @@ module.exports = function(crowi) {
       grant = GRANT_PUBLIC;
     }
 
-    return new Promise(function(resolve, reject) {
-      Page.findOne({path: path}, function(err, pageData) {
+    return Page.findOne({path: path})
+      .then(pageData => {
         if (pageData) {
-          return reject(new Error('Cannot create new page to existed path'));
+          throw new Error('Cannot create new page to existed path');
         }
 
         var newPage = new Page();
@@ -935,28 +936,18 @@ module.exports = function(crowi) {
         newPage.grantedUsers = [];
         newPage.grantedUsers.push(user);
 
-        newPage.save(function(err, newPage) {
-          if (err) {
-            return reject(err);
-          }
-
-          if (newPage.grant == Page.GRANT_USER_GROUP && grantUserGroupId != null) {
-            Page.updateGrantUserGroup(newPage, grant, grantUserGroupId, user)
-              .catch((err) => {
-                return reject(err);
-              });
-          }
-          var newRevision = Revision.prepareRevision(newPage, body, user, {format: format});
-          Page.pushRevision(newPage, newRevision, user).then(function(data) {
-            resolve(data);
-            pageEvent.emit('create', data, user);
-          }).catch(function(err) {
-            debug('Push Revision Error on create page', err);
-            return reject(err);
+        return newPage.save();
+      })
+      .then((newPage) => {
+        const newRevision = Revision.prepareRevision(newPage, body, user, {format: format});
+        return Page.pushRevision(newPage, newRevision, user)
+          .then(() => {
+            return Page.updateGrantUserGroup(newPage, grant, grantUserGroupId, user);
           });
-        });
+      })
+      .then((data) => {
+        pageEvent.emit('create', data, user);
       });
-    });
   };
 
   pageSchema.statics.updatePage = function(pageData, body, user, options) {
@@ -984,20 +975,13 @@ module.exports = function(crowi) {
       , newPath = Page.getDeletedPageName(pageData.path)
       ;
     if (Page.isDeletableName(pageData.path)) {
-      return new Promise(function(resolve, reject) {
-        Page.updatePageProperty(pageData, {status: STATUS_DELETED, lastUpdateUser: user})
-        .then(function(data) {
-          pageData.status = STATUS_DELETED;
-
-          // ページ名が /trash/ 以下に存在する場合、おかしなことになる
-          // が、 /trash 以下にページが有るのは、個別に作っていたケースのみ。
-          // 一応しばらく前から uncreatable pages になっているのでこれでいいことにする
-          debug('Deleted the page, and rename it', pageData.path, newPath);
-          return Page.rename(pageData, newPath, user, {createRedirectPage: true});
-        }).then(function(pageData) {
-          resolve(pageData);
-        }).catch(reject);
-      });
+      return Page.rename(pageData, newPath, user, {createRedirectPage: true})
+        .then((updatedPageData) => {
+          return Page.updatePageProperty(updatedPageData, {status: STATUS_DELETED, lastUpdateUser: user});
+        })
+        .then(() => {
+          return pageData;
+        });
     }
     else {
       return Promise.reject('Page is not deletable.');
@@ -1010,18 +994,15 @@ module.exports = function(crowi) {
       , options = options || {}
       ;
 
-    return new Promise(function(resolve, reject) {
-      Page
-      .generateQueryToListWithDescendants(path, user, options)
+    return Page.generateQueryToListWithDescendants(path, user, options)
       .then(function(pages) {
-        Promise.all(pages.map(function(page) {
+        return Promise.all(pages.map(function(page) {
           return Page.deletePage(page, user, options);
-        }))
-        .then(function(data) {
-          return resolve(pageData);
-        });
+        }));
+      })
+      .then(function(data) {
+        return pageData;
       });
-    });
 
   };
 
@@ -1064,6 +1045,7 @@ module.exports = function(crowi) {
     return new Promise(function(resolve, reject) {
       Page
         .generateQueryToListWithDescendants(path, user, options)
+        .exec()
         .then(function(pages) {
           Promise.all(pages.map(function(page) {
             return Page.revertDeletedPage(page, user, options);
@@ -1084,6 +1066,7 @@ module.exports = function(crowi) {
       , Attachment = crowi.model('Attachment')
       , Comment = crowi.model('Comment')
       , Revision = crowi.model('Revision')
+      , PageGroupRelation = crowi.model('PageGroupRelation')
       , Page = this
       , pageId = pageData._id
       ;
@@ -1103,6 +1086,8 @@ module.exports = function(crowi) {
         return Page.removePageById(pageId);
       }).then(function(done) {
         return Page.removeRedirectOriginPageByPath(pageData.path);
+      }).then(function(done) {
+        return PageGroupRelation.removeAllByPage(pageData);
       }).then(function(done) {
         pageEvent.emit('delete', pageData, user); // update as renamed page
         resolve(pageData);
@@ -1190,25 +1175,22 @@ module.exports = function(crowi) {
       , createRedirectPage = options.createRedirectPage || 0
       , moveUnderTrees     = options.moveUnderTrees || 0;
 
-    return new Promise(function(resolve, reject) {
-      // pageData の path を変更
-      Page.updatePageProperty(pageData, {updatedAt: Date.now(), path: newPagePath, lastUpdateUser: user})
-      .then(function(data) {
+    return Page.updatePageProperty(pageData, {updatedAt: Date.now(), path: newPagePath, lastUpdateUser: user})  // pageData の path を変更
+      .then((data) => {
         // reivisions の path を変更
         return Revision.updateRevisionListByPath(path, {path: newPagePath}, {});
-      }).then(function(data) {
+      })
+      .then(function(data) {
         pageData.path = newPagePath;
 
         if (createRedirectPage) {
           var body = 'redirect ' + newPagePath;
-          Page.create(path, body, user, {redirectTo: newPagePath}).then(resolve).catch(reject);
-        }
-        else {
-          resolve(data);
+          Page.create(path, body, user, {redirectTo: newPagePath});
         }
         pageEvent.emit('update', pageData, user); // update as renamed page
+
+        return pageData;
       });
-    });
   };
 
   pageSchema.statics.renameRecursively = function(pageData, newPagePathPrefix, user, options) {
@@ -1216,20 +1198,17 @@ module.exports = function(crowi) {
       , path = pageData.path
       , pathRegExp = new RegExp('^' + escapeStringRegexp(path), 'i');
 
-    return new Promise(function(resolve, reject) {
-      Page
-      .generateQueryToListWithDescendants(path, user, options)
+    return Page.generateQueryToListWithDescendants(path, user, options)
       .then(function(pages) {
-        Promise.all(pages.map(function(page) {
-          newPagePath = page.path.replace(pathRegExp, newPagePathPrefix);
+        return Promise.all(pages.map(function(page) {
+          const newPagePath = page.path.replace(pathRegExp, newPagePathPrefix);
           return Page.rename(page, newPagePath, user, options);
-        }))
-        .then(function() {
-          pageData.path = newPagePathPrefix;
-          return resolve();
-        });
+        }));
+      })
+      .then(function() {
+        pageData.path = newPagePathPrefix;
+        return pageData;
       });
-    });
   };
 
   pageSchema.statics.getHistories = function() {

+ 2 - 1
lib/views/admin/customize.html

@@ -73,7 +73,8 @@
             {# Dark Themes #}
             <div class="d-flex">
               {% include 'widget/theme-colorbox.html' with { name: 'default-dark', bg: '#212731', topbar: '#151515', theme: '#f75b36' } %}
-              {% include 'widget/theme-colorbox.html' with { name: 'future', bg: '#16282D', topbar: '#011414', theme: '#04B4AE' } %}
+              {# {% include 'widget/theme-colorbox.html' with { name: 'future', bg: '#16282D', topbar: '#011414', theme: '#04B4AE' } %} #}
+              {% include 'widget/theme-colorbox.html' with { name: 'blue-night', bg: '#061F2F', topbar: '#27343B', theme: '#0090C8' } %}
             </div>
           </div>
 

+ 1 - 0
lib/views/admin/widget/theme-colorbox.html

@@ -4,6 +4,7 @@
     data-theme="{{ webpack_asset('style-theme-' + name).css }}">
 
   <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
+    <title>{{name}}</title>
     <g>
       <path d="M -1 -1 L65 -1 L65 65 L-1 65 L-1 -1 Z" fill="{{bg}}"></path>
       <path d="M -1 -1 L65 -1 L65 15 L-1 15 L-1 -1 Z" fill="{{topbar}}"></path>

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "growi",
-  "version": "3.1.0-RC2",
+  "version": "3.1.1-RC",
   "description": "Team collaboration software using markdown",
   "tags": [
     "wiki",

+ 54 - 0
resource/styles/agile-admin/inverse/colors/blue-night.scss

@@ -0,0 +1,54 @@
+@import '../variables';
+
+$basecolor:#061f2f;
+$themecolor:#0090c8;
+
+$linkcolor: #97d1f0;
+
+$topbar:#27343b;
+$sidebar:#061f2f;
+$bodycolor:#061f2f;
+$headingtext: #fff;
+$bodytext: #d3d4d4;
+$linktext: $linkcolor;
+$linktext-hover: rgba($linktext, 0.8);
+$sidebar-text:#d3d4d4;
+$dark-themecolor:#4f5467;
+
+$primary: $themecolor;
+
+$logo-mark-fill: lighten(desaturate($topbar, 10%), 15%);
+$wikilinktext: $linkcolor;
+$wikilinktext-hover: rgba($linktext, 0.8);
+
+$dark: darken($bodytext, 5%);
+$border: #fff;
+$navbar-border: lighten($basecolor, 25%);
+$active-navbar-border: darken($navbar-border, 3%);
+$btn-default-bgcolor: darken($basecolor, 10%);
+$inline-code-color: #c1f1f0;
+$inline-code-bg: #0a121b;
+
+@import 'apply-colors';
+@import 'apply-colors-dark';
+
+.wiki {
+  .highlighted {
+   background-color: lighten($themecolor, 20%);
+  }
+}
+
+.panel {
+  &, &.panel-white, &.panel-default {
+    border-color: $bodytext;
+    .panel-heading {
+      color: $basecolor;
+      background-color: 1px solid $bodytext;
+    }
+  }
+}
+
+:not(.hljs) > pre:not(.hljs) {
+  color: $bodytext;
+  background-color: $inline-code-bg;
+}

+ 8 - 0
resource/styles/scss/theme/blue-night.scss

@@ -0,0 +1,8 @@
+// import colors
+@import '../../agile-admin/inverse/colors/blue-night';
+
+// apply agile-admin theme
+@import '../../agile-admin/inverse/style';
+
+// override
+@import 'override-agileadmin';