Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2f8c9ab
feat: stubs out unpublishSpecificLocale
jessrynkar Oct 1, 2025
1bc1005
Merge branch 'main' into feat/localized-unpublish
jessrynkar Oct 1, 2025
b714acb
chore: add translations
jessrynkar Oct 1, 2025
fd4c452
chore: finish unpublish specific locale logic
jessrynkar Oct 3, 2025
73a9f4e
chore: merge with main
jessrynkar Oct 3, 2025
e7d9004
chore: hide existing unpublish button
jessrynkar Oct 3, 2025
a563ecc
chore: add translations
jessrynkar Oct 3, 2025
b2f6caa
Merge branch 'main' into feat/localized-unpublish
jessrynkar Oct 3, 2025
5441e28
chore: fix globals and clean up
jessrynkar Oct 3, 2025
30adff0
Merge branch 'main' into feat/localized-unpublish
jessrynkar Oct 3, 2025
53a00b5
chore: merge with main
jessrynkar Oct 6, 2025
5f96446
chore: fix version pill label error
jessrynkar Oct 6, 2025
f4a9855
Merge branch 'main' into feat/localized-unpublish
jessrynkar Oct 8, 2025
e545c6d
chore: add int tests for unpublish specific locale
jessrynkar Oct 8, 2025
f32fa3d
adjust var naming, adds comments
JarrodMFlesch Oct 16, 2025
409ecaa
add snapshot exclusion to getVersions helper
JarrodMFlesch Oct 16, 2025
5c8b10e
adds comments around snapshot logic
JarrodMFlesch Oct 17, 2025
41a4c02
rm snapshot query constraints for getVersion find ops
JarrodMFlesch Oct 17, 2025
5369140
fix globals
JarrodMFlesch Oct 17, 2025
8eb33ac
rm snapshot from non versions query
JarrodMFlesch Oct 17, 2025
a694bd6
improve validate search params
JarrodMFlesch Oct 17, 2025
2deb94e
improve version field query validation
JarrodMFlesch Oct 17, 2025
609efc1
fix snapshot query constraint scope
JarrodMFlesch Oct 17, 2025
f109d77
only use snapshots when localization is on
JarrodMFlesch Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/db-mongodb/src/createGlobalVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const createGlobalVersion: CreateGlobalVersion = async function createGlo
req,
returning,
snapshot,
unpublishedLocale,
updatedAt,
versionData,
},
Expand All @@ -36,6 +37,7 @@ export const createGlobalVersion: CreateGlobalVersion = async function createGlo
parent,
publishedLocale,
snapshot,
unpublishedLocale,
updatedAt,
version: versionData,
}
Expand Down
2 changes: 2 additions & 0 deletions packages/db-mongodb/src/createVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const createVersion: CreateVersion = async function createVersion(
req,
returning,
snapshot,
unpublishedLocale,
updatedAt,
versionData,
},
Expand All @@ -40,6 +41,7 @@ export const createVersion: CreateVersion = async function createVersion(
parent,
publishedLocale,
snapshot,
unpublishedLocale,
updatedAt,
version: versionData,
}
Expand Down
2 changes: 2 additions & 0 deletions packages/drizzle/src/createGlobalVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export async function createGlobalVersion<T extends TypeWithID>(
returning,
select,
snapshot,
unpublishedLocale,
updatedAt,
versionData,
}: CreateGlobalVersionArgs,
Expand All @@ -37,6 +38,7 @@ export async function createGlobalVersion<T extends TypeWithID>(
latest: true,
publishedLocale,
snapshot,
unpublishedLocale,
updatedAt,
version: versionData,
},
Expand Down
2 changes: 2 additions & 0 deletions packages/drizzle/src/createVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export async function createVersion<T extends TypeWithID>(
returning,
select,
snapshot,
unpublishedLocale,
updatedAt,
versionData,
}: CreateVersionArgs<T>,
Expand All @@ -43,6 +44,7 @@ export async function createVersion<T extends TypeWithID>(
parent,
publishedLocale,
snapshot,
unpublishedLocale,
updatedAt,
version,
}
Expand Down
18 changes: 18 additions & 0 deletions packages/next/src/views/Document/getVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ export const getVersions = async ({
equals: id,
},
},
...(payload.config.localization
? [
{
snapshot: {
not_equals: true,
},
},
]
: []),
{
'version._status': {
equals: 'draft',
Expand Down Expand Up @@ -260,6 +269,15 @@ export const getVersions = async ({
equals: 'draft',
},
},
...(payload.config.localization
? [
{
snapshot: {
not_equals: true,
},
},
]
: []),
{
updatedAt: {
greater_than: publishedDoc.updatedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const VersionPillLabel: React.FC<{
[key: string]: unknown
id: number | string
publishedLocale?: string
unpublishedLocale?: string
updatedAt?: string
version: {
[key: string]: unknown
Expand Down Expand Up @@ -85,15 +86,14 @@ export const VersionPillLabel: React.FC<{
? formatDate({ date: doc.updatedAt, i18n, pattern: dateFormat })
: null

const localeCode = Array.isArray(doc.publishedLocale)
? doc.publishedLocale[0]
: doc.publishedLocale
const getLocaleLabel = (input) => {
const code = Array.isArray(input) ? input[0] : input
const loc = localization && localization?.locales?.find((l) => l.code === code)
return loc?.label?.[i18n?.language] || loc?.label || null
}

const locale =
localization && localization?.locales
? localization.locales.find((loc) => loc.code === localeCode)
: null
const localeLabel = locale ? locale?.label?.[i18n?.language] || locale?.label : null
const unpublishedLocaleLabel = getLocaleLabel(doc.unpublishedLocale)
const localeLabel = getLocaleLabel(doc.publishedLocale)

return (
<div className={baseClass}>
Expand All @@ -117,6 +117,11 @@ export const VersionPillLabel: React.FC<{
</React.Fragment>
)}
{localeLabel && <Pill size="small">{localeLabel}</Pill>}
{unpublishedLocaleLabel && (
<Pill size="small">
{unpublishedLocaleLabel} {t('version:unpublished')}
</Pill>
)}
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type AutosaveCellProps = {
autosave?: boolean
id: number | string
publishedLocale?: string
unpublishedLocale?: string
version: {
_status: string
}
Expand Down
2 changes: 2 additions & 0 deletions packages/payload/src/collections/endpoints/updateByID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const updateByIDHandler: PayloadHandler = async (req) => {
const overrideLock = searchParams.get('overrideLock')
const trash = searchParams.get('trash') === 'true'
const publishSpecificLocale = req.query.publishSpecificLocale as string | undefined
const unpublishSpecificLocale = req.query.unpublishSpecificLocale as string | undefined

const doc = await updateByIDOperation({
id,
Expand All @@ -32,6 +33,7 @@ export const updateByIDHandler: PayloadHandler = async (req) => {
req,
select: sanitizeSelectParam(req.query.select),
trash,
unpublishSpecificLocale,
})

let message = req.t('general:updatedSuccessfully')
Expand Down
6 changes: 6 additions & 0 deletions packages/payload/src/collections/operations/local/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType
* @default false
*/
trash?: boolean
/**
* Unpublish the document / documents for a specific locale.
*/
unpublishSpecificLocale?: string
/**
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
*/
Expand Down Expand Up @@ -227,6 +231,7 @@ async function updateLocal<
showHiddenFields,
sort,
trash = false,
unpublishSpecificLocale,
where,
} = options

Expand Down Expand Up @@ -261,6 +266,7 @@ async function updateLocal<
showHiddenFields,
sort,
trash,
unpublishSpecificLocale,
where,
}

Expand Down
3 changes: 3 additions & 0 deletions packages/payload/src/collections/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type Arguments<TSlug extends CollectionSlug> = {
*/
sort?: Sort
trash?: boolean
unpublishSpecificLocale?: string
where: Where
}

Expand Down Expand Up @@ -114,6 +115,7 @@ export const updateOperation = async <
showHiddenFields,
sort: incomingSort,
trash = false,
unpublishSpecificLocale,
where,
} = args

Expand Down Expand Up @@ -261,6 +263,7 @@ export const updateOperation = async <
req,
select: select!,
showHiddenFields: showHiddenFields!,
unpublishSpecificLocale,
})

return updatedDoc
Expand Down
7 changes: 7 additions & 0 deletions packages/payload/src/collections/operations/updateByID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type Arguments<TSlug extends CollectionSlug> = {
select?: SelectType
showHiddenFields?: boolean
trash?: boolean
unpublishSpecificLocale?: string
}

export const updateByIDOperation = async <
Expand Down Expand Up @@ -83,6 +84,10 @@ export const updateByIDOperation = async <
args.req.locale = args.publishSpecificLocale
}

if (args.unpublishSpecificLocale) {
args.req.locale = args.unpublishSpecificLocale
}

const {
id,
autosave = false,
Expand All @@ -105,6 +110,7 @@ export const updateByIDOperation = async <
select: incomingSelect,
showHiddenFields,
trash = false,
unpublishSpecificLocale,
} = args

if (!id) {
Expand Down Expand Up @@ -216,6 +222,7 @@ export const updateByIDOperation = async <
req,
select: select!,
showHiddenFields: showHiddenFields!,
unpublishSpecificLocale,
})

await unlinkTempFiles({
Expand Down
Loading