Skip to content

Commit dfbc789

Browse files
committed
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
1 parent 4f5ad17 commit dfbc789

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

app/Entities/Controllers/PageRevisionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function index(Request $request, string $bookSlug, string $pageSlug)
4343
->selectRaw("IF(markdown = '', false, true) as is_markdown")
4444
->with(['page.book', 'createdBy'])
4545
->reorder('id', $listOptions->getOrder())
46-
->reorder('created_at', $listOptions->getOrder())
4746
->paginate(50);
4847

4948
$this->setPageTitle(trans('entities.pages_revisions_named', ['pageName' => $page->getShortName()]));
@@ -52,6 +51,7 @@ public function index(Request $request, string $bookSlug, string $pageSlug)
5251
'revisions' => $revisions,
5352
'page' => $page,
5453
'listOptions' => $listOptions,
54+
'oldestRevisionId' => $page->revisions()->min('id'),
5555
]);
5656
}
5757

resources/views/pages/parts/revisions-index-row.blade.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
{{ $revision->summary }}
2828
</div>
2929
<div class="flex-2 px-m py-xs actions text-small text-l-right min-width-l">
30-
<a href="{{ $revision->getUrl('changes') }}" target="_blank" rel="noopener">{{ trans('entities.pages_revisions_changes') }}</a>
31-
<span class="text-muted opacity-70">&nbsp;|&nbsp;</span>
30+
@if(!$oldest)
31+
<a href="{{ $revision->getUrl('changes') }}" target="_blank" rel="noopener">{{ trans('entities.pages_revisions_changes') }}</a>
32+
<span class="text-muted opacity-70">&nbsp;|&nbsp;</span>
33+
@endif
3234

3335

3436
@if ($current)

resources/views/pages/revisions.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@
3737
<div class="flex-2 px-m py-xs text-right">{{ trans('common.actions') }}</div>
3838
</div>
3939
@foreach($revisions as $index => $revision)
40-
@include('pages.parts.revisions-index-row', ['revision' => $revision, 'current' => $page->revision_count === $revision->revision_number])
40+
@include('pages.parts.revisions-index-row', [
41+
'revision' => $revision,
42+
'current' => $page->revision_count === $revision->revision_number,
43+
'oldest' => $oldestRevisionId === $revision->id,
44+
])
4145
@endforeach
4246
</div>
4347
@else

tests/Entity/PageRevisionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ public function test_revision_list_shows_editor_type()
203203
$this->withHtml($resp)->assertElementContains('.item-list-row > div:nth-child(2)', 'Markdown)');
204204
}
205205

206+
public function test_revision_changes_link_not_shown_for_oldest_revision()
207+
{
208+
$page = $this->entities->page();
209+
$this->createRevisions($page, 3, ['html' => 'new page html']);
210+
211+
$resp = $this->asAdmin()->get($page->refresh()->getUrl('/revisions'));
212+
$html = $this->withHtml($resp);
213+
214+
$html->assertElementNotExists('.item-list > .item-list-row:last-child a[href*="/changes"]');
215+
$html->assertElementContains('.item-list > .item-list-row:nth-child(2)', 'Changes');
216+
}
217+
206218
public function test_revision_restore_action_only_visible_with_permission()
207219
{
208220
$page = $this->entities->page();

0 commit comments

Comments
 (0)