@orion-studios/payload-admin-components 0.2.0-beta.11 → 0.2.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +20 -1
- package/dist/client.d.ts +20 -1
- package/dist/client.js +639 -0
- package/dist/client.mjs +632 -0
- package/dist/index.d.mts +74 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +81 -9
- package/dist/index.mjs +81 -9
- package/package.json +1 -1
- package/src/client.ts +8 -0
- package/src/components/studio/AdminStudioDashboard.tsx +51 -0
- package/src/components/studio/AdminStudioGlobalsView.tsx +61 -0
- package/src/components/studio/AdminStudioMediaView.tsx +50 -0
- package/src/components/studio/AdminStudioNav.tsx +134 -0
- package/src/components/studio/AdminStudioPageEditView.tsx +172 -0
- package/src/components/studio/AdminStudioPagesListView.tsx +208 -0
- package/src/components/studio/AdminStudioToolsView.tsx +80 -0
- package/src/helpers/configureAdmin.ts +110 -7
|
@@ -25,6 +25,23 @@ function getPkgDistDir(): string {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export type StudioGlobalLink = {
|
|
29
|
+
label: string
|
|
30
|
+
slug: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface AdminStudioConfig {
|
|
34
|
+
enabled?: boolean
|
|
35
|
+
globals?: StudioGlobalLink[]
|
|
36
|
+
media?: {
|
|
37
|
+
collectionSlug?: string
|
|
38
|
+
}
|
|
39
|
+
pages?: {
|
|
40
|
+
builderBasePath?: string
|
|
41
|
+
collectionSlug?: string
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
export interface AdminConfig {
|
|
29
46
|
brandName: string
|
|
30
47
|
brandPrimary?: string
|
|
@@ -33,6 +50,8 @@ export interface AdminConfig {
|
|
|
33
50
|
logoUrl?: string
|
|
34
51
|
/** Pass your config file's `dirname` so configureAdmin can generate a CSS file with your brand colors. */
|
|
35
52
|
basePath?: string
|
|
53
|
+
/** Enable the unified custom Studio experience under `/admin`. */
|
|
54
|
+
studio?: AdminStudioConfig
|
|
36
55
|
}
|
|
37
56
|
|
|
38
57
|
export function configureAdmin(config: AdminConfig) {
|
|
@@ -43,6 +62,18 @@ export function configureAdmin(config: AdminConfig) {
|
|
|
43
62
|
defaultTheme = 'brand-light',
|
|
44
63
|
} = config
|
|
45
64
|
|
|
65
|
+
const studioEnabled = Boolean(config.studio?.enabled)
|
|
66
|
+
const pagesCollectionSlug = config.studio?.pages?.collectionSlug || 'pages'
|
|
67
|
+
const builderBasePath = config.studio?.pages?.builderBasePath || '/builder'
|
|
68
|
+
const mediaCollectionSlug = config.studio?.media?.collectionSlug || 'media'
|
|
69
|
+
|
|
70
|
+
const globals: StudioGlobalLink[] =
|
|
71
|
+
config.studio?.globals || [
|
|
72
|
+
{ slug: 'site-settings', label: 'Website Settings' },
|
|
73
|
+
{ slug: 'header', label: 'Header & Navigation' },
|
|
74
|
+
{ slug: 'footer', label: 'Footer' },
|
|
75
|
+
]
|
|
76
|
+
|
|
46
77
|
let cssPath: string
|
|
47
78
|
|
|
48
79
|
const pkgDist = getPkgDistDir()
|
|
@@ -64,32 +95,100 @@ export function configureAdmin(config: AdminConfig) {
|
|
|
64
95
|
cssPath = sourceCssPath
|
|
65
96
|
}
|
|
66
97
|
|
|
98
|
+
const clientPath = '@orion-studios/payload-admin-components/client'
|
|
99
|
+
|
|
67
100
|
return {
|
|
68
101
|
admin: {
|
|
69
102
|
css: cssPath,
|
|
70
103
|
components: {
|
|
104
|
+
...(studioEnabled
|
|
105
|
+
? {
|
|
106
|
+
Nav: {
|
|
107
|
+
exportName: 'AdminStudioNav',
|
|
108
|
+
path: clientPath,
|
|
109
|
+
clientProps: {
|
|
110
|
+
brandName,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
: {}),
|
|
71
115
|
graphics: {
|
|
72
116
|
Logo: {
|
|
73
117
|
exportName: 'Logo',
|
|
74
|
-
path:
|
|
118
|
+
path: clientPath,
|
|
75
119
|
},
|
|
76
120
|
Icon: {
|
|
77
121
|
exportName: 'Icon',
|
|
78
|
-
path:
|
|
122
|
+
path: clientPath,
|
|
79
123
|
},
|
|
80
124
|
},
|
|
81
125
|
views: {
|
|
82
126
|
dashboard: {
|
|
83
127
|
Component: {
|
|
84
|
-
exportName: 'Dashboard',
|
|
85
|
-
path:
|
|
128
|
+
exportName: studioEnabled ? 'AdminStudioDashboard' : 'Dashboard',
|
|
129
|
+
path: clientPath,
|
|
86
130
|
},
|
|
87
131
|
},
|
|
132
|
+
...(studioEnabled
|
|
133
|
+
? {
|
|
134
|
+
studioPages: {
|
|
135
|
+
path: '/pages' as const,
|
|
136
|
+
Component: {
|
|
137
|
+
exportName: 'AdminStudioPagesListView',
|
|
138
|
+
path: clientPath,
|
|
139
|
+
clientProps: {
|
|
140
|
+
pagesCollectionSlug,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
studioPageEdit: {
|
|
145
|
+
path: '/pages/:id' as const,
|
|
146
|
+
Component: {
|
|
147
|
+
exportName: 'AdminStudioPageEditView',
|
|
148
|
+
path: clientPath,
|
|
149
|
+
clientProps: {
|
|
150
|
+
builderBasePath,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
studioGlobals: {
|
|
155
|
+
path: '/globals' as const,
|
|
156
|
+
Component: {
|
|
157
|
+
exportName: 'AdminStudioGlobalsView',
|
|
158
|
+
path: clientPath,
|
|
159
|
+
clientProps: {
|
|
160
|
+
globals,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
studioMedia: {
|
|
165
|
+
path: '/media' as const,
|
|
166
|
+
Component: {
|
|
167
|
+
exportName: 'AdminStudioMediaView',
|
|
168
|
+
path: clientPath,
|
|
169
|
+
clientProps: {
|
|
170
|
+
mediaCollectionSlug,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
studioTools: {
|
|
175
|
+
path: '/tools' as const,
|
|
176
|
+
Component: {
|
|
177
|
+
exportName: 'AdminStudioToolsView',
|
|
178
|
+
path: clientPath,
|
|
179
|
+
clientProps: {
|
|
180
|
+
mediaCollectionSlug,
|
|
181
|
+
pagesCollectionSlug,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
: {}),
|
|
88
187
|
},
|
|
89
188
|
providers: [
|
|
90
189
|
{
|
|
91
190
|
exportName: 'ThemeProvider',
|
|
92
|
-
path:
|
|
191
|
+
path: clientPath,
|
|
93
192
|
clientProps: {
|
|
94
193
|
defaultTheme,
|
|
95
194
|
},
|
|
@@ -98,7 +197,7 @@ export function configureAdmin(config: AdminConfig) {
|
|
|
98
197
|
afterNavLinks: [
|
|
99
198
|
{
|
|
100
199
|
exportName: 'ThemeSwitcher',
|
|
101
|
-
path:
|
|
200
|
+
path: clientPath,
|
|
102
201
|
clientProps: {
|
|
103
202
|
defaultTheme,
|
|
104
203
|
},
|
|
@@ -118,7 +217,11 @@ export function configureAdmin(config: AdminConfig) {
|
|
|
118
217
|
wrapUsers(usersCollection: CollectionConfig): CollectionConfig {
|
|
119
218
|
const existingFields = usersCollection.fields || []
|
|
120
219
|
const hasThemePreference = existingFields.some(
|
|
121
|
-
(field) =>
|
|
220
|
+
(field) =>
|
|
221
|
+
typeof field === 'object' &&
|
|
222
|
+
field !== null &&
|
|
223
|
+
'name' in field &&
|
|
224
|
+
field.name === 'themePreference',
|
|
122
225
|
)
|
|
123
226
|
|
|
124
227
|
return {
|