mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Review of #2682, Also added parent deletion link on restore
On restore, added a link to the parent deletion restore if any exists on a cascading parent. Added a test to cover this case to ensure its shown. Also tweaked default empty state message on recycle bin item list to align with new column count. Also done a little existing code cleanup including a getUrl helper on the deletion items. Related to #2682 & #2594
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
use BookStack\Actions\ActivityType;
|
||||
use BookStack\Entities\Models\Deletion;
|
||||
use BookStack\Entities\Models\Entity;
|
||||
use BookStack\Entities\Tools\TrashCan;
|
||||
|
||||
class RecycleBinController extends Controller
|
||||
@ -44,8 +45,23 @@ class RecycleBinController extends Controller
|
||||
/** @var Deletion $deletion */
|
||||
$deletion = Deletion::query()->findOrFail($id);
|
||||
|
||||
// Walk the parent chain to find any cascading parent deletions
|
||||
$currentDeletable = $deletion->deletable;
|
||||
$searching = true;
|
||||
while ($searching && $currentDeletable instanceof Entity) {
|
||||
$parent = $currentDeletable->getParent();
|
||||
if ($parent && $parent->trashed()) {
|
||||
$currentDeletable = $parent;
|
||||
} else {
|
||||
$searching = false;
|
||||
}
|
||||
}
|
||||
/** @var ?Deletion $parentDeletion */
|
||||
$parentDeletion = ($currentDeletable === $deletion->deletable) ? null : $currentDeletable->deletions()->first();
|
||||
|
||||
return view('settings.recycle-bin.restore', [
|
||||
'deletion' => $deletion,
|
||||
'parentDeletion' => $parentDeletion,
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user