Skip to content

feat(cms): add durianpy-website OrganizationStatus global - #53

Open
alasdiel wants to merge 3 commits into
mainfrom
feat/durianpy-website-organization-status
Open

feat(cms): add durianpy-website OrganizationStatus global#53
alasdiel wants to merge 3 commits into
mainfrom
feat/durianpy-website-organization-status

Conversation

@alasdiel

@alasdiel alasdiel commented Aug 13, 2026

Copy link
Copy Markdown

📝 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

  • 🐛 Bug Fix: Fixed something that was broken.
  • New Feature: Added new functionality or pages.
  • 🗄️ CMS / Database: Updated collections, fields, or config in Payload CMS.
  • 🧹 Chore / Clean up: Text updates, typos, or code cleanup.

🧱 CMS & Database Changes

Skip this section if no CMS or database changes were made.

  • Migration Created: Ran payload migrate:create and saved the file.
  • Local Verification: Verified changes in the local admin panel.

📊 Data Structure

Describe the new fields/tables or drag-and-drop a screenshot here:


🧪 Testing & Validation

  • Test Case Approval: Verified that test cases were commented on the assigned GitHub issue and approved by the Project Lead before development started.
  • Unit Tests: Added or updated unit test scripts covering the new logic.
  • Admin Panel: Verified behavior in the CMS Admin UI.
  • API Check: Tested REST/GraphQL endpoints for correct data.

📸 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

image

OrganizationStatus preview

image

Error banner appears when attempting to enable without PSF logo

image

📋 Final Checklist

  • Sync: Rebased from main and resolved conflicts.
  • Pre-commit: Installed and ran pre-commit hooks successfully.
  • Security: Verified no secrets or local credentials are included.
  • Build: Project builds without errors.
  • Visuals: Attached mandatory visual evidence proving all test cases passed.
  • Migrations: Migration script included (if applicable).

🧠 Extra Notes / Questions

Add any additional context or questions for the reviewers here.

@seangaaab
seangaaab marked this pull request as ready for review August 16, 2026 02:35
@seangaaab
seangaaab requested a review from a team August 16, 2026 02:35
@ASPactores

Copy link
Copy Markdown
Contributor

Kindly mark as Ready for review if you're good with your edits @alasdiel. Thanks

@ASPactores ASPactores left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment on lines +19 to +28
access: {
read: (access: AccessArgs) => {
if ((access.req as any)?.draft) {
return checkOrganizationStatusAccess('read')(access)
}
return anyone(access)
},
readVersions: checkOrganizationStatusAccess('read'),
update: checkOrganizationStatusAccess('update'),
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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],

Comment on lines +15 to +17
admin: {
group: getCollectionGroupLabel('durianpy-website'),
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
      },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants