]> BookStack Code Mirror - bookstack/commitdiff
Updated page revisions link visibility
authorDan Brown <redacted>
Sat, 3 Sep 2022 11:32:21 +0000 (12:32 +0100)
committerDan Brown <redacted>
Sat, 3 Sep 2022 11:32:21 +0000 (12:32 +0100)
To match the actual visibilities of the revisions listing page and
options.
Related to #2946

resources/views/entities/meta.blade.php
resources/views/pages/show.blade.php
tests/Entity/PageRevisionTest.php
tests/TestCase.php

index ac91eeed35f4c5b0a30432f70a031d684946630d..7ad61f1b1e711f8eb95145cf4d37aff8a2f20e30 100644 (file)
@@ -10,9 +10,9 @@
     @endif
 
     @if ($entity->isA('page'))
-        @if (userCan('page-update', $entity)) <a href="{{ $entity->getUrl('/revisions') }}" class="entity-meta-item"> @else <div class="entity-meta-item"> @endif
-        @icon('history'){{ trans('entities.meta_revision', ['revisionCount' => $entity->revision_count]) }}
-        @if (userCan('page-update', $entity))</a> @else </div> @endif
+        <a href="{{ $entity->getUrl('/revisions') }}" class="entity-meta-item">
+            @icon('history'){{ trans('entities.meta_revision', ['revisionCount' => $entity->revision_count]) }}
+        </a>
     @endif
 
     @if ($entity->ownedBy && $entity->owned_by !== $entity->created_by)
index 45d2e2d7f7c9139eaa454e4c2bdf9ecdcaa1503f..b2c57c3196672b9fb209d4d6244ef7d48d0ef01c 100644 (file)
                            <span>{{ trans('common.move') }}</span>
                        </a>
                 @endif
-                <a href="{{ $page->getUrl('/revisions') }}" class="icon-list-item">
-                    <span>@icon('history')</span>
-                    <span>{{ trans('entities.revisions') }}</span>
-                </a>
             @endif
+            <a href="{{ $page->getUrl('/revisions') }}" class="icon-list-item">
+                <span>@icon('history')</span>
+                <span>{{ trans('entities.revisions') }}</span>
+            </a>
             @if(userCan('restrictions-manage', $page))
                 <a href="{{ $page->getUrl('/permissions') }}" class="icon-list-item">
                     <span>@icon('lock')</span>
index 78bf2dec29a36e63163f841a1fe7dbb23f98cad5..01252eda9c0186c0a57998bd63591839a8ba1982 100644 (file)
@@ -9,6 +9,18 @@ use Tests\TestCase;
 
 class PageRevisionTest extends TestCase
 {
+
+    public function test_revision_links_visible_to_viewer()
+    {
+        /** @var Page $page */
+        $page = Page::query()->first();
+
+        $html = $this->withHtml($this->asViewer()->get($page->getUrl()));
+        $html->assertLinkExists($page->getUrl('/revisions'));
+        $html->assertElementContains('a', 'Revisions');
+        $html->assertElementContains('a', 'Revision #1');
+    }
+
     public function test_page_revision_views_viewable()
     {
         $this->asEditor();
index 3ca7638c8e92c8a4d6071e024fb282f1c4e0cfa9..f17d27a1aa320fe4ae4e0bc50ade126ae326302f 100644 (file)
@@ -89,6 +89,14 @@ abstract class TestCase extends BaseTestCase
         return $this->editor;
     }
 
+    /**
+     * Set the current user context to be a viewer.
+     */
+    public function asViewer()
+    {
+        return $this->actingAs($this->getViewer());
+    }
+
     /**
      * Get an instance of a user with 'viewer' permissions.
      */