Skip to content

Commit 6427b7e

Browse files
authored
fix: only show restore as draft option when drafts enabled (#8066)
## Description In version comparison view, the `Restore as draft` button should only be visible when `versions.drafts: true`. Before: <img width="1414" alt="Screenshot 2024-09-04 at 3 33 21 PM" src="https://github.com/user-attachments/assets/1f96d804-46d7-443a-99ea-7b6481839b47"> After: <img width="1307" alt="Screenshot 2024-09-04 at 3 38 42 PM" src="https://github.com/user-attachments/assets/d2621ddd-2b14-4dab-936c-29a5521444de"> - [X] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [X] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [ ] I have added tests that prove my fix is effective or that my feature works - [X] Existing test suite passes locally with my changes - [ ] I have made corresponding changes to the documentation
1 parent 3a65784 commit 6427b7e

File tree

1 file changed

+5
-1
lines changed
  • packages/next/src/views/Version/Restore

1 file changed

+5
-1
lines changed

packages/next/src/views/Version/Restore/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ const Restore: React.FC<Props> = ({
3636
}) => {
3737
const {
3838
config: {
39+
collections,
3940
routes: { admin: adminRoute, api: apiRoute },
4041
serverURL,
4142
},
4243
} = useConfig()
4344

45+
const collectionConfig = collections.find((collection) => collection.slug === collectionSlug)
46+
4447
const { toggleModal } = useModal()
4548
const [processing, setProcessing] = useState(false)
4649
const router = useRouter()
@@ -54,7 +57,8 @@ const Restore: React.FC<Props> = ({
5457

5558
let fetchURL = `${serverURL}${apiRoute}`
5659
let redirectURL: string
57-
const canRestoreAsDraft = status !== 'draft'
60+
61+
const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts
5862

5963
if (collectionSlug) {
6064
fetchURL = `${fetchURL}/${collectionSlug}/versions/${versionID}?draft=${draft}`

0 commit comments

Comments
 (0)