@orion-studios/payload-admin-components 0.2.0-beta.10 → 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.
@@ -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: '@orion-studios/payload-admin-components/client',
118
+ path: clientPath,
75
119
  },
76
120
  Icon: {
77
121
  exportName: 'Icon',
78
- path: '@orion-studios/payload-admin-components/client',
122
+ path: clientPath,
79
123
  },
80
124
  },
81
125
  views: {
82
126
  dashboard: {
83
127
  Component: {
84
- exportName: 'Dashboard',
85
- path: '@orion-studios/payload-admin-components/client',
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: '@orion-studios/payload-admin-components/client',
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: '@orion-studios/payload-admin-components/client',
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) => typeof field === 'object' && field !== null && 'name' in field && field.name === 'themePreference',
220
+ (field) =>
221
+ typeof field === 'object' &&
222
+ field !== null &&
223
+ 'name' in field &&
224
+ field.name === 'themePreference',
122
225
  )
123
226
 
124
227
  return {