You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Backport of #16944 to the `3.x` branch.
Adds a collection-level `disableBulkDelete` config option, completing
the work started in #12850 (which added collection-level
`disableBulkEdit`).
Previously, `disableBulkDelete` only existed as a List View UI prop, so
setting it hid the bulk delete button but did **not** prevent bulk
deletes via the REST, GraphQL, or Local API. A user with `delete`
permission could still delete every document at once through
`payload.delete({ where })` or `DELETE /api/:collection?where=...`.
This brings `disableBulkDelete` to full parity with `disableBulkEdit`:
- New collection config option `disableBulkDelete`.
- Server-side enforcement: the bulk `deleteOperation` now throws a `403`
when `disableBulkDelete` is set and access is not overridden, mirroring
the existing guard in `updateOperation`.
- The bulk delete UI action is hidden automatically, because the option
is threaded into the List view props.
Single-document deletes (`deleteByID`) are unaffected, so "delete one,
not delete many" works out of the box without a custom `access.delete`
check.
## Note on the 3.x adaptation
On `main` the entire list view is rendered through a single
`renderListView` in `packages/ui`, so one change covered the standard
list, trash, and hierarchy views. On `3.x` the list view is still
rendered from `packages/next`, and the folder view is separate, so the
config is threaded into both:
- `packages/next/src/views/List/index.tsx`
- `packages/ui/src/views/CollectionFolder/index.tsx`
both mirroring exactly how `disableBulkEdit` is already resolved from
`collectionConfig` in those files.
## Note on trash / soft delete
This scopes `disableBulkDelete` to the bulk delete operation, exactly
mirroring how `disableBulkEdit` guards the bulk update operation. In
Payload, bulk "move to trash" is a bulk update (it sets `deletedAt`), so
it runs through `updateOperation` and is therefore governed by
`disableBulkEdit`, not `disableBulkDelete`. A collection that wants to
lock down both bulk edits and bulk removals can set both flags, and they
compose cleanly.
## Test plan
- [x] Added a `disabled-bulk-delete-docs` collection with
`disableBulkDelete: true` in `test/collections-rest`.
- [x] Added an integration test mirroring the existing `disableBulkEdit`
test: REST bulk `DELETE` returns `403`, Local API bulk delete with
`overrideAccess: false` rejects with `APIError`, single-document delete
by `id` still works, and bulk delete still works when access is
overridden.
- [ ] `pnpm run test:int collections-rest -t "bulk"` (run against 3.x
before merge)
Co-authored-by: German Jablonski <GermanJablo@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/configuration/collections.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,7 @@ The following options are available:
86
86
|`defaultPopulate`| Specify which fields to select when this Collection is populated from another document. [More Details](../queries/select#defaultpopulate-collection-config-property). |
87
87
|`indexes`| Define compound indexes for this collection. This can be used to either speed up querying/sorting by 2 or more fields at the same time or to ensure uniqueness between several fields. |
88
88
|`forceSelect`| Specify which fields should be selected always, regardless of the `select` query which can be useful that the field exists for access control / hooks. [More details](../queries/select). |
89
+
|`disableBulkDelete`| Disable the bulk delete operation for the collection in the admin panel and the REST API |
89
90
|`disableBulkEdit`| Disable the bulk edit operation for the collection in the admin panel and the REST API |
90
91
91
92
_\* An asterisk denotes that a property is required._
0 commit comments