feat(cms): add durianpy-website OrganizationStatus global - #53
Conversation
|
Kindly mark as |
ASPactores
left a comment
There was a problem hiding this comment.
Before doing any of these changes, kindly do git pull origin main -r to obtain changes from the main branch. There are modifications there that are needed for the requested changes to work.
Also, kindly create a seed function for the OrganizationStatus global in src/seed/durianpy-website/globals/OrganizationStatus.ts and register it in src/endpoints/seed/index.ts. You may obtain inspiration from existing seed functions.
Good job so far, thanks @alasdiel!
| access: { | ||
| read: (access: AccessArgs) => { | ||
| if ((access.req as any)?.draft) { | ||
| return checkOrganizationStatusAccess('read')(access) | ||
| } | ||
| return anyone(access) | ||
| }, | ||
| readVersions: checkOrganizationStatusAccess('read'), | ||
| update: checkOrganizationStatusAccess('update'), | ||
| }, |
There was a problem hiding this comment.
We have a new standard for Resource Access Checking (checkResourceAccess.ts), let's replace the custom access checks (checkOrganizationStatusAccess, anyone, (access.req as any)?.draft) with the standardized createGlobalAccess helper.
Since OrganizationStatus has drafts enabled, pass true for hasDrafts:
import { createGlobalAccess } from '@/access/checkResourceAccess'
import { GLOBALS, GLOBAL_LABELS } from '@/constants/globals'
import { getSidebarGroupLabel, SIDEBAR_GROUPS } from '@/constants/sidebarGroup'
import type { GlobalConfig } from 'payload'
export const OrganizationStatus: GlobalConfig = {
slug: GLOBALS.DURIANPY_WEBSITE_ORGANIZATION_STATUS,
label: GLOBAL_LABELS[GLOBALS.DURIANPY_WEBSITE_ORGANIZATION_STATUS],
admin: {
group: getSidebarGroupLabel(SIDEBAR_GROUPS.DURIANPY_WEBSITE),
},
versions: {
drafts: true,
},
access: createGlobalAccess(GLOBALS.DURIANPY_WEBSITE_ORGANIZATION_STATUS, true),
// ...
}|
|
||
| export const OrganizationStatus: GlobalConfig = { | ||
| slug: GLOBALS.DURIANPY_WEBSITE_ORGANIZATION_STATUS, | ||
| label: GLOBAL_LABELS[GLOBALS.DURIANPY_WEBSITE_ORGANIZATION_STATUS].singular, |
There was a problem hiding this comment.
Per the updated globals.ts constants file, GLOBAL_LABELS maps directly to a string (rather than { singular, plural }). Kindly remove .singular:
label: GLOBAL_LABELS[GLOBALS.DURIANPY_WEBSITE_ORGANIZATION_STATUS],| admin: { | ||
| group: getCollectionGroupLabel('durianpy-website'), | ||
| }, |
There was a problem hiding this comment.
Sidebar group labels should be referenced using SIDEBAR_GROUPS and getSidebarGroupLabel from @/constants/sidebarGroup:
admin: {
group: getSidebarGroupLabel(SIDEBAR_GROUPS.DURIANPY_WEBSITE),
},| name: 'psfPartnerLogo', | ||
| type: 'upload', | ||
| relationTo: 'media', | ||
| validate: (value: unknown, { siblingData }: any) => { |
There was a problem hiding this comment.
Let's avoid using any in field validation. We can type siblingData as { siblingData?: Record<string, unknown> } for stronger type safety:
validate: (value: unknown, { siblingData }: { siblingData?: Record<string, unknown> }) => {
if (siblingData?.isPSFPartner && !value) {
return 'PSF Partner Logo is required when PSF Partner is enabled.'
}
return true
},
📝 Overview
What does this PR do? Briefly describe the changes and the goal of this PR.
Implements OrganizationStatus as a global for the durianpy-website on the CMS.
This PR aims to resolve Ticket #16
🚀 Type of Change
🧱 CMS & Database Changes
Skip this section if no CMS or database changes were made.
payload migrate:createand saved the file.📊 Data Structure
Describe the new fields/tables or drag-and-drop a screenshot here:
🧪 Testing & Validation
📸 Visual Evidence (Mandatory)
Important
Visual proof is required to demonstrate that the approved test cases from the issue were successfully met.
Please provide screenshots, screen recordings (GIFs/Videos), or sample API outputs proving that the feature satisfies all approved test cases and do not introduce regressions.
OrganizationStatus shows on admin page
OrganizationStatus preview
Error banner appears when attempting to enable without PSF logo
📋 Final Checklist
mainand resolved conflicts.🧠 Extra Notes / Questions
Add any additional context or questions for the reviewers here.