Updated page revisions link visibility

To match the actual visibilities of the revisions listing page and
options.
Related to #2946
This commit is contained in:
Dan Brown 2022-09-03 12:32:21 +01:00
parent 9158a66bff
commit 2fe261e207
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
4 changed files with 27 additions and 7 deletions

View File

@ -10,9 +10,9 @@
@endif @endif
@if ($entity->isA('page')) @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 <a href="{{ $entity->getUrl('/revisions') }}" class="entity-meta-item">
@icon('history'){{ trans('entities.meta_revision', ['revisionCount' => $entity->revision_count]) }} @icon('history'){{ trans('entities.meta_revision', ['revisionCount' => $entity->revision_count]) }}
@if (userCan('page-update', $entity))</a> @else </div> @endif </a>
@endif @endif
@if ($entity->ownedBy && $entity->owned_by !== $entity->created_by) @if ($entity->ownedBy && $entity->owned_by !== $entity->created_by)

View File

@ -163,11 +163,11 @@
<span>{{ trans('common.move') }}</span> <span>{{ trans('common.move') }}</span>
</a> </a>
@endif @endif
<a href="{{ $page->getUrl('/revisions') }}" class="icon-list-item">
<span>@icon('history')</span>
<span>{{ trans('entities.revisions') }}</span>
</a>
@endif @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)) @if(userCan('restrictions-manage', $page))
<a href="{{ $page->getUrl('/permissions') }}" class="icon-list-item"> <a href="{{ $page->getUrl('/permissions') }}" class="icon-list-item">
<span>@icon('lock')</span> <span>@icon('lock')</span>

View File

@ -9,6 +9,18 @@ use Tests\TestCase;
class PageRevisionTest extends 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() public function test_page_revision_views_viewable()
{ {
$this->asEditor(); $this->asEditor();

View File

@ -89,6 +89,14 @@ abstract class TestCase extends BaseTestCase
return $this->editor; 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. * Get an instance of a user with 'viewer' permissions.
*/ */