Files
websitedev/proto/src/globals/Home.ts
T
Do SikiandClaude Sonnet 5 d445f0f31a
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
feat(cms): enable draft/publish + version history on Globals/Collections (MITHOME-92)
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>
2026-09-11 21:36:03 +02:00

108 lines
3.2 KiB
TypeScript

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.
*
* WHY nincs `partners` mező: a home.partners.items a JSON-ban ma egy
* beágyazott lista, de a Payload oldalon önálló `Partners` collection lesz
* (logó = Media upload reference) — lásd MITHOME-89. Itt szándékosan
* kihagyjuk, nehogy két, egymásnak ellentmondó forrás legyen.
*/
export const Home: GlobalConfig = {
slug: 'home',
admin: {
group: 'Oldalak',
},
versions: globalVersions,
fields: [
{
name: 'hero',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true },
{ name: 'subtitle', type: 'text', required: true },
{ name: 'description', type: 'textarea', required: true },
stringArrayField('trustBullets', 'Trust bullets'),
{
name: 'cta',
type: 'group',
fields: [
{
name: 'primary',
type: 'group',
fields: [
{ name: 'text', type: 'text', required: true },
{ name: 'href', type: 'text', required: true },
{ name: 'external', type: 'checkbox', defaultValue: false },
],
},
{
name: 'secondary',
type: 'group',
fields: [
{ name: 'text', type: 'text', required: true },
{ name: 'href', type: 'text', required: true },
{ name: 'external', type: 'checkbox', defaultValue: false },
],
},
],
},
],
},
{
name: 'about',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true },
{
name: 'usps',
type: 'array',
fields: [
{ name: 'id', type: 'text', required: true },
{ name: 'title', type: 'text', required: true },
{ name: 'description', type: 'textarea', required: true },
{ name: 'icon', type: 'text', required: true },
],
},
],
},
{
name: 'services',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true },
{ name: 'subtitle', type: 'text', required: true },
{
name: 'items',
type: 'array',
fields: [
{ name: 'id', type: 'text', required: true },
{ name: 'title', type: 'text', required: true },
{ name: 'description', type: 'textarea', required: true },
{ name: 'icon', type: 'text', required: true },
stringArrayField('features', 'Features'),
{ name: 'ctaText', type: 'text', required: true },
],
},
],
},
{
name: 'cta',
type: 'group',
fields: [
{ name: 'title', type: 'text', required: true },
{ name: 'subtitle', type: 'textarea', required: true },
{ name: 'button', type: 'text', required: true },
],
},
{
name: 'serviceFeatures',
type: 'group',
fields: [{ name: 'title', type: 'text', required: true }],
},
],
}