Skip to content

Commit

Permalink
[5.x] Fix incorrect revision edit URLs (#10057)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed May 13, 2024
1 parent 00be905 commit 2d90b26
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/js/components/revision-history/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
readOnly: true,
method: 'patch',
action: 'update',
itemUrl: `${this.revision.attributes.id}/revisions/${this.revision.id}`,
itemUrl: this.revision.attributes.item_url,
}
},
Expand Down
4 changes: 4 additions & 0 deletions routes/cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@
Route::resource('revisions', EntryRevisionsController::class, [
'as' => 'collections.entries',
'only' => ['index', 'store', 'show'],
])->names([
'index' => 'collections.entries.revisions.index',
'store' => 'collections.entries.revisions.store',
'show' => 'collections.entries.revisions.show',
]);

Route::post('restore-revision', RestoreEntryRevisionController::class)->name('collections.entries.restore-revision');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ public function index(Request $request, $collection, $entry)
->revisions()
->reverse()
->prepend($this->workingCopy($entry))
->filter();
->filter()
->each(function ($revision) use ($collection, $entry) {
$revision->attribute('item_url', cp_route('collections.entries.revisions.show', [
'collection' => $collection,
'entry' => $entry->id(),
'revision' => $revision->id(),
]));
});

// The first non manually created revision would be considered the "current"
// version. It's what corresponds to what's in the content directory.
Expand Down

0 comments on commit 2d90b26

Please sign in to comment.