fix: restore as draft function was passing a published status (#13599)

### What  
When using the `Restore as draft` action from the version view, the
restored document incorrectly appears as `published` in the API. This
issue was reported by a client.

### Why  
In the `restoreVersion` operation, the document is updated via
`db.updateOne` (line 265). The update passes along the status stored in
the version being restored but does not respect the `draft` query
parameter.

### How  
Ensures that the result status is explicitly set to `draft` when the
`draft` argument is `true`.
This commit is contained in:
Jessica Rynkar
2025-08-27 19:09:26 +01:00
committed by GitHub
parent ded8ec4117
commit a67043854e
2 changed files with 34 additions and 0 deletions

View File

@@ -260,6 +260,8 @@ export const restoreVersionOperation = async <TData extends TypeWithID = any>(
// Ensure updatedAt date is always updated
result.updatedAt = new Date().toISOString()
// Ensure status respects restoreAsDraft arg
result._status = draftArg ? 'draft' : result._status
result = await req.payload.db.updateOne({
id: parentDocID,
collection: collectionConfig.slug,