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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user