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
@@ -12,6 +12,14 @@
|
||||
* írja a Payload-ban lévő korábbi állapotot. NEM törli/nem érinti a JSON
|
||||
* fájlokat.
|
||||
*
|
||||
* MITHOME-92 tapasztalat: a versions.drafts bekapcsolása után a `_status`
|
||||
* mező defaultValue-ja 'draft' — ha egy create/update hívás data-jában
|
||||
* nincs explicit `_status`, ÚJ dokumentum létrehozásakor 'draft' lesz, és
|
||||
* frissítéskor a meglévő (draft) érték marad meg (nem íródik felül
|
||||
* automatikusan 'published'-re). Ezért itt minden Globals/LegalPages/
|
||||
* Partners írás explicit `_status: 'published'`-t ad át — a migrációs
|
||||
* script eredménye mindig publikált tartalom legyen, sosem draft.
|
||||
*
|
||||
* MITHOME-110 tapasztalat: ha egy mezőt utólag `localized: true`-ra
|
||||
* állítasz (MITHOME-111/112 retrofit), a korábban beírt érték a régi,
|
||||
* nem-lokalizált tárolási alakban marad, és `locale: defaultLocale`-lal
|
||||
@@ -112,12 +120,12 @@ async function upsertLegalPage(payload: Payload, slug: string, json: LegalPageJs
|
||||
await payload.update({
|
||||
collection: 'legal-pages',
|
||||
id: existing.docs[0].id,
|
||||
data: { slug, ...json },
|
||||
data: { slug, ...json, _status: 'published' },
|
||||
})
|
||||
} else {
|
||||
await payload.create({
|
||||
collection: 'legal-pages',
|
||||
data: { slug, ...json },
|
||||
data: { slug, ...json, _status: 'published' },
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -160,12 +168,12 @@ async function upsertPartner(payload: Payload, partner: PartnerJson) {
|
||||
await payload.update({
|
||||
collection: 'partners',
|
||||
id: existingPartner.docs[0].id,
|
||||
data: { name: partner.name, url: partner.url, logo: mediaId },
|
||||
data: { name: partner.name, url: partner.url, logo: mediaId, _status: 'published' },
|
||||
})
|
||||
} else {
|
||||
await payload.create({
|
||||
collection: 'partners',
|
||||
data: { name: partner.name, url: partner.url, logo: mediaId },
|
||||
data: { name: partner.name, url: partner.url, logo: mediaId, _status: 'published' },
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -173,19 +181,19 @@ async function upsertPartner(payload: Payload, partner: PartnerJson) {
|
||||
async function run() {
|
||||
const payload = await getPayload({ config })
|
||||
|
||||
await payload.updateGlobal({ slug: 'home', data: buildHomeData(homeJson) })
|
||||
await payload.updateGlobal({ slug: 'home', data: { ...buildHomeData(homeJson), _status: 'published' } })
|
||||
payload.logger.info('Home global migrálva')
|
||||
|
||||
await payload.updateGlobal({ slug: 'about', data: buildAboutData(aboutJson) })
|
||||
await payload.updateGlobal({ slug: 'about', data: { ...buildAboutData(aboutJson), _status: 'published' } })
|
||||
payload.logger.info('About global migrálva')
|
||||
|
||||
await payload.updateGlobal({ slug: 'services', data: buildServicesData(servicesJson) })
|
||||
await payload.updateGlobal({ slug: 'services', data: { ...buildServicesData(servicesJson), _status: 'published' } })
|
||||
payload.logger.info('Services global migrálva')
|
||||
|
||||
await payload.updateGlobal({ slug: 'contact', data: contactJson })
|
||||
await payload.updateGlobal({ slug: 'contact', data: { ...contactJson, _status: 'published' } })
|
||||
payload.logger.info('Contact global migrálva')
|
||||
|
||||
await payload.updateGlobal({ slug: 'common', data: commonJson })
|
||||
await payload.updateGlobal({ slug: 'common', data: { ...commonJson, _status: 'published' } })
|
||||
payload.logger.info('Common global migrálva')
|
||||
|
||||
await upsertLegalPage(payload, 'adatvedelem', adatvedelemJson)
|
||||
|
||||
Reference in New Issue
Block a user