feat: add publish specific locale (#7669)

## Description

1. Adds ability to publish a specific individual locale (collections and
globals)
2. Shows published locale in versions list and version comparison
3. Adds new int tests to `versions` test suite

- [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] New feature (non-breaking change which adds functionality)
- [ ] This change requires a documentation update

## Checklist:

- [X] 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

---------

Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
This commit is contained in:
Jessica Chowdhury
2024-09-16 16:15:29 -04:00
committed by GitHub
parent aee76cb793
commit b7a0b15786
87 changed files with 1324 additions and 141 deletions

View File

@@ -6,7 +6,17 @@ import { withSession } from './withSession.js'
export const createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(
this: MongooseAdapter,
{ autosave, createdAt, globalSlug, parent, req = {} as PayloadRequest, updatedAt, versionData },
{
autosave,
createdAt,
globalSlug,
parent,
publishedLocale,
req = {} as PayloadRequest,
snapshot,
updatedAt,
versionData,
},
) {
const VersionModel = this.versions[globalSlug]
const options = await withSession(this, req)
@@ -18,6 +28,8 @@ export const createGlobalVersion: CreateGlobalVersion = async function createGlo
createdAt,
latest: true,
parent,
publishedLocale,
snapshot,
updatedAt,
version: versionData,
},

View File

@@ -11,7 +11,9 @@ export const createVersion: CreateVersion = async function createVersion(
collectionSlug,
createdAt,
parent,
publishedLocale,
req = {} as PayloadRequest,
snapshot,
updatedAt,
versionData,
},
@@ -26,6 +28,8 @@ export const createVersion: CreateVersion = async function createVersion(
createdAt,
latest: true,
parent,
publishedLocale,
snapshot,
updatedAt,
version: versionData,
},

View File

@@ -25,6 +25,7 @@ export const findGlobalVersions: FindGlobalVersions = async function findGlobalV
) {
const Model = this.versions[global]
const versionFields = buildVersionGlobalFields(
this.payload.config,
this.payload.globals.config.find(({ slug }) => slug === global),
)
const options = {

View File

@@ -21,7 +21,7 @@ export const init: Init = function init(this: MongooseAdapter) {
if (collection.versions) {
const versionModelName = getDBName({ config: collection, versions: true })
const versionCollectionFields = buildVersionCollectionFields(collection)
const versionCollectionFields = buildVersionCollectionFields(this.payload.config, collection)
const versionSchema = buildSchema(this.payload.config, versionCollectionFields, {
disableUnique: true,
@@ -64,7 +64,7 @@ export const init: Init = function init(this: MongooseAdapter) {
if (global.versions) {
const versionModelName = getDBName({ config: global, versions: true })
const versionGlobalFields = buildVersionGlobalFields(global)
const versionGlobalFields = buildVersionGlobalFields(this.payload.config, global)
const versionSchema = buildSchema(this.payload.config, versionGlobalFields, {
disableUnique: true,