feat(cms): enable draft/publish + version history on Globals/Collections (MITHOME-92)
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
Adds versions.drafts to all content-bearing Globals (Home, About, Services, Contact, Common) and Collections (LegalPages, Partners) via shared config in src/lib/payload-versions.ts. Media and Users are deliberately excluded (no draft workflow needed for uploads/auth). This is the direct successor to the old custom CMS's "Verziók panel" (MITHOME-64): the Payload admin now shows Save Draft / Publish changes and a Versions tab with history/diff/restore per document. Fixes a real bug found during manual verification: Payload's `_status` field defaults to 'draft' when a create/update call's data omits it, and that value is preserved on subsequent updates rather than being overwritten. Since migrate-content-to-payload.ts never passed `_status`, every migrated document ended up in draft status, which would have broken public pages once combined with any future explicit draft read. Fixed by explicitly setting `_status: 'published'` on every write in the migration script. Verified live in the browser: - Payload admin: Home global shows Status: Published, Save Draft / Publish changes buttons, Versions tab with history (draft -> current). - Saving a draft edit (title change, not published) does NOT change what /hu and /en render — confirmed by reloading the public page before publishing. - Publishing the change updates the public page as expected. - Full gate green: tsc, lint, tests (58 passed), production build. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b5590175b7
commit
d445f0f31a
@@ -1,11 +1,13 @@
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import { collectionVersions } from '../lib/payload-versions'
|
||||
|
||||
/**
|
||||
* Mirrors LegalPageContent (proto/src/content/types.ts) — MITHOME-88.
|
||||
* Slug-alapú collection a jogi oldalaknak (adatvedelem, hasznalati-feltetelek).
|
||||
*
|
||||
* WHY `content` textarea és nem lexical richText: a jelenlegi frontend
|
||||
* (proto/src/app/(frontend)/adatvedelem/page.tsx) a szekció-tartalmat egy
|
||||
* WHY `content` textarea és nem lexical richText: a frontend
|
||||
* (proto/src/components/views/LegalPageView.tsx) a szekció-tartalmat egy
|
||||
* kézzel írt regex-alapú "•"/"**bold**" -> HTML konverzióval rendereli, nem
|
||||
* valódi Markdown- vagy richText-parserrel. Ugyanaz a döntés, mint a
|
||||
* Contact global gdpr.label mezőjénél (MITHOME-87) — a bootstrap szinten
|
||||
@@ -17,6 +19,7 @@ export const LegalPages: CollectionConfig = {
|
||||
useAsTitle: 'title',
|
||||
group: 'Oldalak',
|
||||
},
|
||||
versions: collectionVersions,
|
||||
fields: [
|
||||
{
|
||||
name: 'slug',
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import { collectionVersions } from '../lib/payload-versions'
|
||||
|
||||
/**
|
||||
* Mirrors home.json `partners.items` (proto/src/content/pages/home.json) —
|
||||
* MITHOME-89 (MVP). Korábban a Home Global szándékosan NEM tartalmazta ezt
|
||||
@@ -12,6 +14,7 @@ export const Partners: CollectionConfig = {
|
||||
useAsTitle: 'name',
|
||||
group: 'Oldalak',
|
||||
},
|
||||
versions: collectionVersions,
|
||||
fields: [
|
||||
{ name: 'name', type: 'text', required: true },
|
||||
{ name: 'url', type: 'text', required: true },
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { stringArrayField } from './fields/stringArray'
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
|
||||
/** Mirrors AboutPageContent (proto/src/content/types.ts) — MITHOME-87. */
|
||||
export const About: GlobalConfig = {
|
||||
@@ -8,6 +9,7 @@ export const About: GlobalConfig = {
|
||||
admin: {
|
||||
group: 'Oldalak',
|
||||
},
|
||||
versions: globalVersions,
|
||||
fields: [
|
||||
{
|
||||
name: 'meta',
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
|
||||
/**
|
||||
* Mirrors CommonContent (proto/src/content/types.ts) — MITHOME-87.
|
||||
*
|
||||
@@ -14,6 +16,7 @@ export const Common: GlobalConfig = {
|
||||
admin: {
|
||||
group: 'Oldalak',
|
||||
},
|
||||
versions: globalVersions,
|
||||
fields: [
|
||||
{
|
||||
name: 'buttons',
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
|
||||
/**
|
||||
* Mirrors ContactPageContent (proto/src/content/types.ts) — MITHOME-87.
|
||||
*
|
||||
@@ -14,6 +16,7 @@ export const Contact: GlobalConfig = {
|
||||
admin: {
|
||||
group: 'Oldalak',
|
||||
},
|
||||
versions: globalVersions,
|
||||
fields: [
|
||||
{
|
||||
name: 'meta',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { stringArrayField } from './fields/stringArray'
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
|
||||
/**
|
||||
* Mirrors HomePageContent (proto/src/content/types.ts) — MITHOME-87.
|
||||
@@ -15,6 +16,7 @@ export const Home: GlobalConfig = {
|
||||
admin: {
|
||||
group: 'Oldalak',
|
||||
},
|
||||
versions: globalVersions,
|
||||
fields: [
|
||||
{
|
||||
name: 'hero',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { stringArrayField } from './fields/stringArray'
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
|
||||
/** Mirrors ServicesPageContent (proto/src/content/types.ts) — MITHOME-87. */
|
||||
export const Services: GlobalConfig = {
|
||||
@@ -8,6 +9,7 @@ export const Services: GlobalConfig = {
|
||||
admin: {
|
||||
group: 'Oldalak',
|
||||
},
|
||||
versions: globalVersions,
|
||||
fields: [
|
||||
{
|
||||
name: 'meta',
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { GlobalConfig, CollectionConfig } from 'payload'
|
||||
|
||||
/**
|
||||
* MITHOME-92: közös draft/verziózás beállítás — ez az elődje a régi egyedi
|
||||
* CMS "Verziók panel"-jének (MITHOME-64: mentéslista, diff-nézet, egy-
|
||||
* kattintásos visszaállítás). A Payload beépített verziózása/draft-rendszere
|
||||
* ugyanezt adja natívan (Payload admin "Versions" fül minden dokumentumon),
|
||||
* nem kellett újraépíteni.
|
||||
*
|
||||
* WHY `autosave` nincs bekapcsolva: az ügyfél explicit "Save Draft" /
|
||||
* "Publish" gombokkal dolgozzon, ne automatikus mentés — ugyanaz a
|
||||
* szándékos, kézi mentés-modell, mint a régi CMS-nél volt.
|
||||
*
|
||||
* WHY a Local API hívásaink (src/lib/payload-content.ts) nem törnek el
|
||||
* ettől: `findGlobal`/`find` alapból a PUBLISHED verziót adja vissza, amíg
|
||||
* explicit `draft: true` paramétert nem adunk át — ezt sehol nem tesszük,
|
||||
* így a publikus oldal renderelése változatlan marad.
|
||||
*/
|
||||
export const globalVersions: GlobalConfig['versions'] = {
|
||||
drafts: true,
|
||||
max: 50,
|
||||
}
|
||||
|
||||
export const collectionVersions: CollectionConfig['versions'] = {
|
||||
drafts: true,
|
||||
maxPerDoc: 50,
|
||||
}
|
||||
Reference in New Issue
Block a user