feat(globals): add Shims global for admin CSS/JS shims
This commit is contained in:
parent
088b6cefb6
commit
afb61f6227
3 changed files with 80 additions and 1 deletions
40
src/collections/Shims.ts
Normal file
40
src/collections/Shims.ts
Normal 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",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
@ -164,9 +164,11 @@ export interface Config {
|
||||||
fallbackLocale: null;
|
fallbackLocale: null;
|
||||||
globals: {
|
globals: {
|
||||||
'game-rules': GameRule;
|
'game-rules': GameRule;
|
||||||
|
shims: Shim;
|
||||||
};
|
};
|
||||||
globalsSelect: {
|
globalsSelect: {
|
||||||
'game-rules': GameRulesSelect<false> | GameRulesSelect<true>;
|
'game-rules': GameRulesSelect<false> | GameRulesSelect<true>;
|
||||||
|
shims: ShimsSelect<false> | ShimsSelect<true>;
|
||||||
};
|
};
|
||||||
locale: null;
|
locale: null;
|
||||||
widgets: {
|
widgets: {
|
||||||
|
|
@ -3709,6 +3711,24 @@ export interface GameRule {
|
||||||
updatedAt?: string | null;
|
updatedAt?: string | null;
|
||||||
createdAt?: 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
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "game-rules_select".
|
* via the `definition` "game-rules_select".
|
||||||
|
|
@ -3725,6 +3745,24 @@ export interface GameRulesSelect<T extends boolean = true> {
|
||||||
createdAt?: T;
|
createdAt?: T;
|
||||||
globalType?: 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
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "collections_widget".
|
* via the `definition` "collections_widget".
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ import { Tickets } from "@/collections/tickets/Tickets";
|
||||||
import { migrations } from "./migrations";
|
import { migrations } from "./migrations";
|
||||||
import { nodemailerAdapter } from "@payloadcms/email-nodemailer";
|
import { nodemailerAdapter } from "@payloadcms/email-nodemailer";
|
||||||
import nodemailer from "nodemailer";
|
import nodemailer from "nodemailer";
|
||||||
|
import { Shims } from "@/collections/Shims";
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url);
|
const filename = fileURLToPath(import.meta.url);
|
||||||
const dirname = path.dirname(filename);
|
const dirname = path.dirname(filename);
|
||||||
|
|
@ -96,7 +97,7 @@ export default buildConfig({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
globals: [GameRules],
|
globals: [GameRules, Shims],
|
||||||
collections: [
|
collections: [
|
||||||
Media,
|
Media,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue