Skip to content

Commit

Permalink
[4.x] Prevent root entries being deleted in listing view (#8912)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell authored Nov 3, 2023
1 parent d3bb6df commit 2fda18b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Actions/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public function visibleTo($item)
{
switch (true) {
case $item instanceof Contracts\Entries\Entry && $item->collection()->sites()->count() === 1:
return ! $item->page()?->isRoot();
break;
case $item instanceof Contracts\Taxonomies\Term:
case $item instanceof Contracts\Assets\Asset:
case $item instanceof Contracts\Assets\AssetFolder:
Expand Down
7 changes: 5 additions & 2 deletions src/Actions/DeleteMultisiteEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ class DeleteMultisiteEntry extends Delete
{
public function visibleTo($item)
{
return $item instanceof Entry
&& $item->collection()->sites()->count() > 1;
if (! ($item instanceof Entry && $item->collection()->sites()->count() > 1)) {
return false;
}

return ! $item->page()?->isRoot();
}

public function fieldItems()
Expand Down

0 comments on commit 2fda18b

Please sign in to comment.