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

Merge branch 'master' into imprv/refactor-installer

# Conflicts:
#	src/server/util/middlewares.js
Yuki Takei 6 лет назад
Родитель
Сommit
2abe881ba3

+ 1 - 0
CHANGES.md

@@ -9,6 +9,7 @@
 ### Updates
 
 * Feature: Comment Thread
+* Feature: OpenID Connect authentication
 * Improvement Draft list
 * Fix: Deleting page completely
 * I18n: User Management Details

+ 2 - 8
src/client/js/components/PageComments.jsx

@@ -74,12 +74,6 @@ class PageComments extends React.Component {
 
   deleteComment() {
     const comment = this.state.commentToDelete;
-    const comments = this.props.commentContainer.state.comments;
-    comments.forEach((reply) => {
-      if (reply.replyTo === comment._id) {
-        this.props.commentContainer.deleteComment(reply);
-      }
-    });
 
     this.props.commentContainer.deleteComment(comment)
       .then(() => {
@@ -161,10 +155,10 @@ class PageComments extends React.Component {
                       <div className="col-xs-offset-6 col-sm-offset-6 col-md-offset-6 col-lg-offset-6">
                         <Button
                           bsStyle="primary"
-                          className="fcbtn btn btn-sm btn-primary btn-outline btn-rounded btn-1b"
+                          className="fcbtn btn btn-outline btn-rounded btn-xxs"
                           onClick={() => { return this.replyButtonClickedHandler(commentId) }}
                         >
-                          <i className="icon-bubble"></i> Reply
+                          Reply <i className="fa fa-mail-reply"></i>
                         </Button>
                       </div>
                     )

+ 56 - 46
src/client/styles/scss/_comment.scss

@@ -1,46 +1,56 @@
-.main-container {
-  .page-comment-main {
-    // delete button
-    .page-comment-control {
-      position: absolute;
-      top: 0;
-      right: 0;
-      display: none; // default hidden
-    }
-  }
-
-  // modal
-  .page-comment-delete-modal .modal-content {
-    .modal-body {
-      .comment-body {
-        max-height: 13em;
-        // scrollable
-        overflow-y: auto;
-      }
-    }
-  }
-}
-
-.main-container {
-  .page-comments {
-    .page-comments-list-toggle-newer,
-    .page-comments-list-toggle-older {
-      display: block;
-      margin: 8px;
-      font-size: 0.9em;
-      text-align: center;
-    }
-
-    // older comments
-    .page-comments-list-older .page-comment {
-    }
-    // newer comments
-    .page-comments-list-newer .page-comment {
-      opacity: 0.7;
-
-      &:hover {
-        opacity: 1;
-      }
-    }
-  }
-}
+.main-container {
+  .page-comment-main {
+    // delete button
+    .page-comment-control {
+      position: absolute;
+      top: 0;
+      right: 0;
+      display: none; // default hidden
+    }
+  }
+
+  // modal
+  .page-comment-delete-modal .modal-content {
+    .modal-body {
+      .comment-body {
+        max-height: 13em;
+        // scrollable
+        overflow-y: auto;
+      }
+    }
+  }
+}
+
+.main-container {
+  .page-comments {
+    .page-comments-list-toggle-newer,
+    .page-comments-list-toggle-older {
+      display: block;
+      margin: 8px;
+      font-size: 0.9em;
+      text-align: center;
+    }
+
+    // older comments
+    .page-comments-list-older .page-comment {
+    }
+    // newer comments
+    .page-comments-list-newer .page-comment {
+      opacity: 0.7;
+
+      &:hover {
+        opacity: 1;
+      }
+    }
+  }
+}
+
+.btn-xxs {
+  display: inline-flex;
+  align-items: center;
+  justify-content: center;
+  width: 50px;
+  height: 10px;
+  font-size: 11px;
+  border-radius: 1px;
+}

+ 8 - 0
src/server/models/comment.js

@@ -78,6 +78,14 @@ module.exports = function(crowi) {
     }));
   };
 
+  commentSchema.methods.removeWithReplies = async function() {
+    const Comment = crowi.model('Comment');
+    return Comment.remove({
+      $or: (
+        [{ replyTo: this._id }, { _id: this._id }]),
+    });
+  };
+
   /**
    * post save hook
    */

+ 1 - 1
src/server/routes/comment.js

@@ -174,7 +174,7 @@ module.exports = function(crowi, app) {
         throw new Error('Current user is not accessible to this page.');
       }
 
-      await comment.remove();
+      await comment.removeWithReplies();
       await Page.updateCommentCount(comment.page);
     }
     catch (err) {

+ 4 - 0
src/server/util/middlewares.js

@@ -147,6 +147,10 @@ module.exports = (crowi, app) => {
         return pathUtils.removeTrailingSlash(string);
       });
 
+      swig.setFilter('addTrailingSlash', (string) => {
+        return pathUtils.addTrailingSlash(string);
+      });
+
       swig.setFilter('presentation', (string) => {
         // 手抜き
         return string

+ 2 - 1
src/server/views/modal/create_page.html

@@ -72,7 +72,8 @@
             // modify href
             const value = $(this).val();
             const pageName = (value === 'children') ? '_template' : '__template';
-            const link = '{{ page.path || path }}/' + pageName + '#edit-form';
+            const truePath = "{{ page.path || path | addTrailingSlash }}";
+            const link = truePath + pageName + '#edit-form';
             $('#link-to-template').attr('href', link);
           });
         </script>

+ 3 - 0
src/server/views/modal/delete.html

@@ -22,12 +22,15 @@
 
           <hr>
 
+          {% if page.grant != 2 %}
+          {{ page.grant }}
           <div class="checkbox checkbox-warning">
             <input name="recursively" id="cbDeleteRecursively" value="1" type="checkbox" checked>
             <label for="cbDeleteRecursively">{{ t('modal_delete.label.Delete recursively') }}</label>
             <p class="help-block"> {{ t('modal_delete.help.recursively', page.path) }}
             </p>
           </div>
+          {% endif %}
           {% if not page.isDeleted() %}
           <div class="checkbox checkbox-danger">
             <input name="completely" id="cbDeleteCompletely" value="1"  type="checkbox">