Skip to content

Commit

Permalink
Merge pull request #353 from doob9p/main
Browse files Browse the repository at this point in the history
button visible depending on whether or not you have permission to delete
  • Loading branch information
cregourd authored Jun 14, 2024
2 parents 0a86619 + 17fe053 commit e307b93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-countries-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin": patch
---

Modify to be undeleteable from the list if you do not have permission to delete
6 changes: 6 additions & 0 deletions packages/next-admin/src/components/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ function List({

let onSearchChange;
const modelOptions = options?.["model"]?.[resource];

const hasDeletePermission =
!modelOptions?.permissions || modelOptions?.permissions?.includes("delete");

const filterOptions = modelOptions?.list?.filters;
if (
!(modelOptions?.list?.search && modelOptions?.list?.search?.length === 0)
Expand Down Expand Up @@ -139,6 +143,8 @@ function List({
cell: ({ row }) => {
const idProperty = resourcesIdProperty[resource];

if (!hasDeletePermission) return;

return (
<Dropdown>
<DropdownTrigger asChild>
Expand Down

0 comments on commit e307b93

Please sign in to comment.