]> BookStack Code Mirror - bookstack/commitdiff
Comments: Added visual nesting limit, added nesting test
authorDan Brown <redacted>
Fri, 9 Jun 2023 10:12:39 +0000 (11:12 +0100)
committerDan Brown <redacted>
Fri, 9 Jun 2023 10:12:39 +0000 (11:12 +0100)
resources/sass/_components.scss
resources/views/pages/show.blade.php
tests/Entity/CommentTest.php

index a3818168f0f5218e032a236d7a76af8fe139ba8a..f75f8b8f8a958ad176fc537248e37c506583e0c7 100644 (file)
@@ -663,6 +663,12 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group {
   }
 }
 
+.comments-container {
+  padding-inline: $-xl;
+  @include smaller-than($m) {
+    padding-inline: $-xs;
+  }
+}
 .comment-box {
   border-radius: 4px;
   border: 1px solid #DDD;
@@ -715,6 +721,10 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group {
   height: calc(100% - $-m);
 }
 
+.comment-branch .comment-branch .comment-branch .comment-branch .comment-thread-indicator {
+  display: none;
+}
+
 #tag-manager .drag-card {
   max-width: 500px;
 }
index fa6b1a2cde62259de6399e1c6652ecd55e088bde..ae6b273fe4fe1d208a2d0eade98e0933d67f7392 100644 (file)
@@ -34,7 +34,7 @@
             </div>
         @endif
 
-        <div class="px-xl comments-container mb-l print-hidden">
+        <div class="comments-container mb-l print-hidden">
             @include('comments.comments', ['commentTree' => $commentTree, 'page' => $page])
             <div class="clearfix"></div>
         </div>
index 1159df79d187ffcaddda330a391f9c58bc3d9d35..a04933ada6d653c61027cb3768d729048a5695ab 100644 (file)
@@ -114,4 +114,25 @@ class CommentTest extends TestCase
         $pageView->assertDontSee($script, false);
         $pageView->assertSee('sometextinthecommentupdated');
     }
+
+    public function test_reply_comments_are_nested()
+    {
+        $this->asAdmin();
+        $page = $this->entities->page();
+
+        $this->postJson("/comment/$page->id", ['text' => 'My new comment']);
+        $this->postJson("/comment/$page->id", ['text' => 'My new comment']);
+
+        $respHtml = $this->withHtml($this->get($page->getUrl()));
+        $respHtml->assertElementCount('.comment-branch', 3);
+        $respHtml->assertElementNotExists('.comment-branch .comment-branch');
+
+        $comment = $page->comments()->first();
+        $resp = $this->postJson("/comment/$page->id", ['text' => 'My nested comment', 'parent_id' => $comment->local_id]);
+        $resp->assertStatus(200);
+
+        $respHtml = $this->withHtml($this->get($page->getUrl()));
+        $respHtml->assertElementCount('.comment-branch', 4);
+        $respHtml->assertElementContains('.comment-branch .comment-branch', 'My nested comment');
+    }
 }