feat(cms): partner categories, publication permission and CMS-managed references copy (MITHOME-131)
Per the managed web operations research (PLATFM-13), a client must not be
shown as a "partner" and names/logos need written permission. Partners
now carry a required relationship category and a publication permission
(default: none) with the permission's location and review date; only
entries with written permission, a category and a logo are public.
The homepage shows clients ("Akik már minket választottak") and other
relationships in separate blocks via ReferencesSection; every partner
shows its relationship type. The section copy moved from a hard-coded
constant into the Home global (localized). The 20260929_partner_references
migration marks Angele Pihenőház as a client reference with written
permission (owner-confirmed), hides any other uncategorised entry, and
seeds the copy in hu + en. The JSON seed uses the same source.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
526f413bfd
commit
5f9a53ed18
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* MITHOME-131: partner- és referenciaszabályok bevezetése a meglévő adaton.
|
||||
*
|
||||
* - A Partners bejegyzések kapcsolati kategóriát és közzétételi engedélyt
|
||||
* kapnak. A tulajdonos 2026-09-29-i megerősítése szerint az Angele
|
||||
* Pihenőház ÜGYFÉL (nem partner), és írásos engedély van a név- és
|
||||
* logóhasználatra. Minden más, kategória nélküli bejegyzés "nincs
|
||||
* engedély" állapotba kerül, tehát rejtve marad, amíg valaki be nem sorolja.
|
||||
* - A Home global megkapja a korábban beégetett szekció-szövegeket
|
||||
* (hu + en), csak ha még üresek.
|
||||
*
|
||||
* Csak a dokumentumot és a legutóbbi verziót írja. Idempotens.
|
||||
*/
|
||||
import type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/db-mongodb'
|
||||
|
||||
import { rewriteDocs } from '../lib/migrate-global-docs'
|
||||
|
||||
type Data = Record<string, unknown>
|
||||
|
||||
export const CONFIRMED_CLIENT_REFERENCES = [
|
||||
{
|
||||
name: 'Angele Pihenőház',
|
||||
permissionReference: 'Írásos engedély megvan (tulajdonosi megerősítés, 2026-09-29)',
|
||||
},
|
||||
] as const
|
||||
|
||||
type Copy = Record<'hu' | 'en', string>
|
||||
|
||||
export const REFERENCES_SECTION_COPY: {
|
||||
clientsTitle: Copy
|
||||
clientsSubtitle: Copy
|
||||
partnersTitle: Copy
|
||||
partnersSubtitle: Copy
|
||||
relationshipLabels: Record<'technologyPartner' | 'infrastructure' | 'supplier' | 'technologyUsed' | 'professionalPartner', Copy>
|
||||
} = {
|
||||
clientsTitle: { hu: 'Akik már minket választottak', en: 'Clients who chose us' },
|
||||
clientsSubtitle: { hu: 'Ügyfeleink, akik hozzájárultak a bemutatásukhoz', en: 'Clients who agreed to be featured' },
|
||||
partnersTitle: { hu: 'Partnereink és technológiai hátterünk', en: 'Our partners and technology' },
|
||||
partnersSubtitle: { hu: 'Szervezetek, amelyek közreműködnek a szolgáltatásainkban', en: 'Organisations that contribute to our services' },
|
||||
relationshipLabels: {
|
||||
technologyPartner: { hu: 'Technológiai partner', en: 'Technology partner' },
|
||||
infrastructure: { hu: 'Technológiai háttér', en: 'Infrastructure provider' },
|
||||
supplier: { hu: 'Beszállító', en: 'Supplier' },
|
||||
technologyUsed: { hu: 'Általunk használt technológia', en: 'Technology we use' },
|
||||
professionalPartner: { hu: 'Szakmai partner', en: 'Professional partner' },
|
||||
},
|
||||
}
|
||||
|
||||
/** The same copy as stored by Payload for localized fields: { hu, en }. */
|
||||
function localizedCopy(): Data {
|
||||
const { relationshipLabels, ...titles } = REFERENCES_SECTION_COPY
|
||||
return { ...titles, relationshipLabels: { ...relationshipLabels } }
|
||||
}
|
||||
|
||||
export function classifyPartner(doc: Data): number {
|
||||
if (doc.relationship) return 0
|
||||
const confirmed = CONFIRMED_CLIENT_REFERENCES.find((c) => c.name === doc.name)
|
||||
if (confirmed) {
|
||||
doc.relationship = 'client-reference'
|
||||
doc.publicationPermission = 'granted'
|
||||
doc.permissionReference = confirmed.permissionReference
|
||||
} else {
|
||||
doc.publicationPermission = 'none'
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
export function seedReferencesSection(doc: Data): number {
|
||||
if (doc.referencesSection) return 0
|
||||
doc.referencesSection = localizedCopy()
|
||||
return 1
|
||||
}
|
||||
|
||||
export async function up(args: MigrateUpArgs): Promise<void> {
|
||||
const partners = await rewriteDocs(
|
||||
args,
|
||||
{ kind: 'collection', slug: 'partners' },
|
||||
['relationship', 'publicationPermission', 'permissionReference'],
|
||||
classifyPartner,
|
||||
{ versions: 'latest' },
|
||||
)
|
||||
const home = await rewriteDocs(args, { kind: 'global', slug: 'home' }, ['referencesSection'], seedReferencesSection, {
|
||||
versions: 'latest',
|
||||
})
|
||||
args.payload.logger.info(`MITHOME-131 references: ${partners} partner record(s) classified, ${home} home record(s) seeded`)
|
||||
}
|
||||
|
||||
/** DECISION: no automatic down — restore the pre-deploy dump instead. */
|
||||
export async function down(args: MigrateDownArgs): Promise<void> {
|
||||
args.payload.logger.warn('MITHOME-131 references: down is a no-op — restore the pre-deploy dump instead')
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import * as migration_20260929_cta_page_links from './20260929_cta_page_links'
|
||||
import * as migration_20260929_localize_legal_pages from './20260929_localize_legal_pages'
|
||||
import * as migration_20260929_en_ai_draft from './20260929_en_ai_draft'
|
||||
import * as migration_20260929_service_claims from './20260929_service_claims'
|
||||
import * as migration_20260929_partner_references from './20260929_partner_references'
|
||||
|
||||
/**
|
||||
* Payload migrations, in order. Passed to `mongooseAdapter({ prodMigrations })`
|
||||
@@ -38,4 +39,10 @@ export const migrations = [
|
||||
down: migration_20260929_service_claims.down,
|
||||
name: '20260929_service_claims',
|
||||
},
|
||||
{
|
||||
// MITHOME-131 — partner categories/permissions + references section copy.
|
||||
up: migration_20260929_partner_references.up,
|
||||
down: migration_20260929_partner_references.down,
|
||||
name: '20260929_partner_references',
|
||||
},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user