@payloadcms/next 3.0.0-beta.80 → 3.0.0-beta.82
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/prod/styles.css +1 -1
- package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
- package/dist/views/Document/getViewsFromConfig.js +241 -255
- package/dist/views/Document/getViewsFromConfig.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +9 -10
- package/dist/views/Document/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getViewsFromConfig.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getViewsFromConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,MAAM,IAAI;IAClD,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,kBAAkB,+EAM5B;IACD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,MAAM,EAAE,eAAe,CAAA;IACvB,cAAc,EAAE,oBAAoB,GAAG,gBAAgB,CAAA;IACvD,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB,KAAG;IACF,UAAU,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAA;IACnD,WAAW,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAA;IACpD;;OAEG;IACH,SAAS,EAAE,cAAc,CAAC,cAAc,CAAC,CAAA;CAC1C,GAAG,
|
|
1
|
+
{"version":3,"file":"getViewsFromConfig.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getViewsFromConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAa9B,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,MAAM,IAAI;IAClD,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,kBAAkB,+EAM5B;IACD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,MAAM,EAAE,eAAe,CAAA;IACvB,cAAc,EAAE,oBAAoB,GAAG,gBAAgB,CAAA;IACvD,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB,KAAG;IACF,UAAU,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAA;IACnD,WAAW,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAA;IACpD;;OAEG;IACH,SAAS,EAAE,cAAc,CAAC,cAAc,CAAC,CAAA;CAC1C,GAAG,IA6SH,CAAA"}
|
|
@@ -16,295 +16,281 @@ export const getViewsFromConfig = ({ collectionConfig, config, docPermissions, g
|
|
|
16
16
|
const views = collectionConfig && collectionConfig?.admin?.components?.views || globalConfig && globalConfig?.admin?.components?.views;
|
|
17
17
|
const livePreviewEnabled = collectionConfig && collectionConfig?.admin?.livePreview || config?.admin?.livePreview?.collections?.includes(collectionConfig?.slug) || globalConfig && globalConfig?.admin?.livePreview || config?.admin?.livePreview?.globals?.includes(globalConfig?.slug);
|
|
18
18
|
if (collectionConfig) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
case 3:
|
|
32
|
-
{
|
|
33
|
-
switch(segment3){
|
|
34
|
-
case 'create':
|
|
35
|
-
{
|
|
36
|
-
if ('create' in docPermissions && docPermissions?.create?.permission) {
|
|
37
|
-
CustomView = {
|
|
38
|
-
payloadComponent: getCustomViewByKey(views, 'default')
|
|
39
|
-
};
|
|
40
|
-
DefaultView = {
|
|
41
|
-
Component: DefaultEditView
|
|
42
|
-
};
|
|
43
|
-
} else {
|
|
44
|
-
ErrorView = {
|
|
45
|
-
Component: UnauthorizedView
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
default:
|
|
51
|
-
{
|
|
19
|
+
const [collectionEntity, collectionSlug, segment3, segment4, segment5, ...remainingSegments] = routeSegments;
|
|
20
|
+
if (!docPermissions?.read?.permission) {
|
|
21
|
+
notFound();
|
|
22
|
+
} else {
|
|
23
|
+
// `../:id`, or `../create`
|
|
24
|
+
switch(routeSegments.length){
|
|
25
|
+
case 3:
|
|
26
|
+
{
|
|
27
|
+
switch(segment3){
|
|
28
|
+
case 'create':
|
|
29
|
+
{
|
|
30
|
+
if ('create' in docPermissions && docPermissions?.create?.permission) {
|
|
52
31
|
CustomView = {
|
|
53
32
|
payloadComponent: getCustomViewByKey(views, 'default')
|
|
54
33
|
};
|
|
55
34
|
DefaultView = {
|
|
56
35
|
Component: DefaultEditView
|
|
57
36
|
};
|
|
58
|
-
|
|
37
|
+
} else {
|
|
38
|
+
ErrorView = {
|
|
39
|
+
Component: UnauthorizedView
|
|
40
|
+
};
|
|
59
41
|
}
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
{
|
|
46
|
+
CustomView = {
|
|
47
|
+
payloadComponent: getCustomViewByKey(views, 'default')
|
|
48
|
+
};
|
|
49
|
+
DefaultView = {
|
|
50
|
+
Component: DefaultEditView
|
|
51
|
+
};
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
62
54
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
case 'preview':
|
|
80
|
-
{
|
|
81
|
-
if (livePreviewEnabled) {
|
|
82
|
-
DefaultView = {
|
|
83
|
-
Component: DefaultLivePreviewView
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
// `../:id/api`, `../:id/preview`, `../:id/versions`, etc
|
|
58
|
+
case 4:
|
|
59
|
+
{
|
|
60
|
+
switch(segment4){
|
|
61
|
+
case 'api':
|
|
62
|
+
{
|
|
63
|
+
if (collectionConfig?.admin?.hideAPIURL !== true) {
|
|
64
|
+
CustomView = {
|
|
65
|
+
payloadComponent: getCustomViewByKey(views, 'api')
|
|
66
|
+
};
|
|
67
|
+
DefaultView = {
|
|
68
|
+
Component: DefaultAPIView
|
|
69
|
+
};
|
|
87
70
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
} else {
|
|
98
|
-
ErrorView = {
|
|
99
|
-
Component: UnauthorizedView
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'preview':
|
|
74
|
+
{
|
|
75
|
+
if (livePreviewEnabled) {
|
|
76
|
+
DefaultView = {
|
|
77
|
+
Component: DefaultLivePreviewView
|
|
78
|
+
};
|
|
103
79
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
collectionSlug,
|
|
110
|
-
segment3
|
|
111
|
-
].filter(Boolean).join('/');
|
|
112
|
-
const currentRoute = [
|
|
113
|
-
baseRoute,
|
|
114
|
-
segment4,
|
|
115
|
-
segment5,
|
|
116
|
-
...remainingSegments
|
|
117
|
-
].filter(Boolean).join('/');
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 'versions':
|
|
83
|
+
{
|
|
84
|
+
if (docPermissions?.readVersions?.permission) {
|
|
118
85
|
CustomView = {
|
|
119
|
-
payloadComponent:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
86
|
+
payloadComponent: getCustomViewByKey(views, 'versions')
|
|
87
|
+
};
|
|
88
|
+
DefaultView = {
|
|
89
|
+
Component: DefaultVersionsView
|
|
90
|
+
};
|
|
91
|
+
} else {
|
|
92
|
+
ErrorView = {
|
|
93
|
+
Component: UnauthorizedView
|
|
124
94
|
};
|
|
125
|
-
break;
|
|
126
95
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
default:
|
|
99
|
+
{
|
|
100
|
+
const baseRoute = [
|
|
101
|
+
adminRoute !== '/' && adminRoute,
|
|
102
|
+
'collections',
|
|
103
|
+
collectionSlug,
|
|
104
|
+
segment3
|
|
105
|
+
].filter(Boolean).join('/');
|
|
106
|
+
const currentRoute = [
|
|
107
|
+
baseRoute,
|
|
108
|
+
segment4,
|
|
109
|
+
segment5,
|
|
110
|
+
...remainingSegments
|
|
111
|
+
].filter(Boolean).join('/');
|
|
135
112
|
CustomView = {
|
|
136
|
-
payloadComponent:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} else {
|
|
142
|
-
ErrorView = {
|
|
143
|
-
Component: UnauthorizedView
|
|
113
|
+
payloadComponent: getCustomViewByRoute({
|
|
114
|
+
baseRoute,
|
|
115
|
+
currentRoute,
|
|
116
|
+
views
|
|
117
|
+
})
|
|
144
118
|
};
|
|
119
|
+
break;
|
|
145
120
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
baseRoute,
|
|
155
|
-
segment4,
|
|
156
|
-
segment5,
|
|
157
|
-
...remainingSegments
|
|
158
|
-
].filter(Boolean).join('/');
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
// `../:id/versions/:version`, etc
|
|
125
|
+
default:
|
|
126
|
+
{
|
|
127
|
+
if (segment4 === 'versions') {
|
|
128
|
+
if (docPermissions?.readVersions?.permission) {
|
|
159
129
|
CustomView = {
|
|
160
|
-
payloadComponent:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
130
|
+
payloadComponent: getCustomViewByKey(views, 'version')
|
|
131
|
+
};
|
|
132
|
+
DefaultView = {
|
|
133
|
+
Component: DefaultVersionView
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
ErrorView = {
|
|
137
|
+
Component: UnauthorizedView
|
|
165
138
|
};
|
|
166
139
|
}
|
|
167
|
-
|
|
140
|
+
} else {
|
|
141
|
+
const baseRoute = [
|
|
142
|
+
adminRoute !== '/' && adminRoute,
|
|
143
|
+
collectionEntity,
|
|
144
|
+
collectionSlug,
|
|
145
|
+
segment3
|
|
146
|
+
].filter(Boolean).join('/');
|
|
147
|
+
const currentRoute = [
|
|
148
|
+
baseRoute,
|
|
149
|
+
segment4,
|
|
150
|
+
segment5,
|
|
151
|
+
...remainingSegments
|
|
152
|
+
].filter(Boolean).join('/');
|
|
153
|
+
CustomView = {
|
|
154
|
+
payloadComponent: getCustomViewByRoute({
|
|
155
|
+
baseRoute,
|
|
156
|
+
currentRoute,
|
|
157
|
+
views
|
|
158
|
+
})
|
|
159
|
+
};
|
|
168
160
|
}
|
|
169
|
-
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
170
163
|
}
|
|
171
164
|
}
|
|
172
165
|
}
|
|
173
166
|
if (globalConfig) {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
CustomView = {
|
|
203
|
-
payloadComponent: getCustomViewByKey(views, 'api')
|
|
204
|
-
};
|
|
205
|
-
DefaultView = {
|
|
206
|
-
Component: DefaultAPIView
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
break;
|
|
167
|
+
const [globalEntity, globalSlug, segment3, ...remainingSegments] = routeSegments;
|
|
168
|
+
if (!docPermissions?.read?.permission) {
|
|
169
|
+
notFound();
|
|
170
|
+
} else {
|
|
171
|
+
switch(routeSegments.length){
|
|
172
|
+
case 2:
|
|
173
|
+
{
|
|
174
|
+
CustomView = {
|
|
175
|
+
payloadComponent: getCustomViewByKey(views, 'default')
|
|
176
|
+
};
|
|
177
|
+
DefaultView = {
|
|
178
|
+
Component: DefaultEditView
|
|
179
|
+
};
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case 3:
|
|
183
|
+
{
|
|
184
|
+
// `../:slug/api`, `../:slug/preview`, `../:slug/versions`, etc
|
|
185
|
+
switch(segment3){
|
|
186
|
+
case 'api':
|
|
187
|
+
{
|
|
188
|
+
if (globalConfig?.admin?.hideAPIURL !== true) {
|
|
189
|
+
CustomView = {
|
|
190
|
+
payloadComponent: getCustomViewByKey(views, 'api')
|
|
191
|
+
};
|
|
192
|
+
DefaultView = {
|
|
193
|
+
Component: DefaultAPIView
|
|
194
|
+
};
|
|
210
195
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case 'preview':
|
|
199
|
+
{
|
|
200
|
+
if (livePreviewEnabled) {
|
|
201
|
+
DefaultView = {
|
|
202
|
+
Component: DefaultLivePreviewView
|
|
203
|
+
};
|
|
219
204
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 'versions':
|
|
208
|
+
{
|
|
209
|
+
if (docPermissions?.readVersions?.permission) {
|
|
210
|
+
CustomView = {
|
|
211
|
+
payloadComponent: getCustomViewByKey(views, 'versions')
|
|
212
|
+
};
|
|
213
|
+
DefaultView = {
|
|
214
|
+
Component: DefaultVersionsView
|
|
215
|
+
};
|
|
216
|
+
} else {
|
|
217
|
+
ErrorView = {
|
|
218
|
+
Component: UnauthorizedView
|
|
219
|
+
};
|
|
235
220
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
default:
|
|
224
|
+
{
|
|
225
|
+
if (docPermissions?.read?.permission) {
|
|
226
|
+
const baseRoute = [
|
|
227
|
+
adminRoute,
|
|
228
|
+
globalEntity,
|
|
229
|
+
globalSlug,
|
|
230
|
+
segment3
|
|
231
|
+
].filter(Boolean).join('/');
|
|
232
|
+
const currentRoute = [
|
|
233
|
+
baseRoute,
|
|
234
|
+
segment3,
|
|
235
|
+
...remainingSegments
|
|
236
|
+
].filter(Boolean).join('/');
|
|
237
|
+
CustomView = {
|
|
238
|
+
payloadComponent: getCustomViewByRoute({
|
|
246
239
|
baseRoute,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
Component: DefaultEditView
|
|
259
|
-
};
|
|
260
|
-
} else {
|
|
261
|
-
ErrorView = {
|
|
262
|
-
Component: UnauthorizedView
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
break;
|
|
240
|
+
currentRoute,
|
|
241
|
+
views
|
|
242
|
+
})
|
|
243
|
+
};
|
|
244
|
+
DefaultView = {
|
|
245
|
+
Component: DefaultEditView
|
|
246
|
+
};
|
|
247
|
+
} else {
|
|
248
|
+
ErrorView = {
|
|
249
|
+
Component: UnauthorizedView
|
|
250
|
+
};
|
|
266
251
|
}
|
|
267
|
-
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
default:
|
|
271
|
-
{
|
|
272
|
-
// `../:slug/versions/:version`, etc
|
|
273
|
-
if (segment3 === 'versions') {
|
|
274
|
-
if (docPermissions?.readVersions?.permission) {
|
|
275
|
-
CustomView = {
|
|
276
|
-
payloadComponent: getCustomViewByKey(views, 'version')
|
|
277
|
-
};
|
|
278
|
-
DefaultView = {
|
|
279
|
-
Component: DefaultVersionView
|
|
280
|
-
};
|
|
281
|
-
} else {
|
|
282
|
-
ErrorView = {
|
|
283
|
-
Component: UnauthorizedView
|
|
284
|
-
};
|
|
252
|
+
break;
|
|
285
253
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
segment3,
|
|
295
|
-
...remainingSegments
|
|
296
|
-
].filter(Boolean).join('/');
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
default:
|
|
258
|
+
{
|
|
259
|
+
// `../:slug/versions/:version`, etc
|
|
260
|
+
if (segment3 === 'versions') {
|
|
261
|
+
if (docPermissions?.readVersions?.permission) {
|
|
297
262
|
CustomView = {
|
|
298
|
-
payloadComponent:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
263
|
+
payloadComponent: getCustomViewByKey(views, 'version')
|
|
264
|
+
};
|
|
265
|
+
DefaultView = {
|
|
266
|
+
Component: DefaultVersionView
|
|
267
|
+
};
|
|
268
|
+
} else {
|
|
269
|
+
ErrorView = {
|
|
270
|
+
Component: UnauthorizedView
|
|
303
271
|
};
|
|
304
272
|
}
|
|
305
|
-
|
|
273
|
+
} else {
|
|
274
|
+
const baseRoute = [
|
|
275
|
+
adminRoute !== '/' && adminRoute,
|
|
276
|
+
'globals',
|
|
277
|
+
globalSlug
|
|
278
|
+
].filter(Boolean).join('/');
|
|
279
|
+
const currentRoute = [
|
|
280
|
+
baseRoute,
|
|
281
|
+
segment3,
|
|
282
|
+
...remainingSegments
|
|
283
|
+
].filter(Boolean).join('/');
|
|
284
|
+
CustomView = {
|
|
285
|
+
payloadComponent: getCustomViewByRoute({
|
|
286
|
+
baseRoute,
|
|
287
|
+
currentRoute,
|
|
288
|
+
views
|
|
289
|
+
})
|
|
290
|
+
};
|
|
306
291
|
}
|
|
307
|
-
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
308
294
|
}
|
|
309
295
|
}
|
|
310
296
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Document/getViewsFromConfig.tsx"],"sourcesContent":["import type {\n AdminViewProps,\n CollectionPermission,\n GlobalPermission,\n PayloadComponent,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n ServerSideEditViewProps,\n} from 'payload'\nimport type React from 'react'\n\nimport { notFound } from 'next/navigation.js'\n\nimport { APIView as DefaultAPIView } from '../API/index.js'\nimport { EditView as DefaultEditView } from '../Edit/index.js'\nimport { LivePreviewView as DefaultLivePreviewView } from '../LivePreview/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { VersionView as DefaultVersionView } from '../Version/index.js'\nimport { VersionsView as DefaultVersionsView } from '../Versions/index.js'\nimport { getCustomViewByKey } from './getCustomViewByKey.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\n\nexport type ViewFromConfig<TProps extends object> = {\n Component?: React.FC<TProps>\n payloadComponent?: PayloadComponent<TProps>\n}\n\nexport const getViewsFromConfig = ({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments,\n}: {\n collectionConfig?: SanitizedCollectionConfig\n config: SanitizedConfig\n docPermissions: CollectionPermission | GlobalPermission\n globalConfig?: SanitizedGlobalConfig\n routeSegments: string[]\n}): {\n CustomView: ViewFromConfig<ServerSideEditViewProps>\n DefaultView: ViewFromConfig<ServerSideEditViewProps>\n /**\n * The error view to display if CustomView or DefaultView do not exist (could be either due to not found, or unauthorized). Can be null\n */\n ErrorView: ViewFromConfig<AdminViewProps>\n} | null => {\n // Conditionally import and lazy load the default view\n let DefaultView: ViewFromConfig<ServerSideEditViewProps> = null\n let CustomView: ViewFromConfig<ServerSideEditViewProps> = null\n let ErrorView: ViewFromConfig<AdminViewProps> = null\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const views =\n (collectionConfig && collectionConfig?.admin?.components?.views) ||\n (globalConfig && globalConfig?.admin?.components?.views)\n\n const livePreviewEnabled =\n (collectionConfig && collectionConfig?.admin?.livePreview) ||\n config?.admin?.livePreview?.collections?.includes(collectionConfig?.slug) ||\n (globalConfig && globalConfig?.admin?.livePreview) ||\n config?.admin?.livePreview?.globals?.includes(globalConfig?.slug)\n\n if (collectionConfig) {\n const editConfig = collectionConfig?.admin?.components?.views?.edit\n const EditOverride = typeof editConfig === 'function' ? editConfig : null\n\n if (EditOverride) {\n CustomView = EditOverride\n }\n\n if (!EditOverride) {\n const [collectionEntity, collectionSlug, segment3, segment4, segment5, ...remainingSegments] =\n routeSegments\n\n if (!docPermissions?.read?.permission) {\n notFound()\n } else {\n // `../:id`, or `../create`\n switch (routeSegments.length) {\n case 3: {\n switch (segment3) {\n case 'create': {\n if ('create' in docPermissions && docPermissions?.create?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n break\n }\n }\n break\n }\n\n // `../:id/api`, `../:id/preview`, `../:id/versions`, etc\n case 4: {\n switch (segment4) {\n case 'api': {\n if (collectionConfig?.admin?.hideAPIURL !== true) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'api'),\n }\n DefaultView = {\n Component: DefaultAPIView,\n }\n }\n break\n }\n\n case 'preview': {\n if (livePreviewEnabled) {\n DefaultView = {\n Component: DefaultLivePreviewView,\n }\n }\n break\n }\n\n case 'versions': {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'versions'),\n }\n DefaultView = {\n Component: DefaultVersionsView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n const baseRoute = [\n adminRoute !== '/' && adminRoute,\n 'collections',\n collectionSlug,\n segment3,\n ]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n break\n }\n }\n break\n }\n\n // `../:id/versions/:version`, etc\n default: {\n if (segment4 === 'versions') {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'version'),\n }\n DefaultView = {\n Component: DefaultVersionView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n } else {\n const baseRoute = [\n adminRoute !== '/' && adminRoute,\n collectionEntity,\n collectionSlug,\n segment3,\n ]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n }\n break\n }\n }\n }\n }\n }\n\n if (globalConfig) {\n const editConfig = globalConfig?.admin?.components?.views?.edit\n const EditOverride = typeof editConfig === 'function' ? editConfig : null\n\n if (EditOverride) {\n CustomView = EditOverride\n }\n\n if (!EditOverride) {\n const [globalEntity, globalSlug, segment3, ...remainingSegments] = routeSegments\n\n if (!docPermissions?.read?.permission) {\n notFound()\n } else {\n switch (routeSegments.length) {\n case 2: {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n break\n }\n\n case 3: {\n // `../:slug/api`, `../:slug/preview`, `../:slug/versions`, etc\n switch (segment3) {\n case 'api': {\n if (globalConfig?.admin?.hideAPIURL !== true) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'api'),\n }\n DefaultView = {\n Component: DefaultAPIView,\n }\n }\n break\n }\n\n case 'preview': {\n if (livePreviewEnabled) {\n DefaultView = {\n Component: DefaultLivePreviewView,\n }\n }\n break\n }\n\n case 'versions': {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'versions'),\n }\n DefaultView = {\n Component: DefaultVersionsView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n if (docPermissions?.read?.permission) {\n const baseRoute = [adminRoute, globalEntity, globalSlug, segment3]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment3, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n }\n break\n }\n\n default: {\n // `../:slug/versions/:version`, etc\n if (segment3 === 'versions') {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'version'),\n }\n DefaultView = {\n Component: DefaultVersionView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n } else {\n const baseRoute = [adminRoute !== '/' && adminRoute, 'globals', globalSlug]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment3, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n }\n break\n }\n }\n }\n }\n }\n\n return {\n CustomView,\n DefaultView,\n ErrorView,\n }\n}\n"],"names":["notFound","APIView","DefaultAPIView","EditView","DefaultEditView","LivePreviewView","DefaultLivePreviewView","UnauthorizedView","VersionView","DefaultVersionView","VersionsView","DefaultVersionsView","getCustomViewByKey","getCustomViewByRoute","getViewsFromConfig","collectionConfig","config","docPermissions","globalConfig","routeSegments","DefaultView","CustomView","ErrorView","routes","admin","adminRoute","views","components","livePreviewEnabled","livePreview","collections","includes","slug","globals","editConfig","edit","EditOverride","collectionEntity","collectionSlug","segment3","segment4","segment5","remainingSegments","read","permission","length","create","payloadComponent","Component","hideAPIURL","readVersions","baseRoute","filter","Boolean","join","currentRoute","globalEntity","globalSlug"],"mappings":"AAYA,SAASA,QAAQ,QAAQ,qB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,MAAM,CAACC,SACPC,IAAI,CAAC;gCAER,MAAMC,eAAe;oCAACJ;oCAAWZ;uCAAaG;iCAAkB,CAC7DU,MAAM,CAACC,SACPC,IAAI,CAAC;gCAERjC,aAAa;oCACX0B,kBAAkBlC,qBAAqB;wCACrCsC;wCACAI;wCACA7B;oCACF;gCACF;4BACF;4BACA;wBACF;gBACF;YACF;QACF;IACF;IAEA,OAAO;QACLL;QACAD;QACAE;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Document/getViewsFromConfig.tsx"],"sourcesContent":["import type {\n AdminViewProps,\n CollectionPermission,\n GlobalPermission,\n PayloadComponent,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n ServerSideEditViewProps,\n} from 'payload'\nimport type React from 'react'\n\nimport { notFound } from 'next/navigation.js'\n\nimport { APIView as DefaultAPIView } from '../API/index.js'\nimport { EditView as DefaultEditView } from '../Edit/index.js'\nimport { LivePreviewView as DefaultLivePreviewView } from '../LivePreview/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { VersionView as DefaultVersionView } from '../Version/index.js'\nimport { VersionsView as DefaultVersionsView } from '../Versions/index.js'\nimport { getCustomViewByKey } from './getCustomViewByKey.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\n\nexport type ViewFromConfig<TProps extends object> = {\n Component?: React.FC<TProps>\n payloadComponent?: PayloadComponent<TProps>\n}\n\nexport const getViewsFromConfig = ({\n collectionConfig,\n config,\n docPermissions,\n globalConfig,\n routeSegments,\n}: {\n collectionConfig?: SanitizedCollectionConfig\n config: SanitizedConfig\n docPermissions: CollectionPermission | GlobalPermission\n globalConfig?: SanitizedGlobalConfig\n routeSegments: string[]\n}): {\n CustomView: ViewFromConfig<ServerSideEditViewProps>\n DefaultView: ViewFromConfig<ServerSideEditViewProps>\n /**\n * The error view to display if CustomView or DefaultView do not exist (could be either due to not found, or unauthorized). Can be null\n */\n ErrorView: ViewFromConfig<AdminViewProps>\n} | null => {\n // Conditionally import and lazy load the default view\n let DefaultView: ViewFromConfig<ServerSideEditViewProps> = null\n let CustomView: ViewFromConfig<ServerSideEditViewProps> = null\n let ErrorView: ViewFromConfig<AdminViewProps> = null\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const views =\n (collectionConfig && collectionConfig?.admin?.components?.views) ||\n (globalConfig && globalConfig?.admin?.components?.views)\n\n const livePreviewEnabled =\n (collectionConfig && collectionConfig?.admin?.livePreview) ||\n config?.admin?.livePreview?.collections?.includes(collectionConfig?.slug) ||\n (globalConfig && globalConfig?.admin?.livePreview) ||\n config?.admin?.livePreview?.globals?.includes(globalConfig?.slug)\n\n if (collectionConfig) {\n const [collectionEntity, collectionSlug, segment3, segment4, segment5, ...remainingSegments] =\n routeSegments\n\n if (!docPermissions?.read?.permission) {\n notFound()\n } else {\n // `../:id`, or `../create`\n switch (routeSegments.length) {\n case 3: {\n switch (segment3) {\n case 'create': {\n if ('create' in docPermissions && docPermissions?.create?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n break\n }\n }\n break\n }\n\n // `../:id/api`, `../:id/preview`, `../:id/versions`, etc\n case 4: {\n switch (segment4) {\n case 'api': {\n if (collectionConfig?.admin?.hideAPIURL !== true) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'api'),\n }\n DefaultView = {\n Component: DefaultAPIView,\n }\n }\n break\n }\n\n case 'preview': {\n if (livePreviewEnabled) {\n DefaultView = {\n Component: DefaultLivePreviewView,\n }\n }\n break\n }\n\n case 'versions': {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'versions'),\n }\n DefaultView = {\n Component: DefaultVersionsView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n const baseRoute = [\n adminRoute !== '/' && adminRoute,\n 'collections',\n collectionSlug,\n segment3,\n ]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n break\n }\n }\n break\n }\n\n // `../:id/versions/:version`, etc\n default: {\n if (segment4 === 'versions') {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'version'),\n }\n DefaultView = {\n Component: DefaultVersionView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n } else {\n const baseRoute = [\n adminRoute !== '/' && adminRoute,\n collectionEntity,\n collectionSlug,\n segment3,\n ]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment4, segment5, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n }\n break\n }\n }\n }\n }\n\n if (globalConfig) {\n const [globalEntity, globalSlug, segment3, ...remainingSegments] = routeSegments\n\n if (!docPermissions?.read?.permission) {\n notFound()\n } else {\n switch (routeSegments.length) {\n case 2: {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'default'),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n break\n }\n\n case 3: {\n // `../:slug/api`, `../:slug/preview`, `../:slug/versions`, etc\n switch (segment3) {\n case 'api': {\n if (globalConfig?.admin?.hideAPIURL !== true) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'api'),\n }\n DefaultView = {\n Component: DefaultAPIView,\n }\n }\n break\n }\n\n case 'preview': {\n if (livePreviewEnabled) {\n DefaultView = {\n Component: DefaultLivePreviewView,\n }\n }\n break\n }\n\n case 'versions': {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'versions'),\n }\n DefaultView = {\n Component: DefaultVersionsView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n\n default: {\n if (docPermissions?.read?.permission) {\n const baseRoute = [adminRoute, globalEntity, globalSlug, segment3]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment3, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n DefaultView = {\n Component: DefaultEditView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n break\n }\n }\n break\n }\n\n default: {\n // `../:slug/versions/:version`, etc\n if (segment3 === 'versions') {\n if (docPermissions?.readVersions?.permission) {\n CustomView = {\n payloadComponent: getCustomViewByKey(views, 'version'),\n }\n DefaultView = {\n Component: DefaultVersionView,\n }\n } else {\n ErrorView = {\n Component: UnauthorizedView,\n }\n }\n } else {\n const baseRoute = [adminRoute !== '/' && adminRoute, 'globals', globalSlug]\n .filter(Boolean)\n .join('/')\n\n const currentRoute = [baseRoute, segment3, ...remainingSegments]\n .filter(Boolean)\n .join('/')\n\n CustomView = {\n payloadComponent: getCustomViewByRoute({\n baseRoute,\n currentRoute,\n views,\n }),\n }\n }\n break\n }\n }\n }\n }\n\n return {\n CustomView,\n DefaultView,\n ErrorView,\n }\n}\n"],"names":["notFound","APIView","DefaultAPIView","EditView","DefaultEditView","LivePreviewView","DefaultLivePreviewView","UnauthorizedView","VersionView","DefaultVersionView","VersionsView","DefaultVersionsView","getCustomViewByKey","getCustomViewByRoute","getViewsFromConfig","collectionConfig","config","docPermissions","globalConfig","routeSegments","DefaultView","CustomView","ErrorView","routes","admin","adminRoute","views","components","livePreviewEnabled","livePreview","collections","includes","slug","globals","collectionEntity","collectionSlug","segment3","segment4","segment5","remainingSegments","read","permission","length","create","payloadComponent","Component","hideAPIUR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