@payloadcms/next 3.43.0-canary.6 → 3.43.0-internal.693bd81
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/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js +36 -26
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.d.ts +6 -0
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.d.ts.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.js +34 -0
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.js.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.d.ts +7 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.d.ts.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.js +17 -0
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.js.map +1 -0
- package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.js +81 -35
- package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts +6 -8
- package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js +61 -91
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +0 -2
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/views/BrowseByFolder/buildView.d.ts.map +1 -1
- package/dist/views/BrowseByFolder/buildView.js +61 -40
- package/dist/views/BrowseByFolder/buildView.js.map +1 -1
- package/dist/views/CollectionFolders/buildView.d.ts.map +1 -1
- package/dist/views/CollectionFolders/buildView.js +59 -45
- package/dist/views/CollectionFolders/buildView.js.map +1 -1
- package/dist/views/Document/getMetaBySegment.d.ts.map +1 -1
- package/dist/views/Document/getMetaBySegment.js +3 -10
- package/dist/views/Document/getMetaBySegment.js.map +1 -1
- package/dist/views/Document/getViewsFromConfig.d.ts +27 -0
- package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -0
- package/dist/views/Document/getViewsFromConfig.js +330 -0
- package/dist/views/Document/getViewsFromConfig.js.map +1 -0
- package/dist/views/Document/index.d.ts +1 -2
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +76 -34
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.js +1 -3
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/Unauthorized/index.d.ts +0 -1
- package/dist/views/Unauthorized/index.d.ts.map +1 -1
- package/dist/views/Unauthorized/index.js +1 -9
- package/dist/views/Unauthorized/index.js.map +1 -1
- package/dist/views/Unauthorized/index.scss +0 -4
- package/dist/views/Version/SelectComparison/index.js +0 -1
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js +0 -2
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/views/Document/getDocumentView.d.ts +0 -18
- package/dist/views/Document/getDocumentView.d.ts.map +0 -1
- package/dist/views/Document/getDocumentView.js +0 -264
- package/dist/views/Document/getDocumentView.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,qBAAqB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAYpE,eAAO,MAAM,qBAAqB,EAAE,qBAgCnC,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { copyDataFromLocaleHandler } from '@payloadcms/ui/rsc';
|
|
2
2
|
import { buildFormStateHandler } from '@payloadcms/ui/utilities/buildFormState';
|
|
3
3
|
import { buildTableStateHandler } from '@payloadcms/ui/utilities/buildTableState';
|
|
4
|
-
import { getFolderResultsComponentAndDataHandler } from '@payloadcms/ui/utilities/getFolderResultsComponentAndData';
|
|
5
4
|
import { schedulePublishHandler } from '@payloadcms/ui/utilities/schedulePublishHandler';
|
|
6
5
|
import { renderDocumentHandler } from '../views/Document/handleServerFunction.js';
|
|
7
6
|
import { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js';
|
|
@@ -29,7 +28,6 @@ export const handleServerFunctions = async args => {
|
|
|
29
28
|
const serverFunctions = {
|
|
30
29
|
'copy-data-from-locale': copyDataFromLocaleHandler,
|
|
31
30
|
'form-state': buildFormStateHandler,
|
|
32
|
-
'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,
|
|
33
31
|
'render-document': renderDocumentHandler,
|
|
34
32
|
'render-document-slots': renderDocumentSlotsHandler,
|
|
35
33
|
'render-list': renderListHandler,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.js","names":["copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.js","names":["copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","schedulePublishHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","req","key","augmentedArgs","serverFunctions","fn","Error"],"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { copyDataFromLocaleHandler } from '@payloadcms/ui/rsc'\nimport { buildFormStateHandler } from '@payloadcms/ui/utilities/buildFormState'\nimport { buildTableStateHandler } from '@payloadcms/ui/utilities/buildTableState'\nimport { schedulePublishHandler } from '@payloadcms/ui/utilities/schedulePublishHandler'\n\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { initReq } from './initReq.js'\n\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const { name: fnKey, args: fnArgs, config: configPromise, importMap } = args\n\n const { req } = await initReq({\n configPromise,\n importMap,\n key: 'RootLayout',\n })\n\n const augmentedArgs: Parameters<ServerFunction>[0] = {\n ...fnArgs,\n importMap,\n req,\n }\n\n const serverFunctions = {\n 'copy-data-from-locale': copyDataFromLocaleHandler as any as ServerFunction,\n 'form-state': buildFormStateHandler as any as ServerFunction,\n 'render-document': renderDocumentHandler as any as ServerFunction,\n 'render-document-slots': renderDocumentSlotsHandler as any as ServerFunction,\n 'render-list': renderListHandler as any as ServerFunction,\n 'schedule-publish': schedulePublishHandler as any as ServerFunction,\n 'table-state': buildTableStateHandler as any as ServerFunction,\n }\n\n const fn = serverFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n return fn(augmentedArgs)\n}\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,iBAAiB,QAAQ;AAClC,SAASC,OAAO,QAAQ;AAExB,OAAO,MAAMC,qBAAA,GAA+C,MAAOC,IAAA;EACjE,MAAM;IAAEC,IAAA,EAAMC,KAAK;IAAEF,IAAA,EAAMG,MAAM;IAAEC,MAAA,EAAQC,aAAa;IAAEC;EAAS,CAAE,GAAGN,IAAA;EAExE,MAAM;IAAEO;EAAG,CAAE,GAAG,MAAMT,OAAA,CAAQ;IAC5BO,aAAA;IACAC,SAAA;IACAE,GAAA,EAAK;EACP;EAEA,MAAMC,aAAA,GAA+C;IACnD,GAAGN,MAAM;IACTG,SAAA;IACAC;EACF;EAEA,MAAMG,eAAA,GAAkB;IACtB,yBAAyBnB,yBAAA;IACzB,cAAcC,qBAAA;IACd,mBAAmBG,qBAAA;IACnB,yBAAyBC,0BAAA;IACzB,eAAeC,iBAAA;IACf,oBAAoBH,sBAAA;IACpB,eAAeD;EACjB;EAEA,MAAMkB,EAAA,GAAKD,eAAe,CAACR,KAAA,CAAM;EAEjC,IAAI,CAACS,EAAA,EAAI;IACP,MAAM,IAAIC,KAAA,CAAM,4BAA4BV,KAAA,EAAO;EACrD;EAEA,OAAOS,EAAA,CAAGF,aAAA;AACZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAE/B,SAAS,EAEV,MAAM,SAAS,CAAA;AAYhB,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;CACjB,GAAG,oBAAoB,CAAA;AAExB,eAAO,MAAM,uBAAuB,SAC5B,mBAAmB,KACxB,OAAO,CAAC,+BAA+B,CAiLzC,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
import { DefaultBrowseByFolderView, HydrateAuthProvider } from '@payloadcms/ui';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DefaultBrowseByFolderView, FolderProvider, HydrateAuthProvider } from '@payloadcms/ui';
|
|
3
3
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
4
|
-
import { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc';
|
|
5
4
|
import { formatAdminURL } from '@payloadcms/ui/shared';
|
|
6
5
|
import { redirect } from 'next/navigation.js';
|
|
6
|
+
import { getFolderData } from 'payload';
|
|
7
|
+
import { buildFolderWhereConstraints } from 'payload/shared';
|
|
7
8
|
import React from 'react';
|
|
9
|
+
import { getPreferences } from '../../utilities/getPreferences.js';
|
|
8
10
|
export const buildBrowseByFolderView = async args => {
|
|
9
11
|
const {
|
|
10
12
|
browseByFolderSlugs: browseByFolderSlugsFromArgs = [],
|
|
@@ -32,43 +34,64 @@ export const buildBrowseByFolderView = async args => {
|
|
|
32
34
|
},
|
|
33
35
|
visibleEntities
|
|
34
36
|
} = initPageResult;
|
|
37
|
+
const browseByFolderSlugs = browseByFolderSlugsFromArgs.filter(collectionSlug => permissions?.collections?.[collectionSlug]?.read && visibleEntities.collections.includes(collectionSlug));
|
|
35
38
|
if (config.folders === false || config.folders.browseByFolder === false) {
|
|
36
39
|
throw new Error('not-found');
|
|
37
40
|
}
|
|
38
|
-
const browseByFolderSlugs = browseByFolderSlugsFromArgs.filter(collectionSlug => permissions?.collections?.[collectionSlug]?.read && visibleEntities.collections.includes(collectionSlug));
|
|
39
41
|
const query = queryFromArgs || queryFromReq;
|
|
40
|
-
const
|
|
42
|
+
const selectedCollectionSlugs = Array.isArray(query?.relationTo) && query.relationTo.length ? query.relationTo.filter(slug => browseByFolderSlugs.includes(slug) || config.folders && slug === config.folders.slug) : [...browseByFolderSlugs, config.folders.slug];
|
|
41
43
|
const {
|
|
42
44
|
routes: {
|
|
43
45
|
admin: adminRoute
|
|
44
46
|
}
|
|
45
47
|
} = config;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const folderCollectionConfig = payload.collections[config.folders.slug].config;
|
|
49
|
+
const browseByFolderPreferences = await getPreferences('browse-by-folder', payload, user.id, user.collection);
|
|
50
|
+
let documentWhere = undefined;
|
|
51
|
+
let folderWhere = undefined;
|
|
52
|
+
// if folderID, dont make a documentWhere since it only queries root folders
|
|
53
|
+
for (const collectionSlug of selectedCollectionSlugs) {
|
|
54
|
+
if (collectionSlug === config.folders.slug) {
|
|
55
|
+
const folderCollectionConstraints = await buildFolderWhereConstraints({
|
|
56
|
+
collectionConfig: folderCollectionConfig,
|
|
57
|
+
folderID,
|
|
58
|
+
localeCode: fullLocale?.code,
|
|
59
|
+
req: initPageResult.req,
|
|
60
|
+
search: typeof query?.search === 'string' ? query.search : undefined
|
|
61
|
+
});
|
|
62
|
+
if (folderCollectionConstraints) {
|
|
63
|
+
folderWhere = folderCollectionConstraints;
|
|
64
|
+
}
|
|
65
|
+
} else if (folderID) {
|
|
66
|
+
if (!documentWhere) {
|
|
67
|
+
documentWhere = {
|
|
68
|
+
or: []
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const collectionConfig = payload.collections[collectionSlug].config;
|
|
72
|
+
if (collectionConfig.folders && collectionConfig.folders.browseByFolder === true) {
|
|
73
|
+
const collectionConstraints = await buildFolderWhereConstraints({
|
|
74
|
+
collectionConfig,
|
|
75
|
+
folderID,
|
|
76
|
+
localeCode: fullLocale?.code,
|
|
77
|
+
req: initPageResult.req,
|
|
78
|
+
search: typeof query?.search === 'string' ? query.search : undefined
|
|
79
|
+
});
|
|
80
|
+
if (collectionConstraints) {
|
|
81
|
+
documentWhere.or.push(collectionConstraints);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
56
84
|
}
|
|
57
|
-
}
|
|
58
|
-
const sortPreference = browseByFolderPreferences?.sort || '_folderOrDocumentTitle';
|
|
59
|
-
const viewPreference = browseByFolderPreferences?.viewPreference || 'grid';
|
|
85
|
+
}
|
|
60
86
|
const {
|
|
61
87
|
breadcrumbs,
|
|
62
88
|
documents,
|
|
63
|
-
FolderResultsComponent,
|
|
64
89
|
subfolders
|
|
65
|
-
} = await
|
|
66
|
-
|
|
67
|
-
browseByFolder: false,
|
|
68
|
-
displayAs: viewPreference,
|
|
90
|
+
} = await getFolderData({
|
|
91
|
+
documentWhere,
|
|
69
92
|
folderID,
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
folderWhere,
|
|
94
|
+
req: initPageResult.req
|
|
72
95
|
});
|
|
73
96
|
const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id;
|
|
74
97
|
if (!isInDrawer && (resolvedFolderID && folderID && folderID !== resolvedFolderID || folderID && !resolvedFolderID)) {
|
|
@@ -97,31 +120,29 @@ export const buildBrowseByFolderView = async args => {
|
|
|
97
120
|
// serverProps,
|
|
98
121
|
// })
|
|
99
122
|
// documents cannot be created without a parent folder in this view
|
|
100
|
-
const
|
|
123
|
+
const hasCreatePermissionCollectionSlugs = folderID ? [config.folders.slug, ...browseByFolderSlugs] : [config.folders.slug];
|
|
101
124
|
return {
|
|
102
|
-
View: /*#__PURE__*/_jsxs(
|
|
125
|
+
View: /*#__PURE__*/_jsxs(FolderProvider, {
|
|
126
|
+
breadcrumbs: breadcrumbs,
|
|
127
|
+
documents: documents,
|
|
128
|
+
filteredCollectionSlugs: selectedCollectionSlugs,
|
|
129
|
+
folderCollectionSlugs: browseByFolderSlugs,
|
|
130
|
+
folderFieldName: config.folders.fieldName,
|
|
131
|
+
folderID: folderID,
|
|
132
|
+
subfolders: subfolders,
|
|
103
133
|
children: [/*#__PURE__*/_jsx(HydrateAuthProvider, {
|
|
104
134
|
permissions: permissions
|
|
105
135
|
}), RenderServerComponent({
|
|
106
136
|
clientProps: {
|
|
107
137
|
// ...folderViewSlots,
|
|
108
|
-
activeCollectionFolderSlugs,
|
|
109
|
-
allCollectionFolderSlugs: browseByFolderSlugs,
|
|
110
|
-
allowCreateCollectionSlugs,
|
|
111
|
-
baseFolderPath: `/browse-by-folder`,
|
|
112
|
-
breadcrumbs,
|
|
113
138
|
disableBulkDelete,
|
|
114
139
|
disableBulkEdit,
|
|
115
|
-
documents,
|
|
116
140
|
enableRowSelections,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
sort: sortPreference,
|
|
121
|
-
subfolders,
|
|
122
|
-
viewPreference
|
|
141
|
+
hasCreatePermissionCollectionSlugs,
|
|
142
|
+
selectedCollectionSlugs,
|
|
143
|
+
viewPreference: browseByFolderPreferences?.value?.viewPreference
|
|
123
144
|
},
|
|
124
|
-
// Component:config.folders?.components?.views?.
|
|
145
|
+
// Component:config.folders?.components?.views?.list?.Component,
|
|
125
146
|
Fallback: DefaultBrowseByFolderView,
|
|
126
147
|
importMap: payload.importMap,
|
|
127
148
|
serverProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildView.js","names":["DefaultBrowseByFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","React","buildBrowseByFolderView","args","browseByFolderSlugs","browseByFolderSlugsFromArgs","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","params","query","queryFromArgs","searchParams","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","folders","browseByFolder","Error","filter","collectionSlug","collections","read","includes","activeCollectionFolderSlugs","Array","isArray","relationTo","length","slug","routes","admin","adminRoute","browseByFolderPreferences","key","value","sort","sortPreference","viewPreference","breadcrumbs","documents","FolderResultsComponent","subfolders","activeCollectionSlugs","displayAs","resolvedFolderID","id","path","serverURL","serverProps","allowCreateCollectionSlugs","View","_jsxs","_Fragment","_jsx","clientProps","allCollectionFolderSlugs","baseFolderPath","folderFieldName","fieldName","Fallback","importMap"],"sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewClientProps,\n FolderListViewServerPropsOnly,\n FolderSortKeys,\n ListQuery,\n} from 'payload'\n\nimport { DefaultBrowseByFolderView, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\nexport type BuildFolderViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\nexport const buildBrowseByFolderView = async (\n args: BuildFolderViewArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n browseByFolderSlugs: browseByFolderSlugsFromArgs = [],\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n locale: fullLocale,\n permissions,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (config.folders === false || config.folders.browseByFolder === false) {\n throw new Error('not-found')\n }\n\n const browseByFolderSlugs = browseByFolderSlugsFromArgs.filter(\n (collectionSlug) =>\n permissions?.collections?.[collectionSlug]?.read &&\n visibleEntities.collections.includes(collectionSlug),\n )\n\n const query = queryFromArgs || queryFromReq\n const activeCollectionFolderSlugs: string[] =\n Array.isArray(query?.relationTo) && query.relationTo.length\n ? query.relationTo.filter(\n (slug) =>\n browseByFolderSlugs.includes(slug) || (config.folders && slug === config.folders.slug),\n )\n : [...browseByFolderSlugs, config.folders.slug]\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n /**\n * @todo: find a pattern to avoid setting preferences on hard navigation, i.e. direct links, page refresh, etc.\n * This will ensure that prefs are only updated when explicitly set by the user\n * This could potentially be done by injecting a `sessionID` into the params and comparing it against a session cookie\n */\n const browseByFolderPreferences = await upsertPreferences<{\n sort?: FolderSortKeys\n viewPreference?: 'grid' | 'list'\n }>({\n key: 'browse-by-folder',\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys = browseByFolderPreferences?.sort || '_folderOrDocumentTitle'\n const viewPreference = browseByFolderPreferences?.viewPreference || 'grid'\n\n const { breadcrumbs, documents, FolderResultsComponent, subfolders } =\n await getFolderResultsComponentAndData({\n activeCollectionSlugs: activeCollectionFolderSlugs,\n browseByFolder: false,\n displayAs: viewPreference,\n folderID,\n req: initPageResult.req,\n sort: sortPreference,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: config.admin.routes.browseByFolder,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const serverProps: Omit<FolderListViewServerPropsOnly, 'collectionConfig' | 'listPreferences'> = {\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // },\n // description: staticDescription,\n // payload,\n // serverProps,\n // })\n\n // documents cannot be created without a parent folder in this view\n const allowCreateCollectionSlugs = resolvedFolderID\n ? [config.folders.slug, ...browseByFolderSlugs]\n : [config.folders.slug]\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n activeCollectionFolderSlugs,\n allCollectionFolderSlugs: browseByFolderSlugs,\n allowCreateCollectionSlugs,\n baseFolderPath: `/browse-by-folder`,\n breadcrumbs,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderFieldName: config.folders.fieldName,\n folderID: resolvedFolderID || null,\n FolderResultsComponent,\n sort: sortPreference,\n subfolders,\n viewPreference,\n } satisfies FolderListViewClientProps,\n // Component:config.folders?.components?.views?.BrowseByFolders?.Component,\n Fallback: DefaultBrowseByFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </>\n ),\n }\n}\n"],"mappings":";AASA,SAASA,yBAAyB,EAAEC,mBAAmB,QAAQ;AAC/D,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gCAAgC,EAAEC,iBAAiB,QAAQ;AACpE,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAalB,OAAO,MAAMC,uBAAA,GAA0B,MACrCC,IAAA;EAEA,MAAM;IACJC,mBAAA,EAAqBC,2BAAA,GAA8B,EAAE;IACrDC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGZ,IAAA;EAEJ,MAAM;IACJa,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBT,KAAA,EAAOU,YAAY;MACnBC;IA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AiB9C,MAAA,CAAOI,OAAO,CAAC2C,SAAS;UACzC5D,QAAA,EAAU8C,gBAAA,IAAoB;UAC9BJ,sBAAA;UACAL,IAAA,EAAMC,cAAA;UACNK,UAAA;UACAJ;QACF;QACA;QACAsB,QAAA,EAAU5E,yBAAA;QACV6E,SAAA,EAAWlD,OAAA,CAAQkD,SAAS;QAC5BZ;MACF;;EAGN;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildView.js","names":["DefaultBrowseByFolderView","FolderProvider","HydrateAuthProvider","RenderServerComponent","formatAdminURL","redirect","getFolderData","buildFolderWhereConstraints","React","getPreferences","buildBrowseByFolderView","args","browseByFolderSlugs","browseByFolderSlugsFromArgs","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","params","query","queryFromArgs","searchParams","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","filter","collectionSlug","collections","read","includes","folders","browseByFolder","Error","selectedCollectionSlugs","Array","isArray","relationTo","length","slug","routes","admin","adminRoute","folderCollectionConfig","browseByFolderPreferences","id","collection","documentWhere","undefined","folderWhere","folderCollectionConstraints","collectionConfig","localeCode","code","search","or","collectionConstraints","push","breadcrumbs","documents","subfolders","resolvedFolderID","path","serverURL","serverProps","hasCreatePermissionCollectionSlugs","View","_jsxs","filteredCollectionSlugs","folderCollectionSlugs","folderFieldName","fieldName","_jsx","clientProps","viewPreference","value","Fallback","importMap"],"sources":["../../../src/views/BrowseByFolder/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewServerPropsOnly,\n ListQuery,\n Where,\n} from 'payload'\n\nimport { DefaultBrowseByFolderView, FolderProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport { getFolderData } from 'payload'\nimport { buildFolderWhereConstraints } from 'payload/shared'\nimport React from 'react'\n\nimport { getPreferences } from '../../utilities/getPreferences.js'\n\nexport type BuildFolderViewArgs = {\n customCellProps?: Record<string, any>\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\nexport const buildBrowseByFolderView = async (\n args: BuildFolderViewArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n browseByFolderSlugs: browseByFolderSlugsFromArgs = [],\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n locale: fullLocale,\n permissions,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const browseByFolderSlugs = browseByFolderSlugsFromArgs.filter(\n (collectionSlug) =>\n permissions?.collections?.[collectionSlug]?.read &&\n visibleEntities.collections.includes(collectionSlug),\n )\n\n if (config.folders === false || config.folders.browseByFolder === false) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n const selectedCollectionSlugs: string[] =\n Array.isArray(query?.relationTo) && query.relationTo.length\n ? query.relationTo.filter(\n (slug) =>\n browseByFolderSlugs.includes(slug) || (config.folders && slug === config.folders.slug),\n )\n : [...browseByFolderSlugs, config.folders.slug]\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const folderCollectionConfig = payload.collections[config.folders.slug].config\n\n const browseByFolderPreferences = await getPreferences<{ viewPreference: string }>(\n 'browse-by-folder',\n payload,\n user.id,\n user.collection,\n )\n\n let documentWhere: undefined | Where = undefined\n let folderWhere: undefined | Where = undefined\n // if folderID, dont make a documentWhere since it only queries root folders\n for (const collectionSlug of selectedCollectionSlugs) {\n if (collectionSlug === config.folders.slug) {\n const folderCollectionConstraints = await buildFolderWhereConstraints({\n collectionConfig: folderCollectionConfig,\n folderID,\n localeCode: fullLocale?.code,\n req: initPageResult.req,\n search: typeof query?.search === 'string' ? query.search : undefined,\n })\n\n if (folderCollectionConstraints) {\n folderWhere = folderCollectionConstraints\n }\n } else if (folderID) {\n if (!documentWhere) {\n documentWhere = {\n or: [],\n }\n }\n\n const collectionConfig = payload.collections[collectionSlug].config\n if (collectionConfig.folders && collectionConfig.folders.browseByFolder === true) {\n const collectionConstraints = await buildFolderWhereConstraints({\n collectionConfig,\n folderID,\n localeCode: fullLocale?.code,\n req: initPageResult.req,\n search: typeof query?.search === 'string' ? query.search : undefined,\n })\n\n if (collectionConstraints) {\n documentWhere.or.push(collectionConstraints)\n }\n }\n }\n }\n\n const { breadcrumbs, documents, subfolders } = await getFolderData({\n documentWhere,\n folderID,\n folderWhere,\n req: initPageResult.req,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: config.admin.routes.browseByFolder,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const serverProps: Omit<FolderListViewServerPropsOnly, 'collectionConfig' | 'listPreferences'> = {\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // },\n // description: staticDescription,\n // payload,\n // serverProps,\n // })\n\n // documents cannot be created without a parent folder in this view\n const hasCreatePermissionCollectionSlugs = folderID\n ? [config.folders.slug, ...browseByFolderSlugs]\n : [config.folders.slug]\n\n return {\n View: (\n <FolderProvider\n breadcrumbs={breadcrumbs}\n documents={documents}\n filteredCollectionSlugs={selectedCollectionSlugs}\n folderCollectionSlugs={browseByFolderSlugs}\n folderFieldName={config.folders.fieldName}\n folderID={folderID}\n subfolders={subfolders}\n >\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n hasCreatePermissionCollectionSlugs,\n selectedCollectionSlugs,\n viewPreference: browseByFolderPreferences?.value?.viewPreference,\n },\n // Component:config.folders?.components?.views?.list?.Component,\n Fallback: DefaultBrowseByFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </FolderProvider>\n ),\n }\n}\n"],"mappings":";AAQA,SAASA,yBAAyB,EAAEC,cAAc,EAAEC,mBAAmB,QAAQ;AAC/E,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,2BAA2B,QAAQ;AAC5C,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAa/B,OAAO,MAAMC,uBAAA,GAA0B,MACrCC,IAAA;EAEA,MAAM;IACJC,mBAAA,EAAqBC,2BAAA,GAA8B,EAAE;IACrDC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGZ,IAAA;EAEJ,MAAM;IACJa,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBT,KAAA,EAAOU,YAAY;MACnBC;IAAI,CACL;IACDC;EAAe,CAChB,GAAGf,cAAA;EAEJ,MAAMN,mBAAA,GAAsBC,2BAAA,CAA4BqB,MAAM,CAC3DC,cAAA,IACCT,WAAA,EAAaU,WAAA,GAAcD,cAAA,CAAe,EAAEE,IAAA,IAC5CJ,eAAA,CAAgBG,WAAW,CAACE,QAAQ,CAACH,cAAA;EAGzC,IAAIL,MAAA,CAAOS,OAAO,KAAK,SAAST,MAAA,CAAOS,OAAO,CAACC,cAAc,KAA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AAWzC,MAAA,CAAOyC;IACpB;EAEJ;EAEA,MAAMC,WAAA,GAA2F;IAC/FL,SAAA;IACAvC,IAAA;IACAJ,MAAA,EAAQC,UAAA;IACRL,MAAA;IACAS,OAAA;IACAH,WAAA;IACAH,YAAA;IACA6C,UAAA;IACApC;EACF;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA,MAAMyC,kCAAA,GAAqCxD,QAAA,GACvC,CAACa,MAAA,CAAOS,OAAO,CAACQ,IAAI,E,GAAKnC,mBAAA,CAAoB,GAC7C,CAACkB,MAAA,CAAOS,OAAO,CAACQ,IAAI,CAAC;EAEzB,OAAO;IACL2B,IAAA,eACEC,KAAA,CAAC1E,cAAA;MACCiE,WAAA,EAAaA,WAAA;MACbC,SAAA,EAAWA,SAAA;MACXS,uBAAA,EAAyBlC,uBAAA;MACzBmC,qBAAA,EAAuBjE,mBAAA;MACvBkE,eAAA,EAAiBhD,MAAA,CAAOS,OAAO,CAACwC,SAAS;MACzC9D,QAAA,EAAUA,QAAA;MACVmD,UAAA,EAAYA,UAAA;8BAEZY,IAAA,CAAC9E,mBAAA;QAAoBwB,WAAA,EAAaA;UACjCvB,qBAAA,CAAsB;QACrB8E,WAAA,EAAa;UACX;UACAnE,iBAAA;UACAC,eAAA;UACAC,mBAAA;UACAyD,kCAAA;UACA/B,uBAAA;UACAwC,cAAA,EAAgB9B,yBAAA,EAA2B+B,KAAA,EAAOD;QACpD;QACA;QACAE,QAAA,EAAUpF,yBAAA;QACVqF,SAAA,EAAWxD,OAAA,CAAQwD,SAAS;QAC5Bb;MACF;;EAGN;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/CollectionFolders/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/CollectionFolders/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAE/B,SAAS,EAEV,MAAM,SAAS,CAAA;AAchB,MAAM,MAAM,kCAAkC,GAAG;IAC/C,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;CACjB,GAAG,oBAAoB,CAAA;AAExB;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAC9B,kCAAkC,KACvC,OAAO,CAAC,+BAA+B,CAkLzC,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
import { DefaultCollectionFolderView, HydrateAuthProvider } from '@payloadcms/ui';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DefaultCollectionFolderView, FolderProvider, HydrateAuthProvider } from '@payloadcms/ui';
|
|
3
3
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
4
|
-
import { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc';
|
|
5
4
|
import { formatAdminURL } from '@payloadcms/ui/shared';
|
|
6
5
|
import { redirect } from 'next/navigation.js';
|
|
6
|
+
import { getFolderData } from 'payload';
|
|
7
|
+
import { buildFolderWhereConstraints } from 'payload/shared';
|
|
7
8
|
import React from 'react';
|
|
9
|
+
import { getPreferences } from '../../utilities/getPreferences.js';
|
|
8
10
|
/**
|
|
9
11
|
* Builds the entire view for collection-folder views on the server
|
|
10
12
|
*/
|
|
@@ -39,48 +41,56 @@ export const buildCollectionFolderView = async args => {
|
|
|
39
41
|
},
|
|
40
42
|
visibleEntities
|
|
41
43
|
} = initPageResult;
|
|
42
|
-
if (!
|
|
43
|
-
throw new Error('not-found');
|
|
44
|
-
}
|
|
45
|
-
if (!permissions?.collections?.[collectionSlug]?.read || !permissions?.collections?.[config.folders.slug].read) {
|
|
44
|
+
if (!permissions?.collections?.[collectionSlug]?.read) {
|
|
46
45
|
throw new Error('not-found');
|
|
47
46
|
}
|
|
48
47
|
if (collectionConfig) {
|
|
49
|
-
if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility || !config.folders) {
|
|
50
|
-
throw new Error('not-found');
|
|
51
|
-
}
|
|
52
48
|
const query = queryFromArgs || queryFromReq;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* This will ensure that prefs are only updated when explicitly set by the user
|
|
56
|
-
* This could potentially be done by injecting a `sessionID` into the params and comparing it against a session cookie
|
|
57
|
-
*/
|
|
58
|
-
const collectionFolderPreferences = await upsertPreferences({
|
|
59
|
-
key: `${collectionSlug}-collection-folder`,
|
|
60
|
-
req: initPageResult.req,
|
|
61
|
-
value: {
|
|
62
|
-
sort: query?.sort
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
const sortPreference = collectionFolderPreferences?.sort || '_folderOrDocumentTitle';
|
|
66
|
-
const viewPreference = collectionFolderPreferences?.viewPreference || 'grid';
|
|
49
|
+
const collectionFolderPreferences = await getPreferences(`${collectionSlug}-collection-folder`, payload, user.id, user.collection);
|
|
50
|
+
const sortPreference = collectionFolderPreferences?.value.sort;
|
|
67
51
|
const {
|
|
68
52
|
routes: {
|
|
69
53
|
admin: adminRoute
|
|
70
54
|
}
|
|
71
55
|
} = config;
|
|
56
|
+
if (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility || !config.folders) {
|
|
57
|
+
throw new Error('not-found');
|
|
58
|
+
}
|
|
59
|
+
let folderWhere;
|
|
60
|
+
const folderCollectionConfig = payload.collections[config.folders.slug].config;
|
|
61
|
+
const folderCollectionConstraints = await buildFolderWhereConstraints({
|
|
62
|
+
collectionConfig: folderCollectionConfig,
|
|
63
|
+
folderID,
|
|
64
|
+
localeCode: fullLocale?.code,
|
|
65
|
+
req: initPageResult.req,
|
|
66
|
+
search: typeof query?.search === 'string' ? query.search : undefined,
|
|
67
|
+
sort: sortPreference
|
|
68
|
+
});
|
|
69
|
+
if (folderCollectionConstraints) {
|
|
70
|
+
folderWhere = folderCollectionConstraints;
|
|
71
|
+
}
|
|
72
|
+
let documentWhere;
|
|
73
|
+
const collectionConstraints = await buildFolderWhereConstraints({
|
|
74
|
+
collectionConfig,
|
|
75
|
+
folderID,
|
|
76
|
+
localeCode: fullLocale?.code,
|
|
77
|
+
req: initPageResult.req,
|
|
78
|
+
search: typeof query?.search === 'string' ? query.search : undefined,
|
|
79
|
+
sort: sortPreference
|
|
80
|
+
});
|
|
81
|
+
if (collectionConstraints) {
|
|
82
|
+
documentWhere = collectionConstraints;
|
|
83
|
+
}
|
|
72
84
|
const {
|
|
73
85
|
breadcrumbs,
|
|
74
86
|
documents,
|
|
75
|
-
FolderResultsComponent,
|
|
76
87
|
subfolders
|
|
77
|
-
} = await
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
displayAs: viewPreference,
|
|
88
|
+
} = await getFolderData({
|
|
89
|
+
collectionSlug,
|
|
90
|
+
documentWhere,
|
|
81
91
|
folderID,
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
folderWhere,
|
|
93
|
+
req: initPageResult.req
|
|
84
94
|
});
|
|
85
95
|
const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id;
|
|
86
96
|
if (!isInDrawer && (resolvedFolderID && folderID && folderID !== resolvedFolderID || folderID && !resolvedFolderID)) {
|
|
@@ -90,6 +100,11 @@ export const buildCollectionFolderView = async args => {
|
|
|
90
100
|
serverURL: config.serverURL
|
|
91
101
|
}));
|
|
92
102
|
}
|
|
103
|
+
const newDocumentURL = formatAdminURL({
|
|
104
|
+
adminRoute,
|
|
105
|
+
path: `/collections/${collectionSlug}/create`
|
|
106
|
+
});
|
|
107
|
+
const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create;
|
|
93
108
|
const serverProps = {
|
|
94
109
|
collectionConfig,
|
|
95
110
|
documents,
|
|
@@ -118,30 +133,29 @@ export const buildCollectionFolderView = async args => {
|
|
|
118
133
|
// })
|
|
119
134
|
const search = query?.search;
|
|
120
135
|
return {
|
|
121
|
-
View: /*#__PURE__*/_jsxs(
|
|
136
|
+
View: /*#__PURE__*/_jsxs(FolderProvider, {
|
|
137
|
+
breadcrumbs: breadcrumbs,
|
|
138
|
+
collectionSlug: collectionSlug,
|
|
139
|
+
documents: documents,
|
|
140
|
+
folderCollectionSlugs: [collectionSlug],
|
|
141
|
+
folderFieldName: config.folders.fieldName,
|
|
142
|
+
folderID: folderID,
|
|
143
|
+
search: search,
|
|
144
|
+
subfolders: subfolders,
|
|
122
145
|
children: [/*#__PURE__*/_jsx(HydrateAuthProvider, {
|
|
123
146
|
permissions: permissions
|
|
124
147
|
}), RenderServerComponent({
|
|
125
148
|
clientProps: {
|
|
126
149
|
// ...folderViewSlots,
|
|
127
|
-
allCollectionFolderSlugs: [config.folders.slug, collectionSlug],
|
|
128
|
-
allowCreateCollectionSlugs: [permissions?.collections?.[config.folders.slug]?.create ? config.folders.slug : null, permissions?.collections?.[collectionSlug]?.create ? collectionSlug : null].filter(Boolean),
|
|
129
|
-
baseFolderPath: `/collections/${collectionSlug}/${config.folders.slug}`,
|
|
130
|
-
breadcrumbs,
|
|
131
150
|
collectionSlug,
|
|
132
151
|
disableBulkDelete,
|
|
133
152
|
disableBulkEdit,
|
|
134
|
-
documents,
|
|
135
153
|
enableRowSelections,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
search,
|
|
140
|
-
sort: sortPreference,
|
|
141
|
-
subfolders,
|
|
142
|
-
viewPreference
|
|
154
|
+
hasCreatePermission,
|
|
155
|
+
newDocumentURL,
|
|
156
|
+
viewPreference: collectionFolderPreferences?.value?.viewPreference
|
|
143
157
|
},
|
|
144
|
-
|
|
158
|
+
Component: collectionConfig?.admin?.components?.views?.list?.Component,
|
|
145
159
|
Fallback: DefaultCollectionFolderView,
|
|
146
160
|
importMap: payload.importMap,
|
|
147
161
|
serverProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildView.js","names":["DefaultCollectionFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","React","buildCollectionFolderView","args","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","folders","Error","collections","read","includes","collectionFolderPreferences","key","value","sort","sortPreference","viewPreference","routes","admin","adminRoute","breadcrumbs","documents","FolderResultsComponent","subfolders","activeCollectionSlugs","browseByFolder","displayAs","resolvedFolderID","length","id","path","serverURL","serverProps","search","View","_jsxs","_Fragment","_jsx","clientProps","allCollectionFolderSlugs","allowCreateCollectionSlugs","create","filter","Boolean","baseFolderPath","folderFieldName","fieldName","Fallback","importMap"],"sources":["../../../src/views/CollectionFolders/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewClientProps,\n FolderListViewServerPropsOnly,\n FolderSortKeys,\n ListQuery,\n} from 'payload'\n\nimport { DefaultCollectionFolderView, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getFolderResultsComponentAndData, upsertPreferences } from '@payloadcms/ui/rsc'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport React from 'react'\n\n// import { renderFolderViewSlots } from './renderFolderViewSlots.js'\n\nexport type BuildCollectionFolderViewStateArgs = {\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\n/**\n * Builds the entire view for collection-folder views on the server\n */\nexport const buildCollectionFolderView = async (\n args: BuildCollectionFolderViewStateArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!config.folders) {\n throw new Error('not-found')\n }\n\n if (\n !permissions?.collections?.[collectionSlug]?.read ||\n !permissions?.collections?.[config.folders.slug].read\n ) {\n throw new Error('not-found')\n }\n\n if (collectionConfig) {\n if (\n (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) ||\n !config.folders\n ) {\n throw new Error('not-found')\n }\n\n const query = queryFromArgs || queryFromReq\n\n /**\n * @todo: find a pattern to avoid setting preferences on hard navigation, i.e. direct links, page refresh, etc.\n * This will ensure that prefs are only updated when explicitly set by the user\n * This could potentially be done by injecting a `sessionID` into the params and comparing it against a session cookie\n */\n const collectionFolderPreferences = await upsertPreferences<{\n sort?: FolderSortKeys\n viewPreference?: 'grid' | 'list'\n }>({\n key: `${collectionSlug}-collection-folder`,\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys =\n collectionFolderPreferences?.sort || '_folderOrDocumentTitle'\n const viewPreference = collectionFolderPreferences?.viewPreference || 'grid'\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const { breadcrumbs, documents, FolderResultsComponent, subfolders } =\n await getFolderResultsComponentAndData({\n activeCollectionSlugs: [config.folders.slug, collectionSlug],\n browseByFolder: false,\n displayAs: viewPreference,\n folderID,\n req: initPageResult.req,\n sort: sortPreference,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${config.folders.slug}`,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const serverProps: FolderListViewServerPropsOnly = {\n collectionConfig,\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // We could support slots in the folder view in the future\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // collectionSlug,\n // hasCreatePermission,\n // newDocumentURL,\n // },\n // collectionConfig,\n // description: typeof collectionConfig.admin.description === 'function'\n // ? collectionConfig.admin.description({ t: i18n.t })\n // : collectionConfig.admin.description,\n // payload,\n // serverProps,\n // })\n\n const search = query?.search as string\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n allCollectionFolderSlugs: [config.folders.slug, collectionSlug],\n allowCreateCollectionSlugs: [\n permissions?.collections?.[config.folders.slug]?.create\n ? config.folders.slug\n : null,\n permissions?.collections?.[collectionSlug]?.create ? collectionSlug : null,\n ].filter(Boolean),\n baseFolderPath: `/collections/${collectionSlug}/${config.folders.slug}`,\n breadcrumbs,\n collectionSlug,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderFieldName: config.folders.fieldName,\n folderID: resolvedFolderID || null,\n FolderResultsComponent,\n search,\n sort: sortPreference,\n subfolders,\n viewPreference,\n } satisfies FolderListViewClientProps,\n // Component: collectionConfig?.admin?.components?.views?.Folders?.Component,\n Fallback: DefaultCollectionFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n"],"mappings":";AASA,SAAS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;MACA+B,UAAA;MACAnB;IACF;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA,MAAM6B,MAAA,GAAS3C,KAAA,EAAO2C,MAAA;IAEtB,OAAO;MACLC,IAAA,eACEC,KAAA,CAAAC,SAAA;gCACEC,IAAA,CAAChE,mBAAA;UAAoByB,WAAA,EAAaA;YACjCxB,qBAAA,CAAsB;UACrBgE,WAAA,EAAa;YACX;YACAC,wBAAA,EAA0B,CAACrC,MAAA,CAAOI,OAAO,CAACZ,IAAI,EAAEC,cAAA,CAAe;YAC/D6C,0BAAA,EAA4B,CAC1B1C,WAAA,EAAaU,WAAA,GAAcN,MAAA,CAAOI,OAAO,CAACZ,IAAI,CAAC,EAAE+C,MAAA,GAC7CvC,MAAA,CAAOI,OAAO,CAACZ,IAAI,GACnB,MACJI,WAAA,EAAaU,WAAA,GAAcb,cAAA,CAAe,EAAE8C,MAAA,GAAS9C,cAAA,GAAiB,KACvE,CAAC+C,MAAM,CAACC,OAAA;YACTC,cAAA,EAAgB,gBAAgBjD,cAAA,IAAkBO,MAAA,CAAOI,OAAO,CAACZ,IAAI,EAAE;YACvE0B,WAAA;YACAzB,cAAA;YACAb,iBAAA;YACAC,eAAA;YACAsC,SAAA;YACArC,mBAAA;YACA6D,eAAA,EAAiB3C,MAAA,CAAOI,OAAO,CAACwC,SAAS;YACzC7D,QAAA,EAAU0C,gBAAA,IAAoB;YAC9BL,sBAAA;YACAW,MAAA;YACAnB,IAAA,EAAMC,cAAA;YACNQ,UAAA;YACAP;UACF;UACA;UACA+B,QAAA,EAAU3E,2BAAA;UACV4E,SAAA,EAAW/C,OAAA,CAAQ+C,SAAS;UAC5BhB;QACF;;IAGN;EACF;EAEA,MAAM,IAAIzB,KAAA,CAAM;AAClB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildView.js","names":["DefaultCollectionFolderView","FolderProvider","HydrateAuthProvider","RenderServerComponent","formatAdminURL","redirect","getFolderData","buildFolderWhereConstraints","React","getPreferences","buildCollectionFolderView","args","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","overrideEntityVisibility","params","query","queryFromArgs","searchParams","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","user","visibleEntities","collections","read","Error","collectionFolderPreferences","id","collection","sortPreference","value","sort","routes","admin","adminRoute","includes","folders","folderWhere","folderCollectionConfig","folderCollectionConstraints","localeCode","code","search","undefined","documentWhere","collectionConstraints","breadcrumbs","documents","subfolders","resolvedFolderID","length","path","serverURL","newDocumentURL","hasCreatePermission","create","serverProps","View","_jsxs","folderCollectionSlugs","folderFieldName","fieldName","_jsx","clientProps","viewPreference","Component","components","views","list","Fallback","importMap"],"sources":["../../../src/views/CollectionFolders/buildView.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n BuildCollectionFolderViewResult,\n FolderListViewServerPropsOnly,\n ListQuery,\n Where,\n} from 'payload'\n\nimport { DefaultCollectionFolderView, FolderProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { redirect } from 'next/navigation.js'\nimport { getFolderData } from 'payload'\nimport { buildFolderWhereConstraints } from 'payload/shared'\nimport React from 'react'\n\nimport { getPreferences } from '../../utilities/getPreferences.js'\n\n// import { renderFolderViewSlots } from './renderFolderViewSlots.js'\n\nexport type BuildCollectionFolderViewStateArgs = {\n disableBulkDelete?: boolean\n disableBulkEdit?: boolean\n enableRowSelections: boolean\n folderID?: number | string\n isInDrawer?: boolean\n overrideEntityVisibility?: boolean\n query: ListQuery\n} & AdminViewServerProps\n\n/**\n * Builds the entire view for collection-folder views on the server\n */\nexport const buildCollectionFolderView = async (\n args: BuildCollectionFolderViewStateArgs,\n): Promise<BuildCollectionFolderViewResult> => {\n const {\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n folderID,\n initPageResult,\n isInDrawer,\n overrideEntityVisibility,\n params,\n query: queryFromArgs,\n searchParams,\n } = args\n\n const {\n collectionConfig,\n collectionConfig: { slug: collectionSlug },\n locale: fullLocale,\n permissions,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n if (!permissions?.collections?.[collectionSlug]?.read) {\n throw new Error('not-found')\n }\n\n if (collectionConfig) {\n const query = queryFromArgs || queryFromReq\n\n const collectionFolderPreferences = await getPreferences<{\n sort?: string\n viewPreference: string\n }>(`${collectionSlug}-collection-folder`, payload, user.id, user.collection)\n\n const sortPreference = collectionFolderPreferences?.value.sort\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n if (\n (!visibleEntities.collections.includes(collectionSlug) && !overrideEntityVisibility) ||\n !config.folders\n ) {\n throw new Error('not-found')\n }\n\n let folderWhere: undefined | Where\n const folderCollectionConfig = payload.collections[config.folders.slug].config\n const folderCollectionConstraints = await buildFolderWhereConstraints({\n collectionConfig: folderCollectionConfig,\n folderID,\n localeCode: fullLocale?.code,\n req: initPageResult.req,\n search: typeof query?.search === 'string' ? query.search : undefined,\n sort: sortPreference,\n })\n\n if (folderCollectionConstraints) {\n folderWhere = folderCollectionConstraints\n }\n\n let documentWhere: undefined | Where\n const collectionConstraints = await buildFolderWhereConstraints({\n collectionConfig,\n folderID,\n localeCode: fullLocale?.code,\n req: initPageResult.req,\n search: typeof query?.search === 'string' ? query.search : undefined,\n sort: sortPreference,\n })\n if (collectionConstraints) {\n documentWhere = collectionConstraints\n }\n\n const { breadcrumbs, documents, subfolders } = await getFolderData({\n collectionSlug,\n documentWhere,\n folderID,\n folderWhere,\n req: initPageResult.req,\n })\n\n const resolvedFolderID = breadcrumbs[breadcrumbs.length - 1]?.id\n\n if (\n !isInDrawer &&\n ((resolvedFolderID && folderID && folderID !== resolvedFolderID) ||\n (folderID && !resolvedFolderID))\n ) {\n redirect(\n formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${config.folders.slug}`,\n serverURL: config.serverURL,\n }),\n )\n }\n\n const newDocumentURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/create`,\n })\n\n const hasCreatePermission = permissions?.collections?.[collectionSlug]?.create\n\n const serverProps: FolderListViewServerPropsOnly = {\n collectionConfig,\n documents,\n i18n,\n locale: fullLocale,\n params,\n payload,\n permissions,\n searchParams,\n subfolders,\n user,\n }\n\n // We could support slots in the folder view in the future\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // collectionSlug,\n // hasCreatePermission,\n // newDocumentURL,\n // },\n // collectionConfig,\n // description: typeof collectionConfig.admin.description === 'function'\n // ? collectionConfig.admin.description({ t: i18n.t })\n // : collectionConfig.admin.description,\n // payload,\n // serverProps,\n // })\n\n const search = query?.search as string\n\n return {\n View: (\n <FolderProvider\n breadcrumbs={breadcrumbs}\n collectionSlug={collectionSlug}\n documents={documents}\n folderCollectionSlugs={[collectionSlug]}\n folderFieldName={config.folders.fieldName}\n folderID={folderID}\n search={search}\n subfolders={subfolders}\n >\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n collectionSlug,\n disableBulkDelete,\n disableBulkEdit,\n enableRowSelections,\n hasCreatePermission,\n newDocumentURL,\n viewPreference: collectionFolderPreferences?.value?.viewPreference,\n },\n Component: collectionConfig?.admin?.components?.views?.list?.Component,\n Fallback: DefaultCollectionFolderView,\n importMap: payload.importMap,\n serverProps,\n })}\n </FolderProvider>\n ),\n }\n }\n\n throw new Error('not-found')\n}\n"],"mappings":";AAQA,SAASA,2BAA2B,EAAEC,cAAc,EAAEC,mBAAmB,QAAQ;AACjF,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,2BAA2B,QAAQ;AAC5C,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ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H,SAAA;UAC7DI,QAAA,EAAUlF,2BAAA;UACVmF,SAAA,EAAWpD,OAAA,CAAQoD,SAAS;UAC5Bd;QACF;;IAGN;EACF;EAEA,MAAM,IAAI/B,KAAA,CAAM;AAClB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMetaBySegment.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getMetaBySegment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAW5D,MAAM,MAAM,wBAAwB,GAAG,CACrC,IAAI,EAAE;IACJ,gBAAgB,CAAC,EAAE,IAAI,GAAG,yBAAyB,CAAA;IACnD,YAAY,CAAC,EAAE,IAAI,GAAG,qBAAqB,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,UAAU,CAAA;CACxB,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KACpC,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"getMetaBySegment.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getMetaBySegment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAW5D,MAAM,MAAM,wBAAwB,GAAG,CACrC,IAAI,EAAE;IACJ,gBAAgB,CAAC,EAAE,IAAI,GAAG,yBAAyB,CAAA;IACnD,YAAY,CAAC,EAAE,IAAI,GAAG,qBAAqB,CAAA;IAC3C,IAAI,CAAC,EAAE,MAAM,UAAU,CAAA;CACxB,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KACpC,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB,eAAO,MAAM,gBAAgB,EAAE,wBAgI9B,CAAA"}
|
|
@@ -5,7 +5,7 @@ import { generateLivePreviewViewMetadata } from '../LivePreview/metadata.js';
|
|
|
5
5
|
import { generateNotFoundViewMetadata } from '../NotFound/metadata.js';
|
|
6
6
|
import { generateVersionViewMetadata } from '../Version/metadata.js';
|
|
7
7
|
import { generateVersionsViewMetadata } from '../Versions/metadata.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getViewsFromConfig } from './getViewsFromConfig.js';
|
|
9
9
|
export const getMetaBySegment = async ({
|
|
10
10
|
collectionConfig,
|
|
11
11
|
config,
|
|
@@ -99,18 +99,11 @@ export const getMetaBySegment = async ({
|
|
|
99
99
|
} else {
|
|
100
100
|
const {
|
|
101
101
|
viewKey
|
|
102
|
-
} =
|
|
102
|
+
} = getViewsFromConfig({
|
|
103
103
|
collectionConfig,
|
|
104
104
|
config,
|
|
105
|
-
docPermissions: {
|
|
106
|
-
create: true,
|
|
107
|
-
delete: true,
|
|
108
|
-
fields: true,
|
|
109
|
-
read: true,
|
|
110
|
-
readVersions: true,
|
|
111
|
-
update: true
|
|
112
|
-
},
|
|
113
105
|
globalConfig,
|
|
106
|
+
overrideDocPermissions: true,
|
|
114
107
|
routeSegments: typeof segments === 'string' ? [segments] : segments
|
|
115
108
|
});
|
|
116
109
|
if (viewKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMetaBySegment.js","names":["getNextRequestI18n","generateAPIViewMetadata","generateEditViewMetadata","generateLivePreviewViewMetadata","generateNotFoundViewMetadata","generateVersionViewMetadata","generateVersionsViewMetadata","
|
|
1
|
+
{"version":3,"file":"getMetaBySegment.js","names":["getNextRequestI18n","generateAPIViewMetadata","generateEditViewMetadata","generateLivePreviewViewMetadata","generateNotFoundViewMetadata","generateVersionViewMetadata","generateVersionsViewMetadata","getViewsFromConfig","getMetaBySegment","collectionConfig","config","globalConfig","params","segments","fn","segmentOne","isCollection","isGlobal","isEditing","Boolean","length","i18n","viewKey","overrideDocPermissions","routeSegments","customViewConfig","admin","components","views","edit","view"],"sources":["../../../src/views/Document/getMetaBySegment.tsx"],"sourcesContent":["import type { Metadata } from 'next'\nimport type { EditConfig, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport type { GenerateViewMetadata } from '../Root/index.js'\n\nimport { getNextRequestI18n } from '../../utilities/getNextRequestI18n.js'\nimport { generateAPIViewMetadata } from '../API/metadata.js'\nimport { generateEditViewMetadata } from '../Edit/metadata.js'\nimport { generateLivePreviewViewMetadata } from '../LivePreview/metadata.js'\nimport { generateNotFoundViewMetadata } from '../NotFound/metadata.js'\nimport { generateVersionViewMetadata } from '../Version/metadata.js'\nimport { generateVersionsViewMetadata } from '../Versions/metadata.js'\nimport { getViewsFromConfig } from './getViewsFromConfig.js'\n\nexport type GenerateEditViewMetadata = (\n args: {\n collectionConfig?: null | SanitizedCollectionConfig\n globalConfig?: null | SanitizedGlobalConfig\n view?: keyof EditConfig\n } & Parameters<GenerateViewMetadata>[0],\n) => Promise<Metadata>\n\nexport const getMetaBySegment: GenerateEditViewMetadata = async ({\n collectionConfig,\n config,\n globalConfig,\n params,\n}) => {\n const { segments } = params\n\n let fn: GenerateEditViewMetadata | null = null\n\n const [segmentOne] = segments\n const isCollection = segmentOne === 'collections'\n const isGlobal = segmentOne === 'globals'\n\n const isEditing =\n isGlobal || Boolean(isCollection && segments?.length > 2 && segments[2] !== 'create')\n\n if (isCollection) {\n // `/:collection/:id`\n if (params.segments.length === 3) {\n fn = generateEditViewMetadata\n }\n\n // `/:collection/:id/:view`\n if (params.segments.length === 4) {\n switch (params.segments[3]) {\n case 'api':\n // `/:collection/:id/api`\n fn = generateAPIViewMetadata\n break\n case 'preview':\n // `/:collection/:id/preview`\n fn = generateLivePreviewViewMetadata\n break\n case 'versions':\n // `/:collection/:id/versions`\n fn = generateVersionsViewMetadata\n break\n default:\n break\n }\n }\n\n // `/:collection/:id/:slug-1/:slug-2`\n if (params.segments.length === 5) {\n switch (params.segments[3]) {\n case 'versions':\n // `/:collection/:id/versions/:version`\n fn = generateVersionViewMetadata\n break\n default:\n break\n }\n }\n }\n\n if (isGlobal) {\n // `/:global`\n if (params.segments?.length === 2) {\n fn = generateEditViewMetadata\n }\n\n // `/:global/:view`\n if (params.segments?.length === 3) {\n switch (params.segments[2]) {\n case 'api':\n // `/:global/api`\n fn = generateAPIViewMetadata\n break\n case 'preview':\n // `/:global/preview`\n fn = generateLivePreviewViewMetadata\n break\n case 'versions':\n // `/:global/versions`\n fn = generateVersionsViewMetadata\n break\n default:\n break\n }\n }\n\n // `/:global/versions/:version`\n if (params.segments?.length === 4 && params.segments[2] === 'versions') {\n fn = generateVersionViewMetadata\n }\n }\n\n const i18n = await getNextRequestI18n({\n config,\n })\n\n if (typeof fn === 'function') {\n return fn({\n collectionConfig,\n config,\n globalConfig,\n i18n,\n isEditing,\n })\n } else {\n const { viewKey } = getViewsFromConfig({\n collectionConfig,\n config,\n globalConfig,\n overrideDocPermissions: true,\n routeSegments: typeof segments === 'string' ? [segments] : segments,\n })\n\n if (viewKey) {\n const customViewConfig =\n collectionConfig?.admin?.components?.views?.edit?.[viewKey] ||\n globalConfig?.admin?.components?.views?.edit?.[viewKey]\n\n if (customViewConfig) {\n return generateEditViewMetadata({\n collectionConfig,\n config,\n globalConfig,\n i18n,\n isEditing,\n view: viewKey as keyof EditConfig,\n })\n }\n }\n }\n\n return generateNotFoundViewMetadata({ config, i18n })\n}\n"],"mappings":"AAKA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,+BAA+B,QAAQ;AAChD,SAASC,4BAA4B,QAAQ;AAC7C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
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AdminViewServerProps, DocumentViewServerProps, PayloadComponent, SanitizedCollectionConfig, SanitizedCollectionPermission, SanitizedConfig, SanitizedGlobalConfig, SanitizedGlobalPermission } from 'payload';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
export type ViewFromConfig<TProps extends object> = {
|
|
4
|
+
Component?: React.FC<TProps>;
|
|
5
|
+
ComponentConfig?: PayloadComponent<TProps>;
|
|
6
|
+
};
|
|
7
|
+
export declare const getViewsFromConfig: ({ collectionConfig, config, docPermissions, globalConfig, overrideDocPermissions, routeSegments, }: {
|
|
8
|
+
collectionConfig?: SanitizedCollectionConfig;
|
|
9
|
+
config: SanitizedConfig;
|
|
10
|
+
globalConfig?: SanitizedGlobalConfig;
|
|
11
|
+
routeSegments: string[];
|
|
12
|
+
} & ({
|
|
13
|
+
docPermissions: SanitizedCollectionPermission | SanitizedGlobalPermission;
|
|
14
|
+
overrideDocPermissions?: false | undefined;
|
|
15
|
+
} | {
|
|
16
|
+
docPermissions?: never;
|
|
17
|
+
overrideDocPermissions: true;
|
|
18
|
+
})) => {
|
|
19
|
+
CustomView: ViewFromConfig<DocumentViewServerProps>;
|
|
20
|
+
DefaultView: ViewFromConfig<DocumentViewServerProps>;
|
|
21
|
+
/**
|
|
22
|
+
* The error view to display if CustomView or DefaultView do not exist (could be either due to not found, or unauthorized). Can be null
|
|
23
|
+
*/
|
|
24
|
+
ErrorView: ViewFromConfig<AdminViewServerProps>;
|
|
25
|
+
viewKey: string;
|
|
26
|
+
} | null;
|
|
27
|
+
//# sourceMappingURL=getViewsFromConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getViewsFromConfig.d.ts","sourceRoot":"","sources":["../../../src/views/Document/getViewsFromConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAC7B,eAAe,EACf,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,MAAM,IAAI;IAClD,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;IAC5B,eAAe,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,kBAAkB,uGAO5B;IACD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB,GAAG,CACA;IACE,cAAc,EAAE,6BAA6B,GAAG,yBAAyB,CAAA;IACzE,sBAAsB,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAC3C,GACD;IACE,cAAc,CAAC,EAAE,KAAK,CAAA;IACtB,sBAAsB,EAAE,IAAI,CAAA;CAC7B,CACJ,KAAG;IACF,UAAU,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAA;IACnD,WAAW,EAAE,cAAc,CAAC,uBAAuB,CAAC,CAAA;IACpD;;OAEG;IACH,SAAS,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAA;IAC/C,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,IAsXH,CAAA"}
|