From afb61f6227b8e963c10bd67f8132ef8146d67469 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Sun, 16 Aug 2026 23:27:51 -0400 Subject: [PATCH] feat(globals): add Shims global for admin CSS/JS shims --- src/collections/Shims.ts | 40 ++++++++++++++++++++++++++++++++++++++++ src/payload-types.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/payload.config.ts | 3 ++- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/collections/Shims.ts diff --git a/src/collections/Shims.ts b/src/collections/Shims.ts new file mode 100644 index 0000000..14d7a0e --- /dev/null +++ b/src/collections/Shims.ts @@ -0,0 +1,40 @@ +import { GlobalConfig } from "payload"; +import { isDeveloper } from "@/utils/access-control/isRole"; + +export const Shims: GlobalConfig = { + slug: "shims", + access: { + update: isDeveloper, + read: isDeveloper, + }, + fields: [ + { + name: "shims", + type: "array", + fields: [ + { + name: "name", + type: "text", + required: true, + unique: true, + }, + { + name: "summary", + type: "text", + }, + { + name: "content", + type: "code", + required: true, + }, + { + name: "type", + type: "select", + options: ["css", "js"], + required: true, + defaultValue: "css", + }, + ], + }, + ], +}; diff --git a/src/payload-types.ts b/src/payload-types.ts index ba51680..c8048ee 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -164,9 +164,11 @@ export interface Config { fallbackLocale: null; globals: { 'game-rules': GameRule; + shims: Shim; }; globalsSelect: { 'game-rules': GameRulesSelect | GameRulesSelect; + shims: ShimsSelect | ShimsSelect; }; locale: null; widgets: { @@ -3709,6 +3711,24 @@ export interface GameRule { updatedAt?: string | null; createdAt?: string | null; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "shims". + */ +export interface Shim { + id: number; + shims?: + | { + name: string; + summary?: string | null; + content: string; + type: 'css' | 'js'; + id?: string | null; + }[] + | null; + updatedAt?: string | null; + createdAt?: string | null; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "game-rules_select". @@ -3725,6 +3745,24 @@ export interface GameRulesSelect { createdAt?: T; globalType?: T; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "shims_select". + */ +export interface ShimsSelect { + shims?: + | T + | { + name?: T; + summary?: T; + content?: T; + type?: T; + id?: T; + }; + updatedAt?: T; + createdAt?: T; + globalType?: T; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "collections_widget". diff --git a/src/payload.config.ts b/src/payload.config.ts index e2f9539..c4bfc09 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -46,6 +46,7 @@ import { Tickets } from "@/collections/tickets/Tickets"; import { migrations } from "./migrations"; import { nodemailerAdapter } from "@payloadcms/email-nodemailer"; import nodemailer from "nodemailer"; +import { Shims } from "@/collections/Shims"; const filename = fileURLToPath(import.meta.url); const dirname = path.dirname(filename); @@ -96,7 +97,7 @@ export default buildConfig({ }, }, }, - globals: [GameRules], + globals: [GameRules, Shims], collections: [ Media,