Revisions: Hid changes link for oldest revision

Just as a UX improvement to help avoid confusion, as the whole content
will be changes for this revision.

For #5454
This commit is contained in:
Dan Brown 2025-03-16 11:59:42 +00:00
parent 4f5ad171ac
commit dfbc78947f
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
4 changed files with 22 additions and 4 deletions

View File

@ -43,7 +43,6 @@ class PageRevisionController extends Controller
->selectRaw("IF(markdown = '', false, true) as is_markdown")
->with(['page.book', 'createdBy'])
->reorder('id', $listOptions->getOrder())
->reorder('created_at', $listOptions->getOrder())
->paginate(50);
$this->setPageTitle(trans('entities.pages_revisions_named', ['pageName' => $page->getShortName()]));
@ -52,6 +51,7 @@ class PageRevisionController extends Controller
'revisions' => $revisions,
'page' => $page,
'listOptions' => $listOptions,
'oldestRevisionId' => $page->revisions()->min('id'),
]);
}

View File

@ -27,8 +27,10 @@
{{ $revision->summary }}
</div>
<div class="flex-2 px-m py-xs actions text-small text-l-right min-width-l">
<a href="{{ $revision->getUrl('changes') }}" target="_blank" rel="noopener">{{ trans('entities.pages_revisions_changes') }}</a>
<span class="text-muted opacity-70">&nbsp;|&nbsp;</span>
@if(!$oldest)
<a href="{{ $revision->getUrl('changes') }}" target="_blank" rel="noopener">{{ trans('entities.pages_revisions_changes') }}</a>
<span class="text-muted opacity-70">&nbsp;|&nbsp;</span>
@endif
@if ($current)

View File

@ -37,7 +37,11 @@
<div class="flex-2 px-m py-xs text-right">{{ trans('common.actions') }}</div>
</div>
@foreach($revisions as $index => $revision)
@include('pages.parts.revisions-index-row', ['revision' => $revision, 'current' => $page->revision_count === $revision->revision_number])
@include('pages.parts.revisions-index-row', [
'revision' => $revision,
'current' => $page->revision_count === $revision->revision_number,
'oldest' => $oldestRevisionId === $revision->id,
])
@endforeach
</div>
@else

View File

@ -203,6 +203,18 @@ class PageRevisionTest extends TestCase
$this->withHtml($resp)->assertElementContains('.item-list-row > div:nth-child(2)', 'Markdown)');
}
public function test_revision_changes_link_not_shown_for_oldest_revision()
{
$page = $this->entities->page();
$this->createRevisions($page, 3, ['html' => 'new page html']);
$resp = $this->asAdmin()->get($page->refresh()->getUrl('/revisions'));
$html = $this->withHtml($resp);
$html->assertElementNotExists('.item-list > .item-list-row:last-child a[href*="/changes"]');
$html->assertElementContains('.item-list > .item-list-row:nth-child(2)', 'Changes');
}
public function test_revision_restore_action_only_visible_with_permission()
{
$page = $this->entities->page();