1
0
Fork 0

feat(globals): add Shims global for admin CSS/JS shims

This commit is contained in:
Jason Fraley 2026-08-16 23:27:51 -04:00
parent 088b6cefb6
commit afb61f6227
3 changed files with 80 additions and 1 deletions

40
src/collections/Shims.ts Normal file
View file

@ -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",
},
],
},
],
};

View file

@ -164,9 +164,11 @@ export interface Config {
fallbackLocale: null;
globals: {
'game-rules': GameRule;
shims: Shim;
};
globalsSelect: {
'game-rules': GameRulesSelect<false> | GameRulesSelect<true>;
shims: ShimsSelect<false> | ShimsSelect<true>;
};
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<T extends boolean = true> {
createdAt?: T;
globalType?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "shims_select".
*/
export interface ShimsSelect<T extends boolean = true> {
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".

View file

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