Repository navigation
feat(ui): always restore versions as drafts - #18892
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Restore action and localized messages packages/translations/src/clientKeys.ts, packages/translations/src/languages/*, packages/ui/src/views/Version/* |
The restore view derives draft behavior from configuration, removes the status prop and draft submenu, and sends the draft choice with the restore request. Translation keys and messages cover single-locale and all-locale confirmations. |
End-to-end restore behavior test/versions/e2e.spec.ts, test/a11y/WCAG.e2e.spec.ts |
Tests cover localized and scalar restores, draft and no-draft configurations, published-content preservation, and keyboard use of the confirmation dialog. |
REST restore and access checks test/versions/int.spec.ts |
Integration tests cover draft restoration of a never-published global and access checks for global restores. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Possibly related issues
- Explore restoring all document versions as drafts by default #18926: Requests draft restoration that leaves published content unchanged, which this pull request implements.
Possibly related PRs
- payloadcms/payload#17394: Changes localized draft-status handling related to the localized restore behavior.
- payloadcms/payload#19058: Addresses preservation of other locales during localized updates, which is relevant to all-locale restoration.
Merge Risk: 
Minimal · up to 34c69
-
No issue identified here prevents merging after normal checks.
Security architecture risk: 
Low · up to 09a2d
-
Restoring from the admin now defaults to a draft where drafts are enabled. The existing server-side restore paths still enforce access checks and keep published records unchanged for draft restores. Direct restore requests can still request the older behavior, so this is an admin workflow safeguard rather than a new server-side prohibition.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The changed default affects admin restores for draft-enabled collection and global documents, including localized versions. It does not itself change the authority of direct API callers.
Trust Boundaries and Controls
- observed — The browser supplies the draft parameter, but the unchanged server operations determine access and persistence behavior. A draft restore does not update the main published collection or global record.
Resilience and Maintainability Implications
- inferred — Repeated requests can add draft versions, and the inspected code does not establish cross-request ordering or post-commit upload completion guarantees. Both behaviors belong to unchanged server paths; their effective behavior under concurrency or failure remains a coverage gap, not a verified PR regression.
-
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 46 files.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
| }) | ||
|
|
||
| describe('Restore historical content', () => { | ||
| for (const entity of ['collection'] as Array<'collection' | 'global'>) { |
There was a problem hiding this comment.
Skipping global tests here because there's an exsting issue with restoring localized global which is out of scope for this PR. Will open a follow-up PR to fix this.
There was a problem hiding this comment.
🔇 Additional comments: 1
packages/translations/src/languages/en.ts-721-721: 1
721-721:Major · Data Integrity & Integration · Quick win
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Warn about restoration across all locales.
When a collection has localized fields but localized status is disabled,
Restoreselects this message. The restore still replaces draft content across locales, but the message does not warn editors about the other locales. Select the all-locales message based on content localization, or update this message and its translations to disclose that scope. (raw.githubusercontent.com)

Review info
-
Run configuration-
- Source mode: Auto
- Repository: payloadcms/payload
- Branch: codex/safe-version-restoration
- File: .coderabbit.yaml
- Commit: 09a2d47
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
edfa2e16-00c2-442b-acfc-cf2cb9164dbc
Files selected for processing: 51-
packages/translations/src/clientKeys.tspackages/translations/src/languages/ar.tspackages/translations/src/languages/az.tspackages/translations/src/languages/bg.tspackages/translations/src/languages/bnBd.tspackages/translations/src/languages/bnIn.tspackages/translations/src/languages/ca.tspackages/translations/src/languages/cs.tspackages/translations/src/languages/da.tspackages/translations/src/languages/de.tspackages/translations/src/languages/en.tspackages/translations/src/languages/es.tspackages/translations/src/languages/et.tspackages/translations/src/languages/fa.tspackages/translations/src/languages/fr.tspackages/translations/src/languages/he.tspackages/translations/src/languages/hr.tspackages/translations/src/languages/hu.tspackages/translations/src/languages/hy.tspackages/translations/src/languages/id.tspackages/translations/src/languages/is.tspackages/translations/src/languages/it.tspackages/translations/src/languages/ja.tspackages/translations/src/languages/ko.tspackages/translations/src/languages/lt.tspackages/translations/src/languages/lv.tspackages/translations/src/languages/my.tspackages/translations/src/languages/nb.tspackages/translations/src/languages/nl.tspackages/translations/src/languages/pl.tspackages/translations/src/languages/pt.tspackages/translations/src/languages/ro.tspackages/translations/src/languages/rs.tspackages/translations/src/languages/rsLatin.tspackages/translations/src/languages/ru.tspackages/translations/src/languages/sk.tspackages/translations/src/languages/sl.tspackages/translations/src/languages/sv.tspackages/translations/src/languages/ta.tspackages/translations/src/languages/th.tspackages/translations/src/languages/tr.tspackages/translations/src/languages/uk.tspackages/translations/src/languages/vi.tspackages/translations/src/languages/zh.tspackages/translations/src/languages/zhTw.tspackages/ui/src/views/Version/Default/index.tsxpackages/ui/src/views/Version/Restore/index.csspackages/ui/src/views/Version/Restore/index.tsxtest/a11y/WCAG.e2e.spec.tstest/versions/e2e.spec.tstest/versions/int.spec.ts
Files with no reviewable changes: 2-
- packages/ui/src/views/Version/Restore/index.css
- packages/ui/src/views/Version/Default/index.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
|
🚀 This is included in version v4.0.0-beta.6 |
Restoring a version in the admin now always saves a draft for draft-enabled collections and globals, preserving published content and statuses. Restoration can no longer publish or unpublish a document, protecting live content from accidental changes.
Replaces the restore dropdown with a single
Restore as draftaction, building on #7100. Restores all locales into the latest draft. Editors review the restored content and explicitly publish from the document editor.Before:
payload-restore-before.mp4
After:
payload-restore-after.mp4