@payloadcms/next 3.55.0-internal.f8c92b5 → 3.56.0-internal.299316b
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/auth/refresh.js +8 -8
- package/dist/auth/refresh.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +41 -19
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
- package/dist/elements/Nav/index.client.js +48 -28
- package/dist/elements/Nav/index.client.js.map +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +2 -1
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/utilities/getRouteWithoutAdmin.d.ts +5 -0
- package/dist/utilities/getRouteWithoutAdmin.d.ts.map +1 -0
- package/dist/utilities/getRouteWithoutAdmin.js +7 -0
- package/dist/utilities/getRouteWithoutAdmin.js.map +1 -0
- package/dist/utilities/getVisibleEntities.d.ts +5 -0
- package/dist/utilities/getVisibleEntities.d.ts.map +1 -0
- package/dist/utilities/getVisibleEntities.js +26 -0
- package/dist/utilities/getVisibleEntities.js.map +1 -0
- package/dist/utilities/handleAuthRedirect.d.ts.map +1 -0
- package/dist/utilities/handleAuthRedirect.js.map +1 -0
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +2 -7
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/isCustomAdminView.d.ts.map +1 -0
- package/dist/utilities/{initPage/isCustomAdminView.js → isCustomAdminView.js} +1 -1
- package/dist/utilities/isCustomAdminView.js.map +1 -0
- package/dist/utilities/isPublicAdminRoute.d.ts +7 -0
- package/dist/utilities/isPublicAdminRoute.d.ts.map +1 -0
- package/dist/utilities/{initPage/shared.js → isPublicAdminRoute.js} +2 -13
- package/dist/utilities/isPublicAdminRoute.js.map +1 -0
- package/dist/views/CollectionFolders/buildView.d.ts.map +1 -1
- package/dist/views/CollectionFolders/buildView.js +1 -1
- package/dist/views/CollectionFolders/buildView.js.map +1 -1
- package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.js +16 -11
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +2 -1
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/List/handleGroupBy.d.ts +4 -2
- package/dist/views/List/handleGroupBy.d.ts.map +1 -1
- package/dist/views/List/handleGroupBy.js +3 -1
- package/dist/views/List/handleGroupBy.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +2 -1
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +17 -4
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/transformColumnsToSelect.d.ts +3 -0
- package/dist/views/List/transformColumnsToSelect.d.ts.map +1 -0
- package/dist/views/List/transformColumnsToSelect.js +7 -0
- package/dist/views/List/transformColumnsToSelect.js.map +1 -0
- package/dist/views/Logout/LogoutClient.js +31 -29
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/NotFound/index.d.ts +0 -8
- package/dist/views/NotFound/index.d.ts.map +1 -1
- package/dist/views/NotFound/index.js +40 -18
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/Root/SyncClientConfig.d.ts +11 -0
- package/dist/views/Root/SyncClientConfig.d.ts.map +1 -0
- package/dist/views/Root/SyncClientConfig.js +38 -0
- package/dist/views/Root/SyncClientConfig.js.map +1 -0
- package/dist/views/Root/attachViewActions.d.ts +4 -5
- package/dist/views/Root/attachViewActions.d.ts.map +1 -1
- package/dist/views/Root/attachViewActions.js +5 -7
- package/dist/views/Root/attachViewActions.js.map +1 -1
- package/dist/views/Root/getRouteData.d.ts +33 -16
- package/dist/views/Root/getRouteData.d.ts.map +1 -1
- package/dist/views/Root/getRouteData.js +122 -103
- package/dist/views/Root/getRouteData.js.map +1 -1
- package/dist/views/Root/index.d.ts +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +173 -78
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Version/Default/SetStepNav.d.ts +0 -1
- package/dist/views/Version/Default/SetStepNav.d.ts.map +1 -1
- package/dist/views/Version/Default/SetStepNav.js +28 -38
- package/dist/views/Version/Default/SetStepNav.js.map +1 -1
- package/dist/views/Version/Default/index.d.ts.map +1 -1
- package/dist/views/Version/Default/index.js +2 -4
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/Default/types.d.ts +0 -1
- package/dist/views/Version/Default/types.d.ts.map +1 -1
- package/dist/views/Version/Default/types.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +28 -12
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts +3 -5
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +59 -37
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js +27 -17
- package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js +31 -21
- package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +33 -23
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.d.ts +2 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js +7 -4
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts +5 -5
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +30 -21
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.d.ts +6 -4
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js +15 -6
- package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js +50 -16
- package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js.map +1 -1
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js +12 -8
- package/dist/views/Version/SelectComparison/VersionDrawer/index.js.map +1 -1
- package/dist/views/Version/index.d.ts.map +1 -1
- package/dist/views/Version/index.js +4 -6
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.d.ts +1 -0
- package/dist/views/Versions/cells/AutosaveCell/index.d.ts.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js +23 -14
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js +53 -27
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/package.json +9 -9
- package/dist/utilities/initPage/handleAdminPage.d.ts +0 -18
- package/dist/utilities/initPage/handleAdminPage.d.ts.map +0 -1
- package/dist/utilities/initPage/handleAdminPage.js +0 -57
- package/dist/utilities/initPage/handleAdminPage.js.map +0 -1
- package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +0 -1
- package/dist/utilities/initPage/handleAuthRedirect.js.map +0 -1
- package/dist/utilities/initPage/index.d.ts +0 -4
- package/dist/utilities/initPage/index.d.ts.map +0 -1
- package/dist/utilities/initPage/index.js +0 -127
- package/dist/utilities/initPage/index.js.map +0 -1
- package/dist/utilities/initPage/isCustomAdminView.d.ts.map +0 -1
- package/dist/utilities/initPage/isCustomAdminView.js.map +0 -1
- package/dist/utilities/initPage/shared.d.ts +0 -16
- package/dist/utilities/initPage/shared.d.ts.map +0 -1
- package/dist/utilities/initPage/shared.js.map +0 -1
- package/dist/utilities/initPage/types.d.ts +0 -44
- package/dist/utilities/initPage/types.d.ts.map +0 -1
- package/dist/utilities/initPage/types.js +0 -2
- package/dist/utilities/initPage/types.js.map +0 -1
- /package/dist/utilities/{initPage/handleAuthRedirect.d.ts → handleAuthRedirect.d.ts} +0 -0
- /package/dist/utilities/{initPage/handleAuthRedirect.js → handleAuthRedirect.js} +0 -0
- /package/dist/utilities/{initPage/isCustomAdminView.d.ts → isCustomAdminView.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRouteWithoutAdmin.d.ts","sourceRoot":"","sources":["../../src/utilities/getRouteWithoutAdmin.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,2BAG9B;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd,KAAG,MAEH,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRouteWithoutAdmin.js","names":["getRouteWithoutAdmin","adminRoute","route","replace"],"sources":["../../src/utilities/getRouteWithoutAdmin.ts"],"sourcesContent":["export const getRouteWithoutAdmin = ({\n adminRoute,\n route,\n}: {\n adminRoute: string\n route: string\n}): string => {\n return adminRoute && adminRoute !== '/' ? route.replace(adminRoute, '') : route\n}\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAA,GAAuBA,CAAC;EACnCC,UAAU;EACVC;AAAK,CAIN;EACC,OAAOD,UAAA,IAAcA,UAAA,KAAe,MAAMC,KAAA,CAAMC,OAAO,CAACF,UAAA,EAAY,MAAMC,KAAA;AAC5E","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getVisibleEntities.d.ts","sourceRoot":"","sources":["../../src/utilities/getVisibleEntities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9D,wBAAgB,kBAAkB,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,GAAG,eAAe,CAapF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isEntityHidden } from 'payload';
|
|
2
|
+
export function getVisibleEntities({
|
|
3
|
+
req
|
|
4
|
+
}) {
|
|
5
|
+
return {
|
|
6
|
+
collections: req.payload.config.collections.map(({
|
|
7
|
+
slug,
|
|
8
|
+
admin: {
|
|
9
|
+
hidden
|
|
10
|
+
}
|
|
11
|
+
}) => !isEntityHidden({
|
|
12
|
+
hidden,
|
|
13
|
+
user: req.user
|
|
14
|
+
}) ? slug : null).filter(Boolean),
|
|
15
|
+
globals: req.payload.config.globals.map(({
|
|
16
|
+
slug,
|
|
17
|
+
admin: {
|
|
18
|
+
hidden
|
|
19
|
+
}
|
|
20
|
+
}) => !isEntityHidden({
|
|
21
|
+
hidden,
|
|
22
|
+
user: req.user
|
|
23
|
+
}) ? slug : null).filter(Boolean)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=getVisibleEntities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getVisibleEntities.js","names":["isEntityHidden","getVisibleEntities","req","collections","payload","config","map","slug","admin","hidden","user","filter","Boolean","globals"],"sources":["../../src/utilities/getVisibleEntities.ts"],"sourcesContent":["import type { PayloadRequest, VisibleEntities } from 'payload'\n\nimport { isEntityHidden } from 'payload'\n\nexport function getVisibleEntities({ req }: { req: PayloadRequest }): VisibleEntities {\n return {\n collections: req.payload.config.collections\n .map(({ slug, admin: { hidden } }) =>\n !isEntityHidden({ hidden, user: req.user }) ? slug : null,\n )\n .filter(Boolean),\n globals: req.payload.config.globals\n .map(({ slug, admin: { hidden } }) =>\n !isEntityHidden({ hidden, user: req.user }) ? slug : null,\n )\n .filter(Boolean),\n }\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAE/B,OAAO,SAASC,mBAAmB;EAAEC;AAAG,CAA2B;EACjE,OAAO;IACLC,WAAA,EAAaD,GAAA,CAAIE,OAAO,CAACC,MAAM,CAACF,WAAW,CACxCG,GAAG,CAAC,CAAC;MAAEC,IAAI;MAAEC,KAAA,EAAO;QAAEC;MAAM;IAAE,CAAE,KAC/B,CAACT,cAAA,CAAe;MAAES,MAAA;MAAQC,IAAA,EAAMR,GAAA,CAAIQ;IAAK,KAAKH,IAAA,GAAO,MAEtDI,MAAM,CAACC,OAAA;IACVC,OAAA,EAASX,GAAA,CAAIE,OAAO,CAACC,MAAM,CAACQ,OAAO,CAChCP,GAAG,CAAC,CAAC;MAAEC,IAAI;MAAEC,KAAA,EAAO;QAAEC;MAAM;IAAE,CAAE,KAC/B,CAACT,cAAA,CAAe;MAAES,MAAA;MAAQC,IAAA,EAAMR,GAAA,CAAIQ;IAAK,KAAKH,IAAA,GAAO,MAEtDI,MAAM,CAACC,OAAA;EACZ;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAuthRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAuthRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,KAAK,IAAI,GAAG;IACV,MAAM,MAAA;IACN,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;IAClD,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,kBAAkB,0CAA2C,IAAI,KAAG,MAkChF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAuthRedirect.js","names":["formatAdminURL","qs","handleAuthRedirect","config","route","searchParams","user","admin","routes","login","loginRouteFromConfig","unauthorized","unauthorizedRoute","adminRoute","redirect","redirectRoute","Object","keys","length","stringify","addQueryPrefix","redirectTo","path","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"sources":["../../src/utilities/handleAuthRedirect.ts"],"sourcesContent":["import type { TypedUser } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\n\ntype Args = {\n config\n route: string\n searchParams: { [key: string]: string | string[] }\n user?: TypedUser\n}\n\nexport const handleAuthRedirect = ({ config, route, searchParams, user }: Args): string => {\n const {\n admin: {\n routes: { login: loginRouteFromConfig, unauthorized: unauthorizedRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (searchParams && 'redirect' in searchParams) {\n delete searchParams.redirect\n }\n\n const redirectRoute =\n (route !== adminRoute ? route : '') +\n (Object.keys(searchParams ?? {}).length > 0\n ? `${qs.stringify(searchParams, { addQueryPrefix: true })}`\n : '')\n\n const redirectTo = formatAdminURL({\n adminRoute,\n path: user ? unauthorizedRoute : loginRouteFromConfig,\n })\n\n const parsedLoginRouteSearchParams = qs.parse(redirectTo.split('?')[1] ?? '')\n\n const searchParamsWithRedirect = `${qs.stringify(\n {\n ...parsedLoginRouteSearchParams,\n ...(redirectRoute ? { redirect: redirectRoute } : {}),\n },\n { addQueryPrefix: true },\n )}`\n\n return `${redirectTo.split('?')[0]}${searchParamsWithRedirect}`\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,Y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":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAwBpE,eAAO,MAAM,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAwBpE,eAAO,MAAM,qBAAqB,EAAE,qBAsBnC,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { renderDocumentHandler } from '../views/Document/handleServerFunction.js
|
|
|
7
7
|
import { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js';
|
|
8
8
|
import { renderListHandler } from '../views/List/handleServerFunction.js';
|
|
9
9
|
import { initReq } from './initReq.js';
|
|
10
|
-
const
|
|
10
|
+
const serverFunctions = {
|
|
11
11
|
'copy-data-from-locale': copyDataFromLocaleHandler,
|
|
12
12
|
'form-state': buildFormStateHandler,
|
|
13
13
|
'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,
|
|
@@ -22,8 +22,7 @@ export const handleServerFunctions = async args => {
|
|
|
22
22
|
name: fnKey,
|
|
23
23
|
args: fnArgs,
|
|
24
24
|
config: configPromise,
|
|
25
|
-
importMap
|
|
26
|
-
serverFunctions: extraServerFunctions
|
|
25
|
+
importMap
|
|
27
26
|
} = args;
|
|
28
27
|
const {
|
|
29
28
|
req
|
|
@@ -37,10 +36,6 @@ export const handleServerFunctions = async args => {
|
|
|
37
36
|
importMap,
|
|
38
37
|
req
|
|
39
38
|
};
|
|
40
|
-
const serverFunctions = {
|
|
41
|
-
...baseServerFunctions,
|
|
42
|
-
...(extraServerFunctions || {})
|
|
43
|
-
};
|
|
44
39
|
const fn = serverFunctions[fnKey];
|
|
45
40
|
if (!fn) {
|
|
46
41
|
throw new Error(`Unknown Server Function: ${fnKey}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.js","names":["copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.js","names":["copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","serverFunctions","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","req","key","augmentedArgs","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 { getFolderResultsComponentAndDataHandler } from '@payloadcms/ui/utilities/getFolderResultsComponentAndData'\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\nconst serverFunctions: Record<string, ServerFunction> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,\n 'render-document': renderDocumentHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-list': renderListHandler,\n 'schedule-publish': schedulePublishHandler,\n 'table-state': buildTableStateHandler,\n}\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 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,uCAAuC,QAAQ;AACxD,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,iBAAiB,QAAQ;AAClC,SAASC,OAAO,QAAQ;AAExB,MAAMC,eAAA,GAAkD;EACtD,yBAAyBT,yBAAA;EACzB,cAAcC,qBAAA;EACd,yCAAyCE,uCAAA;EACzC,mBAAmBE,qBAAA;EACnB,yBAAyBC,0BAAA;EACzB,eAAeC,iBAAA;EACf,oBAAoBH,sBAAA;EACpB,eAAeF;AACjB;AAEA,OAAO,MAAMQ,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,MAAMV,OAAA,CAAQ;IAC5BQ,aAAA;IACAC,SAAA;IACAE,GAAA,EAAK;EACP;EAEA,MAAMC,aAAA,GAA+C;IACnD,GAAGN,MAAM;IACTG,SAAA;IACAC;EACF;EAEA,MAAMG,EAAA,GAAKZ,eAAe,CAACI,KAAA,CAAM;EAEjC,IAAI,CAACQ,EAAA,EAAI;IACP,MAAM,IAAIC,KAAA,CAAM,4BAA4BT,KAAA,EAAO;EACrD;EAEA,OAAOQ,EAAA,CAAGD,aAAA;AACZ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCustomAdminView.d.ts","sourceRoot":"","sources":["../../src/utilities/isCustomAdminView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;GAEG;AACH,eAAO,MAAM,iBAAiB,mCAI3B;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;CACd,KAAG,OAmBH,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCustomAdminView.js","names":["getRouteWithoutAdmin","isCustomAdminView","adminRoute","config","route","admin","components","views","isPublicAdminRoute","Object","entries","some","_","view","routeWithoutAdmin","exact","path","startsWith"],"sources":["../../src/utilities/isCustomAdminView.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { getRouteWithoutAdmin } from './getRouteWithoutAdmin.js'\n\n/**\n * Returns an array of views marked with 'public: true' in the config\n */\nexport const isCustomAdminView = ({\n adminRoute,\n config,\n route,\n}: {\n adminRoute: string\n config: SanitizedConfig\n route: string\n}): boolean => {\n if (config.admin?.components?.views) {\n const isPublicAdminRoute = Object.entries(config.admin.components.views).some(([_, view]) => {\n const routeWithoutAdmin = getRouteWithoutAdmin({ adminRoute, route })\n\n if (view.exact) {\n if (routeWithoutAdmin === view.path) {\n return true\n }\n } else {\n if (routeWithoutAdmin.startsWith(view.path)) {\n return true\n }\n }\n return false\n })\n return isPublicAdminRoute\n }\n return false\n}\n"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ;AAErC;;;AAGA,OAAO,MAAMC,iBAAA,GAAoBA,CAAC;EAChCC,UAAU;EACVC,MAAM;EACNC;AAAK,CAKN;EACC,IAAID,MAAA,CAAOE,KAAK,EAAEC,UAAA,EAAYC,KAAA,EAAO;IACnC,MAAMC,kBAAA,GAAqBC,MAAA,CAAOC,OAAO,CAACP,MAAA,CAAOE,KAAK,CAACC,UAAU,CAACC,KAAK,EAAEI,IAAI,CAAC,CAAC,CAACC,CAAA,EAAGC,IAAA,CAAK;MACtF,MAAMC,iBAAA,GAAoBd,oBAAA,CAAqB;QAAEE,UAAA;QAAYE;MAAM;MAEnE,IAAIS,IAAA,CAAKE,KAAK,EAAE;QACd,IAAID,iBAAA,KAAsBD,IAAA,CAAKG,IAAI,EAAE;UACnC,OAAO;QACT;MACF,OAAO;QACL,IAAIF,iBAAA,CAAkBG,UAAU,CAACJ,IAAA,CAAKG,IAAI,GAAG;UAC3C,OAAO;QACT;MACF;MACA,OAAO;IACT;IACA,OAAOR,kBAAA;EACT;EACA,OAAO;AACT","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPublicAdminRoute.d.ts","sourceRoot":"","sources":["../../src/utilities/isPublicAdminRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAmB9C,eAAO,MAAM,kBAAkB,mCAI5B;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;CACd,KAAG,OAeH,CAAA"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
+
import { getRouteWithoutAdmin } from './getRouteWithoutAdmin.js';
|
|
1
2
|
// Routes that require admin authentication
|
|
2
3
|
const publicAdminRoutes = ['createFirstUser', 'forgot', 'login', 'logout', 'forgot', 'inactivity', 'unauthorized', 'reset'];
|
|
3
|
-
export const isAdminRoute = ({
|
|
4
|
-
adminRoute,
|
|
5
|
-
route
|
|
6
|
-
}) => {
|
|
7
|
-
return route.startsWith(adminRoute);
|
|
8
|
-
};
|
|
9
4
|
export const isPublicAdminRoute = ({
|
|
10
5
|
adminRoute,
|
|
11
6
|
config,
|
|
@@ -27,10 +22,4 @@ export const isPublicAdminRoute = ({
|
|
|
27
22
|
});
|
|
28
23
|
return isPublicAdminRoute;
|
|
29
24
|
};
|
|
30
|
-
|
|
31
|
-
adminRoute,
|
|
32
|
-
route
|
|
33
|
-
}) => {
|
|
34
|
-
return adminRoute && adminRoute !== '/' ? route.replace(adminRoute, '') : route;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=shared.js.map
|
|
25
|
+
//# sourceMappingURL=isPublicAdminRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPublicAdminRoute.js","names":["getRouteWithoutAdmin","publicAdminRoutes","isPublicAdminRoute","adminRoute","config","route","some","routeSegment","segment","admin","routes","routeWithoutAdmin","startsWith","includes"],"sources":["../../src/utilities/isPublicAdminRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { getRouteWithoutAdmin } from './getRouteWithoutAdmin.js'\n\n// Routes that require admin authentication\nconst publicAdminRoutes: (keyof Pick<\n SanitizedConfig['admin']['routes'],\n 'createFirstUser' | 'forgot' | 'inactivity' | 'login' | 'logout' | 'reset' | 'unauthorized'\n>)[] = [\n 'createFirstUser',\n 'forgot',\n 'login',\n 'logout',\n 'forgot',\n 'inactivity',\n 'unauthorized',\n 'reset',\n]\n\nexport const isPublicAdminRoute = ({\n adminRoute,\n config,\n route,\n}: {\n adminRoute: string\n config: SanitizedConfig\n route: string\n}): boolean => {\n const isPublicAdminRoute = publicAdminRoutes.some((routeSegment) => {\n const segment = config.admin?.routes?.[routeSegment] || routeSegment\n const routeWithoutAdmin = getRouteWithoutAdmin({ adminRoute, route })\n\n if (routeWithoutAdmin.startsWith(segment)) {\n return true\n } else if (routeWithoutAdmin.includes('/verify/')) {\n return true\n } else {\n return false\n }\n })\n\n return isPublicAdminRoute\n}\n"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ;AAErC;AACA,MAAMC,iBAAA,GAGC,CACL,mBACA,UACA,SACA,UACA,UACA,cACA,gBACA,QACD;AAED,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EACjCC,UAAU;EACVC,MAAM;EACNC;AAAK,CAKN;EACC,MAAMH,kBAAA,GAAqBD,iBAAA,CAAkBK,IAAI,CAAEC,YAAA;IACjD,MAAMC,OAAA,GAAUJ,MAAA,CAAOK,KAAK,EAAEC,MAAA,GAASH,YAAA,CAAa,IAAIA,YAAA;IACxD,MAAMI,iBAAA,GAAoBX,oBAAA,CAAqB;MAAEG,UAAA;MAAYE;IAAM;IAEnE,IAAIM,iBAAA,CAAkBC,UAAU,CAACJ,OAAA,GAAU;MACzC,OAAO;IACT,OAAO,IAAIG,iBAAA,CAAkBE,QAAQ,CAAC,aAAa;MACjD,OAAO;IACT,OAAO;MACL,OAAO;IACT;EACF;EAEA,OAAOX,kBAAA;AACT","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,EAI/B,SAAS,EACV,MAAM,SAAS,CAAA;AAWhB,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,
|
|
1
|
+
{"version":3,"file":"buildView.d.ts","sourceRoot":"","sources":["../../../src/views/CollectionFolders/buildView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,+BAA+B,EAI/B,SAAS,EACV,MAAM,SAAS,CAAA;AAWhB,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"}
|
|
@@ -127,7 +127,7 @@ export const buildCollectionFolderView = async args => {
|
|
|
127
127
|
clientProps: {
|
|
128
128
|
// ...folderViewSlots,
|
|
129
129
|
allCollectionFolderSlugs: [config.folders.slug, collectionSlug],
|
|
130
|
-
allowCreateCollectionSlugs: [permissions?.collections?.[config.folders.slug]?.create ? config.folders.slug : null, permissions?.collections?.[collectionSlug]?.create ? collectionSlug : null].filter(Boolean),
|
|
130
|
+
allowCreateCollectionSlugs: [permissions?.collections?.[config.folders.slug]?.create ? config.folders.slug : null, resolvedFolderID && permissions?.collections?.[collectionSlug]?.create ? collectionSlug : null].filter(Boolean),
|
|
131
131
|
baseFolderPath: `/collections/${collectionSlug}/${config.folders.slug}`,
|
|
132
132
|
breadcrumbs,
|
|
133
133
|
collectionSlug,
|
|
@@ -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","folderAssignedCollections","FolderResultsComponent","subfolders","browseByFolder","collectionsToDisplay","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 = collectionFolderPreferences?.sort || 'name'\n const viewPreference = collectionFolderPreferences?.viewPreference || 'grid'\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const {\n breadcrumbs,\n documents,\n folderAssignedCollections,\n FolderResultsComponent,\n subfolders,\n } = await getFolderResultsComponentAndData({\n browseByFolder: false,\n collectionsToDisplay: [config.folders.slug, collectionSlug],\n displayAs: viewPreference,\n folderAssignedCollections: [collectionSlug],\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 folderAssignedCollections,\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,SAASA,2BAA2B,EAAEC,mBAAmB,QAAQ;AACjE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gCAAgC,EAAEC,iBAAiB,QAAQ;AACpE,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAclB;;;AAGA,OAAO,MAAMC,yBAAA,GAA4B,MACvCC,IAAA;EAEA,MAAM;IACJC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,wBAAwB;IACxBC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGX,IAAA;EAEJ,MAAM;IACJY,gBAAgB;IAChBA,gBAAA,EAAkB;MAAEC,IAAA,EAAMC;IAAc,CA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AAOI,OAAO,CAACZ,IAAI,CAAC,EAAEgD,MAAA,GAC7CxC,MAAA,CAAOI,OAAO,CAACZ,IAAI,GACnB,MACJI,WAAA,EAAaU,WAAA,GAAcb,cAAA,CAAe,EAAE+C,MAAA,GAAS/C,cAAA,GAAiB,KACvE,CAACgD,MAAM,CAACC,OAAA;YACTC,cAAA,EAAgB,gBAAgBlD,cAAA,IAAkBO,MAAA,CAAOI,OAAO,CAACZ,IAAI,EAAE;YACvE0B,WAAA;YACAzB,cAAA;YACAb,iBAAA;YACAC,eAAA;YACAsC,SAAA;YACArC,mBAAA;YACAsC,yBAAA;YACAwB,eAAA,EAAiB5C,MAAA,CAAOI,OAAO,CAACyC,SAAS;YACzC9D,QAAA,EAAU2C,gBAAA,IAAoB;YAC9BL,sBAAA;YACAW,MAAA;YACApB,IAAA,EAAMC,cAAA;YACNS,UAAA;YACAR;UACF;UACA;UACAgC,QAAA,EAAU5E,2BAAA;UACV6E,SAAA,EAAWhD,OAAA,CAAQgD,SAAS;UAC5BhB;QACF;;IAGN;EACF;EAEA,MAAM,IAAI1B,KAAA,CAAM;AAClB","ignoreList":[]}
|
|
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","folderAssignedCollections","FolderResultsComponent","subfolders","browseByFolder","collectionsToDisplay","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 = collectionFolderPreferences?.sort || 'name'\n const viewPreference = collectionFolderPreferences?.viewPreference || 'grid'\n\n const {\n routes: { admin: adminRoute },\n } = config\n\n const {\n breadcrumbs,\n documents,\n folderAssignedCollections,\n FolderResultsComponent,\n subfolders,\n } = await getFolderResultsComponentAndData({\n browseByFolder: false,\n collectionsToDisplay: [config.folders.slug, collectionSlug],\n displayAs: viewPreference,\n folderAssignedCollections: [collectionSlug],\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 resolvedFolderID && permissions?.collections?.[collectionSlug]?.create\n ? collectionSlug\n : null,\n ].filter(Boolean),\n baseFolderPath: `/collections/${collectionSlug}/${config.folders.slug}`,\n breadcrumbs,\n collectionSlug,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderAssignedCollections,\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,SAASA,2BAA2B,EAAEC,mBAAmB,QAAQ;AACjE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gCAAgC,EAAEC,iBAAiB,QAAQ;AACpE,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,MAAW;AAclB;;;AAGA,OAAO,MAAMC,yBAAA,GAA4B,MACvCC,IAAA;EAEA,MAAM;IACJC,iBAAiB;IACjBC,eAAe;IACfC,mBAAmB;IACnBC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,wBAAwB;IACxBC,MAAM;IACNC,KAAA,EAAOC,aAAa;IACpBC;EAAY,CACb,GAAGX,IAAA;EAEJ,MAAM;IACJY,gBAAgB;IAChBA,gBAAA,EAAkB;MAAEC,IAAA,EAAMC;IAAc,CAAE;IAC1CC,MAAA,EAAQC,UAAU;IAClBC,WAAW;IACXC,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBZ,KAAA,EAAOa,Y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AA,CAAe,EAAE+C,MAAA,GAC5D/C,cAAA,GACA,KACL,CAACgD,MAAM,CAACC,OAAA;YACTC,cAAA,EAAgB,gBAAgBlD,cAAA,IAAkBO,MAAA,CAAOI,OAAO,CAACZ,IAAI,EAAE;YACvE0B,WAAA;YACAzB,cAAA;YACAb,iBAAA;YACAC,eAAA;YACAsC,SAAA;YACArC,mBAAA;YACAsC,yBAAA;YACAwB,eAAA,EAAiB5C,MAAA,CAAOI,OAAO,CAACyC,SAAS;YACzC9D,QAAA,EAAU2C,gBAAA,IAAoB;YAC9BL,sBAAA;YACAW,MAAA;YACApB,IAAA,EAAMC,cAAA;YACNS,UAAA;YACAR;UACF;UACA;UACAgC,QAAA,EAAU5E,2BAAA;UACV6E,SAAA,EAAWhD,OAAA,CAAQgD,SAAS;UAC5BhB;QACF;;IAGN;EACF;EAEA,MAAM,IAAI1B,KAAA,CAAM;AAClB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/CreateFirstUser/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/CreateFirstUser/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,cAAc,CAAA;AAErB,wBAAsB,mBAAmB,CAAC,EAAE,cAAc,EAAE,EAAE,oBAAoB,8BA6EjF"}
|
|
@@ -3,7 +3,6 @@ import { buildFormState } from '@payloadcms/ui/utilities/buildFormState';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { getDocPreferences } from '../Document/getDocPreferences.js';
|
|
5
5
|
import { getDocumentData } from '../Document/getDocumentData.js';
|
|
6
|
-
import { getDocumentPermissions } from '../Document/getDocumentPermissions.js';
|
|
7
6
|
import { CreateFirstUserClient } from './index.client.js';
|
|
8
7
|
export async function CreateFirstUserView({
|
|
9
8
|
initPageResult
|
|
@@ -41,21 +40,27 @@ export async function CreateFirstUserView({
|
|
|
41
40
|
payload: req.payload,
|
|
42
41
|
user: req.user
|
|
43
42
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
const baseFields = Object.fromEntries(collectionConfig.fields.filter(f => 'name' in f && typeof f.name === 'string').map(f => [f.name, {
|
|
44
|
+
create: true,
|
|
45
|
+
read: true,
|
|
46
|
+
update: true
|
|
47
|
+
}]));
|
|
48
|
+
// In create-first-user we should always allow all fields
|
|
49
|
+
const docPermissionsForForm = {
|
|
50
|
+
create: true,
|
|
51
|
+
delete: true,
|
|
52
|
+
fields: baseFields,
|
|
53
|
+
read: true,
|
|
54
|
+
readVersions: true,
|
|
55
|
+
update: true
|
|
56
|
+
};
|
|
52
57
|
// Build initial form state from data
|
|
53
58
|
const {
|
|
54
59
|
state: formState
|
|
55
60
|
} = await buildFormState({
|
|
56
61
|
collectionSlug: collectionConfig.slug,
|
|
57
62
|
data,
|
|
58
|
-
docPermissions,
|
|
63
|
+
docPermissions: docPermissionsForForm,
|
|
59
64
|
docPreferences,
|
|
60
65
|
locale: locale?.code,
|
|
61
66
|
operation: 'create',
|
|
@@ -71,7 +76,7 @@ export async function CreateFirstUserView({
|
|
|
71
76
|
}), /*#__PURE__*/_jsx("p", {
|
|
72
77
|
children: req.t('authentication:beginCreateFirstUser')
|
|
73
78
|
}), /*#__PURE__*/_jsx(CreateFirstUserClient, {
|
|
74
|
-
docPermissions:
|
|
79
|
+
docPermissions: docPermissionsForForm,
|
|
75
80
|
docPreferences: docPreferences,
|
|
76
81
|
initialState: formState,
|
|
77
82
|
loginWithUsername: loginWithUsername,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["buildFormState","React","getDocPreferences","getDocumentData","
|
|
1
|
+
{"version":3,"file":"index.js","names":["buildFormState","React","getDocPreferences","getDocumentData","CreateFirstUserClient","CreateFirstUserView","initPageResult","locale","req","payload","collections","config","admin","user","userSlug","collectionConfig","auth","authOptions","loginWithUsername","data","collectionSlug","slug","docPreferences","baseFields","Object","fromEntries","fields","filter","f","name","map","create","read","update","docPermissionsForForm","delete","readVersions","state","formState","docPermissions","code","operation","renderAllFields","schemaPath","skipValidation","_jsxs","className","_jsx","t","initialState"],"sources":["../../../src/views/CreateFirstUser/index.tsx"],"sourcesContent":["import type {\n AdminViewServerProps,\n SanitizedDocumentPermissions,\n SanitizedFieldsPermissions,\n} from 'payload'\n\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport React from 'react'\n\nimport { getDocPreferences } from '../Document/getDocPreferences.js'\nimport { getDocumentData } from '../Document/getDocumentData.js'\nimport { CreateFirstUserClient } from './index.client.js'\nimport './index.scss'\n\nexport async function CreateFirstUserView({ initPageResult }: AdminViewServerProps) {\n const {\n locale,\n req,\n req: {\n payload: {\n collections,\n config: {\n admin: { user: userSlug },\n },\n },\n },\n } = initPageResult\n\n const collectionConfig = collections?.[userSlug]?.config\n const { auth: authOptions } = collectionConfig\n const loginWithUsername = authOptions.loginWithUsername\n\n // Fetch the data required for the view\n const data = await getDocumentData({\n collectionSlug: collectionConfig.slug,\n locale,\n payload: req.payload,\n req,\n user: req.user,\n })\n\n // Get document preferences\n const docPreferences = await getDocPreferences({\n collectionSlug: collectionConfig.slug,\n payload: req.payload,\n user: req.user,\n })\n\n const baseFields: SanitizedFieldsPermissions = Object.fromEntries(\n collectionConfig.fields\n .filter((f): f is { name: string } & typeof f => 'name' in f && typeof f.name === 'string')\n .map((f) => [f.name, { create: true, read: true, update: true }]),\n )\n\n // In create-first-user we should always allow all fields\n const docPermissionsForForm: SanitizedDocumentPermissions = {\n create: true,\n delete: true,\n fields: baseFields,\n read: true,\n readVersions: true,\n update: true,\n }\n\n // Build initial form state from data\n const { state: formState } = await buildFormState({\n collectionSlug: collectionConfig.slug,\n data,\n docPermissions: docPermissionsForForm,\n docPreferences,\n locale: locale?.code,\n operation: 'create',\n renderAllFields: true,\n req,\n schemaPath: collectionConfig.slug,\n skipValidation: true,\n })\n\n return (\n <div className=\"create-first-user\">\n <h1>{req.t('general:welcome')}</h1>\n <p>{req.t('authentication:beginCreateFirstUser')}</p>\n <CreateFirstUserClient\n docPermissions={docPermissionsForForm}\n docPreferences={docPreferences}\n initialState={formState}\n loginWithUsername={loginWithUsername}\n userSlug={userSlug}\n />\n </div>\n )\n}\n"],"mappings":";AAMA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AAGtC,OAAO,eAAeC,oBAAoB;EAAEC;AAAc,CAAwB;EAChF,MAAM;IACJC,MAAM;IACNC,GAAG;IACHA,GAAA,EAAK;MACHC,OAAA,EAAS;QACPC,WAAW;QACXC,MAAA,EAAQ;UACNC,KAAA,EAAO;YAAEC,IAAA,EAAMC;UAAQ;QAAE;MAC1B;IACF;EACF,CACF,GAAGR,cAAA;EAEJ,MAAMS,gBAAA,GAAmBL,WAAA,GAAcI,QAAA,CAAS,EAAEH,MAAA;EAClD,MAAM;IAAEK,IAAA,EAAMC;EAAW,CAAE,GAAGF,gBAAA;EAC9B,MAAMG,iBAAA,GAAoBD,WAAA,CAAYC,iBAAiB;EAEvD;EACA,MAAMC,IAAA,GAAO,MAAMhB,eAAA,CAAgB;IACjCiB,cAAA,EAAgBL,gBAAA,CAAiBM,IAAI;IACrCd,MAAA;IACAE,OAAA,EAASD,GAAA,CAAIC,OAAO;IACpBD,GAAA;IACAK,IAAA,EAAML,GAAA,CAAIK;EACZ;EAEA;EACA,MAAMS,cAAA,GAAiB,MAAMpB,iBAAA,CAAkB;IAC7CkB,cAAA,EAAgBL,gBAAA,CAAiBM,IAAI;IACrCZ,OAAA,EAASD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-
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/Document/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AASlE,eAAO,MAAM,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/Document/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AASlE,eAAO,MAAM,qBAAqB,EAAE,4BAwJnC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","getAccessResults","isEntityHidden","parseCookies","renderDocument","renderDocumentHandler","args","collectionSlug","disableActions","docID","drawerSlug","initialData","locale","overrideEntityVisibility","paramsOverride","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","searchParams","versions","cookies","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","clientConfig","importMap","preferences","preferencesKey","where","and","key","equals","id","then","res","value","visibleEntities","map","slug","hidden","filter","Boolean","globals","permissions","data","Document","documentSubViewType","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","String","viewType"],"sources":["../../../src/views/Document/handleServerFunction.tsx"],"sourcesContent":["import type { RenderDocumentServerFunction } from '@payloadcms/ui'\nimport type { DocumentPreferences, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { getAccessResults, isEntityHidden, parseCookies } from 'payload'\n\nimport { renderDocument } from './index.js'\n\nexport const renderDocumentHandler: RenderDocumentServerFunction = async (args) => {\n const {\n collectionSlug,\n disableActions,\n docID,\n drawerSlug,\n initialData,\n locale,\n overrideEntityVisibility,\n paramsOverride,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n searchParams = {},\n versions,\n } = args\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: req.payload.importMap,\n })\n\n let preferences: DocumentPreferences\n\n if (docID) {\n const preferencesKey = `${collectionSlug}-edit-${docID}`\n\n preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as DocumentPreferences)\n }\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const permissions = await getAccessResults({\n req,\n })\n\n const { data, Document } = await renderDocument({\n clientConfig,\n disableActions,\n documentSubViewType: 'default',\n drawerSlug,\n i18n,\n importMap: payload.importMap,\n initialData,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n docID,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n overrideEntityVisibility,\n params: paramsOverride ?? {\n segments: ['collections', collectionSlug, String(docID)],\n },\n payload,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams,\n versions,\n viewType: 'document',\n })\n\n return {\n data,\n Document,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,YAAY,QAAQ;AAE/D,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,qBAAA,GAAsD,MAAOC,IAAA;EACxE,MAAM;IACJC,cAAc;IACdC,cAAc;IACdC,KAAK;IACLC,UAAU;IACVC,WAAW;IACXC,MAAM;IACNC,wBAAwB;IACxBC,cAAc;IACdC,mBAAmB;IACnBC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI,CACL;IACDC,YAAA,GAAe,CAAC,CAAC;IACjBC;EAAQ,CACT,GAAGlB,IAAA;EAEJ,MAAMP,OAAA,GAAU,MAAMC,UAAA;EAEtB,MAAMyB,OAAA,GAAUtB,YAAA,CAAaJ,OAAA;EAE7B,MAAM2B,gBAAA,GAAmBJ,IAAA,EAAMK,UAAA;EAE/B,MAAMC,aAAA,GAAgBP,MAAA,CAAOQ,KAAK,CAACP,IAAI;EAEvC;EACA,IAAII,gBAAA,EAAkB;IACpB,MAAMI,mBAAA,GAAsBV,OAAA,CAAQW,WAAW,CAACL,gBAAA,CAAiB,CAACL,MAAM,CAACW,MAAM,EAAEH,KAAA;IAEjF;IACA,IAAIC,mBAAA,EAAqB;MACvB,MAAMG,cAAA,GAAiB,MAAMH,mBAAA,CAAoB;QAAEZ;MAAI;MAEvD,IAAI,CAACe,cAAA,EAAgB;QACnB,MAAM,IAAIC,KAAA,CAAM;MAClB;MACA;IACF,OAAO,IAAIN,aAAA,KAAkBF,gBAAA,EAAkB;MAC7C,MAAM,IAAIQ,KAAA,CAAM;IAClB;EACF,OAAO;IACL,MAAMC,QAAA,GAAW,MAAMf,OAAA,CAAQgB,IAAI,CAAC;MAClCT,UAAA,EAAYC,aAAA;MACZS,KAAA,EAAO;MACPC,KAAA,EAAO;MACPC,UAAA,EAAY;IACd;IAEA;IACA,IAAIJ,QAAA,CAASK,IAAI,CAACC,MAAM,EAAE;MACxB,MAAM,IAAIP,KAAA,CAAM;IAClB;EACF;EAEA,MAAMQ,YAAA,GAAe5C,eAAA,CAAgB;IACnCuB,MAAA;IACAF,IAAA;IACAwB,SAAA,EAAWzB,GAAA,CAAIE,OAAO,CAACuB;
|
|
1
|
+
{"version":3,"file":"handleServerFunction.js","names":["getClientConfig","headers","getHeaders","getAccessResults","isEntityHidden","parseCookies","renderDocument","renderDocumentHandler","args","collectionSlug","disableActions","docID","drawerSlug","initialData","locale","overrideEntityVisibility","paramsOverride","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","req","i18n","payload","config","user","searchParams","versions","cookies","incomingUserSlug","collection","adminUserSlug","admin","adminAccessFunction","collections","access","canAccessAdmin","Error","hasUsers","find","depth","limit","pagination","docs","length","clientConfig","importMap","preferences","preferencesKey","where","and","key","equals","id","then","res","value","visibleEntities","map","slug","hidden","filter","Boolean","globals","permissions","data","Document","documentSubViewType","initPageResult","collectionConfig","globalConfig","global","languageOptions","undefined","translations","params","segments","String","viewType"],"sources":["../../../src/views/Document/handleServerFunction.tsx"],"sourcesContent":["import type { RenderDocumentServerFunction } from '@payloadcms/ui'\nimport type { DocumentPreferences, VisibleEntities } from 'payload'\n\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { headers as getHeaders } from 'next/headers.js'\nimport { getAccessResults, isEntityHidden, parseCookies } from 'payload'\n\nimport { renderDocument } from './index.js'\n\nexport const renderDocumentHandler: RenderDocumentServerFunction = async (args) => {\n const {\n collectionSlug,\n disableActions,\n docID,\n drawerSlug,\n initialData,\n locale,\n overrideEntityVisibility,\n paramsOverride,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n searchParams = {},\n versions,\n } = args\n\n const headers = await getHeaders()\n\n const cookies = parseCookies(headers)\n\n const incomingUserSlug = user?.collection\n\n const adminUserSlug = config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n throw new Error('Unauthorized')\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n throw new Error('Unauthorized')\n }\n } else {\n const hasUsers = await payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n throw new Error('Unauthorized')\n }\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n,\n importMap: req.payload.importMap,\n user,\n })\n\n let preferences: DocumentPreferences\n\n if (docID) {\n const preferencesKey = `${collectionSlug}-edit-${docID}`\n\n preferences = await payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n and: [\n {\n key: {\n equals: preferencesKey,\n },\n },\n {\n 'user.relationTo': {\n equals: user.collection,\n },\n },\n {\n 'user.value': {\n equals: user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs[0]?.value as DocumentPreferences)\n }\n\n const visibleEntities: VisibleEntities = {\n collections: payload.config.collections\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n globals: payload.config.globals\n .map(({ slug, admin: { hidden } }) => (!isEntityHidden({ hidden, user }) ? slug : null))\n .filter(Boolean),\n }\n\n const permissions = await getAccessResults({\n req,\n })\n\n const { data, Document } = await renderDocument({\n clientConfig,\n disableActions,\n documentSubViewType: 'default',\n drawerSlug,\n i18n,\n importMap: payload.importMap,\n initialData,\n initPageResult: {\n collectionConfig: payload?.collections?.[collectionSlug]?.config,\n cookies,\n docID,\n globalConfig: payload.config.globals.find((global) => global.slug === collectionSlug),\n languageOptions: undefined, // TODO\n locale,\n permissions,\n req,\n translations: undefined, // TODO\n visibleEntities,\n },\n overrideEntityVisibility,\n params: paramsOverride ?? {\n segments: ['collections', collectionSlug, String(docID)],\n },\n payload,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n searchParams,\n versions,\n viewType: 'document',\n })\n\n return {\n data,\n Document,\n preferences,\n }\n}\n"],"mappings":"AAGA,SAASA,eAAe,QAAQ;AAChC,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SAASC,gBAAgB,EAAEC,cAAc,EAAEC,YAAY,QAAQ;AAE/D,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,qBAAA,GAAsD,MAAOC,IAAA;EACxE,MAAM;IACJC,cAAc;IACdC,cAAc;IACdC,KAAK;IACLC,UAAU;IACVC,WAAW;IACXC,MAAM;IACNC,wBAAwB;IACxBC,cAAc;IACdC,mBAAmB;IACnBC,mBAAmB;IACnBC,sBAAsB;IACtBC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBC;IAAI,CACL;IACDC,YAAA,GAAe,CAAC,CAAC;IACjBC;EAAQ,CACT,GAAGlB,IAAA;EAEJ,MAAMP,OAAA,GAAU,MAAMC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AA,IAAWA,MAAA,CAAOZ,IAAI,KAAKjD,cAAA;MACtE8D,eAAA,EAAiBC,SAAA;MACjB1D,MAAA;MACAiD,WAAA;MACA3C,GAAA;MACAqD,YAAA,EAAcD,SAAA;MACdhB;IACF;IACAzC,wBAAA;IACA2D,MAAA,EAAQ1D,cAAA,IAAkB;MACxB2D,QAAA,EAAU,CAAC,eAAelE,cAAA,EAAgBmE,MAAA,CAAOjE,KAAA;IACnD;IACAW,OAAA;IACAL,mBAAA;IACAC,mBAAA;IACAC,sBAAA;IACAM,YAAA;IACAC,QAAA;IACAmD,QAAA,EAAU;EACZ;EAEA,OAAO;IACLb,IAAA;IACAC,QAAA;IACAnB;EACF;AACF","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ClientConfig, Column, ListQuery, PaginatedDocs, PayloadRequest, SanitizedCollectionConfig, ViewTypes, Where } from 'payload';
|
|
2
|
-
export declare const handleGroupBy: ({ clientConfig, collectionConfig, collectionSlug, columns, customCellProps, drawerSlug, enableRowSelections, query, req, trash, user, viewType, where: whereWithMergedSearch, }: {
|
|
1
|
+
import type { ClientCollectionConfig, ClientConfig, Column, ListQuery, PaginatedDocs, PayloadRequest, SanitizedCollectionConfig, SelectType, ViewTypes, Where } from 'payload';
|
|
2
|
+
export declare const handleGroupBy: ({ clientCollectionConfig, clientConfig, collectionConfig, collectionSlug, columns, customCellProps, drawerSlug, enableRowSelections, query, req, select, trash, user, viewType, where: whereWithMergedSearch, }: {
|
|
3
|
+
clientCollectionConfig: ClientCollectionConfig;
|
|
3
4
|
clientConfig: ClientConfig;
|
|
4
5
|
collectionConfig: SanitizedCollectionConfig;
|
|
5
6
|
collectionSlug: string;
|
|
@@ -9,6 +10,7 @@ export declare const handleGroupBy: ({ clientConfig, collectionConfig, collectio
|
|
|
9
10
|
enableRowSelections?: boolean;
|
|
10
11
|
query?: ListQuery;
|
|
11
12
|
req: PayloadRequest;
|
|
13
|
+
select?: SelectType;
|
|
12
14
|
trash?: boolean;
|
|
13
15
|
user: any;
|
|
14
16
|
viewType?: ViewTypes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleGroupBy.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleGroupBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,SAAS,EACT,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAA;AAMhB,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"handleGroupBy.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleGroupBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,MAAM,EACN,SAAS,EACT,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,UAAU,EACV,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAA;AAMhB,eAAO,MAAM,aAAa,oNAgBvB;IACD,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,YAAY,EAAE,YAAY,CAAA;IAC1B,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,GAAG,CAAA;IACT,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,EAAE,KAAK,CAAA;CACb,KAAG,OAAO,CAAC;IACV,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,IAAI,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAA;CAClD,CA0KA,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { renderTable } from '@payloadcms/ui/rsc';
|
|
|
2
2
|
import { formatDate } from '@payloadcms/ui/shared';
|
|
3
3
|
import { flattenAllFields } from 'payload';
|
|
4
4
|
export const handleGroupBy = async ({
|
|
5
|
+
clientCollectionConfig,
|
|
5
6
|
clientConfig,
|
|
6
7
|
collectionConfig,
|
|
7
8
|
collectionSlug,
|
|
@@ -11,6 +12,7 @@ export const handleGroupBy = async ({
|
|
|
11
12
|
enableRowSelections,
|
|
12
13
|
query,
|
|
13
14
|
req,
|
|
15
|
+
select,
|
|
14
16
|
trash = false,
|
|
15
17
|
user,
|
|
16
18
|
viewType,
|
|
@@ -19,7 +21,6 @@ export const handleGroupBy = async ({
|
|
|
19
21
|
let Table = null;
|
|
20
22
|
let columnState;
|
|
21
23
|
const dataByGroup = {};
|
|
22
|
-
const clientCollectionConfig = clientConfig.collections.find(c => c.slug === collectionSlug);
|
|
23
24
|
// NOTE: is there a faster/better way to do this?
|
|
24
25
|
const flattenedFields = flattenAllFields({
|
|
25
26
|
fields: collectionConfig.fields
|
|
@@ -76,6 +77,7 @@ export const handleGroupBy = async ({
|
|
|
76
77
|
req,
|
|
77
78
|
// Note: if we wanted to enable table-by-table sorting, we could use this:
|
|
78
79
|
// sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,
|
|
80
|
+
select,
|
|
79
81
|
sort: query?.sort,
|
|
80
82
|
trash,
|
|
81
83
|
user,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleGroupBy.js","names":["renderTable","formatDate","flattenAllFields","handleGroupBy","clientConfig","collectionConfig","collectionSlug","columns","customCellProps","drawerSlug","enableRowSelections","query","req","trash","user","viewType","where","whereWithMergedSearch","Table","columnState","dataByGroup","clientCollectionConfig","collections","find","c","slug","flattenedFields","fields","groupByFieldPath","groupBy","replace","groupByField","f","name","relationshipConfig","type","relationTo","undefined","populate","Array","isArray","forEach","rel","admin","useAsTitle","distinct","payload","findDistinct","collection","depth","field","limit","Number","locale","overrideAccess","page","sort","data","docs","values","map","Promise","all","distinctValue","i","potentiallyPopulatedRelationship","valueOrRelationshipID","id","groupData","draft","fallbackLocale","includeLockStatus","queryByGroup","equals","heading","date","String","i18n","pattern","dateFormat","t","length","newColumnState","NewTable","groupByValue","key","orderableFieldName","orderable"],"sources":["../../../src/views/List/handleGroupBy.ts"],"sourcesContent":["import type {\n ClientConfig,\n Column,\n ListQuery,\n PaginatedDocs,\n PayloadRequest,\n SanitizedCollectionConfig,\n ViewTypes,\n Where,\n} from 'payload'\n\nimport { renderTable } from '@payloadcms/ui/rsc'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { flattenAllFields } from 'payload'\n\nexport const handleGroupBy = async ({\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n query,\n req,\n trash = false,\n user,\n viewType,\n where: whereWithMergedSearch,\n}: {\n clientConfig: ClientConfig\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n columns: any[]\n customCellProps?: Record<string, any>\n drawerSlug?: string\n enableRowSelections?: boolean\n query?: ListQuery\n req: PayloadRequest\n trash?: boolean\n user: any\n viewType?: ViewTypes\n where: Where\n}): Promise<{\n columnState: Column[]\n data: PaginatedDocs\n Table: null | React.ReactNode | React.ReactNode[]\n}> => {\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[]\n\n const dataByGroup: Record<string, PaginatedDocs> = {}\n const clientCollectionConfig = clientConfig.collections.find((c) => c.slug === collectionSlug)\n\n // NOTE: is there a faster/better way to do this?\n const flattenedFields = flattenAllFields({ fields: collectionConfig.fields })\n\n const groupByFieldPath = query.groupBy.replace(/^-/, '')\n\n const groupByField = flattenedFields.find((f) => f.name === groupByFieldPath)\n\n const relationshipConfig =\n groupByField?.type === 'relationship'\n ? clientConfig.collections.find((c) => c.slug === groupByField.relationTo)\n : undefined\n\n let populate\n\n if (groupByField?.type === 'relationship' && groupByField.relationTo) {\n const relationTo =\n typeof groupByField.relationTo === 'string'\n ? [groupByField.relationTo]\n : groupByField.relationTo\n\n if (Array.isArray(relationTo)) {\n relationTo.forEach((rel) => {\n if (!populate) {\n populate = {}\n }\n populate[rel] = { [relationshipConfig?.admin.useAsTitle || 'id']: true }\n })\n }\n }\n\n const distinct = await req.payload.findDistinct({\n collection: collectionSlug,\n depth: 1,\n field: groupByFieldPath,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n populate,\n req,\n sort: query?.groupBy,\n trash,\n where: whereWithMergedSearch,\n })\n\n const data = {\n ...distinct,\n docs: distinct.values?.map(() => ({})) || [],\n values: undefined,\n }\n\n await Promise.all(\n distinct.values.map(async (distinctValue, i) => {\n const potentiallyPopulatedRelationship = distinctValue[groupByFieldPath]\n\n const valueOrRelationshipID =\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object' &&\n 'id' in potentiallyPopulatedRelationship\n ? potentiallyPopulatedRelationship.id\n : potentiallyPopulatedRelationship\n\n const groupData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.queryByGroup?.[valueOrRelationshipID]?.limit\n ? Number(query.queryByGroup[valueOrRelationshipID].limit)\n : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.queryByGroup?.[valueOrRelationshipID]?.page\n ? Number(query.queryByGroup[valueOrRelationshipID].page)\n : undefined,\n req,\n // Note: if we wanted to enable table-by-table sorting, we could use this:\n // sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,\n sort: query?.sort,\n trash,\n user,\n where: {\n ...(whereWithMergedSearch || {}),\n [groupByFieldPath]: {\n equals: valueOrRelationshipID,\n },\n },\n })\n\n let heading = valueOrRelationshipID\n\n if (\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object'\n ) {\n heading =\n potentiallyPopulatedRelationship[relationshipConfig.admin.useAsTitle || 'id'] ||\n valueOrRelationshipID\n }\n\n if (groupByField.type === 'date' && valueOrRelationshipID) {\n heading = formatDate({\n date: String(valueOrRelationshipID),\n i18n: req.i18n,\n pattern: clientConfig.admin.dateFormat,\n })\n }\n\n if (groupByField.type === 'checkbox') {\n if (valueOrRelationshipID === true) {\n heading = req.i18n.t('general:true')\n }\n\n if (valueOrRelationshipID === false) {\n heading = req.i18n.t('general:false')\n }\n }\n\n if (groupData.docs && groupData.docs.length > 0) {\n const { columnState: newColumnState, Table: NewTable } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data: groupData,\n drawerSlug,\n enableRowSelections,\n groupByFieldPath,\n groupByValue: valueOrRelationshipID,\n heading: heading || req.i18n.t('general:noValue'),\n i18n: req.i18n,\n key: `table-${valueOrRelationshipID}`,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n })\n\n // Only need to set `columnState` once, using the first table's column state\n // This will avoid needing to generate column state explicitly for root context that wraps all tables\n if (!columnState) {\n columnState = newColumnState\n }\n\n if (!Table) {\n Table = []\n }\n\n dataByGroup[valueOrRelationshipID] = groupData\n ;(Table as Array<React.ReactNode>)[i] = NewTable\n }\n }),\n )\n\n return {\n columnState,\n data,\n Table,\n }\n}\n"],"mappings":"AAWA,SAASA,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,YAAY;EACZC,gBAAgB;EAChBC,cAAc;EACdC,OAAO;EACPC,eAAe;EACfC,UAAU;E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9D,GAAA,CAAIiE,IAAI,CAACG,CAAC,CAAC;MACvB;IACF;IAEA,IAAIZ,SAAA,CAAUV,IAAI,IAAIU,SAAA,CAAUV,IAAI,CAACuB,MAAM,GAAG,GAAG;MAC/C,MAAM;QAAE9D,WAAA,EAAa+D,cAAc;QAAEhE,KAAA,EAAOiE;MAAQ,CAAE,GAAGnF,WAAA,CAAY;QACnEqB,sBAAA;QACAhB,gBAAA;QACAE,OAAA;QACAC,eAAA;QACAiD,IAAA,EAAMW,SAAA;QACN3D,UAAA;QACAC,mBAAA;QACAkB,gBAAA;QACAwD,YAAA,EAAclB,qBAAA;QACdQ,OAAA,EAASA,OAAA,IAAW9D,GAAA,CAAIiE,IAAI,CAACG,CAAC,CAAC;QAC/BH,IAAA,EAAMjE,GAAA,CAAIiE,IAAI;QACdQ,GAAA,EAAK,SAASnB,qBAAA,EAAuB;QACrCoB,kBAAA,EAAoBjF,gBAAA,CAAiBkF,SAAS,KAAK,OAAO,WAAWlD,SAAA;QACrES,OAAA,EAASlC,GAAA,CAAIkC,OAAO;QACpBnC,KAAA;QACAiC,UAAA,EAAYvC,gBAAA,CAAiBsC,KAAK,CAACC,UAAU;QAC7C7B;MACF;MAEA;MACA;MACA,IAAI,CAACI,WAAA,EAAa;QAChBA,WAAA,GAAc+D,cAAA;MAChB;MAEA,IAAI,CAAChE,KAAA,EAAO;QACVA,KAAA,GAAQ,EAAE;MACZ;MAEAE,WAAW,CAAC8C,qBAAA,CAAsB,GAAGE,SAAA;MACnClD,KAAgC,CAAC8C,CAAA,CAAE,GAAGmB,QAAA;IAC1C;EACF;EAGF,OAAO;IACLhE,WAAA;IACAsC,IAAA;IACAvC;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"handleGroupBy.js","names":["renderTable","formatDate","flattenAllFields","handleGroupBy","clientCollectionConfig","clientConfig","collectionConfig","collectionSlug","columns","customCellProps","drawerSlug","enableRowSelections","query","req","select","trash","user","viewType","where","whereWithMergedSearch","Table","columnState","dataByGroup","flattenedFields","fields","groupByFieldPath","groupBy","replace","groupByField","find","f","name","relationshipConfig","type","collections","c","slug","relationTo","undefined","populate","Array","isArray","forEach","rel","admin","useAsTitle","distinct","payload","findDistinct","collection","depth","field","limit","Number","locale","overrideAccess","page","sort","data","docs","values","map","Promise","all","distinctValue","i","potentiallyPopulatedRelationship","valueOrRelationshipID","id","groupData","draft","fallbackLocale","includeLockStatus","queryByGroup","equals","heading","date","String","i18n","pattern","dateFormat","t","length","newColumnState","NewTable","groupByValue","key","orderableFieldName","orderable"],"sources":["../../../src/views/List/handleGroupBy.ts"],"sourcesContent":["import type {\n ClientCollectionConfig,\n ClientConfig,\n Column,\n ListQuery,\n PaginatedDocs,\n PayloadRequest,\n SanitizedCollectionConfig,\n SelectType,\n ViewTypes,\n Where,\n} from 'payload'\n\nimport { renderTable } from '@payloadcms/ui/rsc'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { flattenAllFields } from 'payload'\n\nexport const handleGroupBy = async ({\n clientCollectionConfig,\n clientConfig,\n collectionConfig,\n collectionSlug,\n columns,\n customCellProps,\n drawerSlug,\n enableRowSelections,\n query,\n req,\n select,\n trash = false,\n user,\n viewType,\n where: whereWithMergedSearch,\n}: {\n clientCollectionConfig: ClientCollectionConfig\n clientConfig: ClientConfig\n collectionConfig: SanitizedCollectionConfig\n collectionSlug: string\n columns: any[]\n customCellProps?: Record<string, any>\n drawerSlug?: string\n enableRowSelections?: boolean\n query?: ListQuery\n req: PayloadRequest\n select?: SelectType\n trash?: boolean\n user: any\n viewType?: ViewTypes\n where: Where\n}): Promise<{\n columnState: Column[]\n data: PaginatedDocs\n Table: null | React.ReactNode | React.ReactNode[]\n}> => {\n let Table: React.ReactNode | React.ReactNode[] = null\n let columnState: Column[]\n\n const dataByGroup: Record<string, PaginatedDocs> = {}\n\n // NOTE: is there a faster/better way to do this?\n const flattenedFields = flattenAllFields({ fields: collectionConfig.fields })\n\n const groupByFieldPath = query.groupBy.replace(/^-/, '')\n\n const groupByField = flattenedFields.find((f) => f.name === groupByFieldPath)\n\n const relationshipConfig =\n groupByField?.type === 'relationship'\n ? clientConfig.collections.find((c) => c.slug === groupByField.relationTo)\n : undefined\n\n let populate\n\n if (groupByField?.type === 'relationship' && groupByField.relationTo) {\n const relationTo =\n typeof groupByField.relationTo === 'string'\n ? [groupByField.relationTo]\n : groupByField.relationTo\n\n if (Array.isArray(relationTo)) {\n relationTo.forEach((rel) => {\n if (!populate) {\n populate = {}\n }\n populate[rel] = { [relationshipConfig?.admin.useAsTitle || 'id']: true }\n })\n }\n }\n\n const distinct = await req.payload.findDistinct({\n collection: collectionSlug,\n depth: 1,\n field: groupByFieldPath,\n limit: query?.limit ? Number(query.limit) : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.page ? Number(query.page) : undefined,\n populate,\n req,\n sort: query?.groupBy,\n trash,\n where: whereWithMergedSearch,\n })\n\n const data = {\n ...distinct,\n docs: distinct.values?.map(() => ({})) || [],\n values: undefined,\n }\n\n await Promise.all(\n distinct.values.map(async (distinctValue, i) => {\n const potentiallyPopulatedRelationship = distinctValue[groupByFieldPath]\n\n const valueOrRelationshipID =\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object' &&\n 'id' in potentiallyPopulatedRelationship\n ? potentiallyPopulatedRelationship.id\n : potentiallyPopulatedRelationship\n\n const groupData = await req.payload.find({\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: false,\n includeLockStatus: true,\n limit: query?.queryByGroup?.[valueOrRelationshipID]?.limit\n ? Number(query.queryByGroup[valueOrRelationshipID].limit)\n : undefined,\n locale: req.locale,\n overrideAccess: false,\n page: query?.queryByGroup?.[valueOrRelationshipID]?.page\n ? Number(query.queryByGroup[valueOrRelationshipID].page)\n : undefined,\n req,\n // Note: if we wanted to enable table-by-table sorting, we could use this:\n // sort: query?.queryByGroup?.[valueOrRelationshipID]?.sort,\n select,\n sort: query?.sort,\n trash,\n user,\n where: {\n ...(whereWithMergedSearch || {}),\n [groupByFieldPath]: {\n equals: valueOrRelationshipID,\n },\n },\n })\n\n let heading = valueOrRelationshipID\n\n if (\n groupByField?.type === 'relationship' &&\n potentiallyPopulatedRelationship &&\n typeof potentiallyPopulatedRelationship === 'object'\n ) {\n heading =\n potentiallyPopulatedRelationship[relationshipConfig.admin.useAsTitle || 'id'] ||\n valueOrRelationshipID\n }\n\n if (groupByField.type === 'date' && valueOrRelationshipID) {\n heading = formatDate({\n date: String(valueOrRelationshipID),\n i18n: req.i18n,\n pattern: clientConfig.admin.dateFormat,\n })\n }\n\n if (groupByField.type === 'checkbox') {\n if (valueOrRelationshipID === true) {\n heading = req.i18n.t('general:true')\n }\n\n if (valueOrRelationshipID === false) {\n heading = req.i18n.t('general:false')\n }\n }\n\n if (groupData.docs && groupData.docs.length > 0) {\n const { columnState: newColumnState, Table: NewTable } = renderTable({\n clientCollectionConfig,\n collectionConfig,\n columns,\n customCellProps,\n data: groupData,\n drawerSlug,\n enableRowSelections,\n groupByFieldPath,\n groupByValue: valueOrRelationshipID,\n heading: heading || req.i18n.t('general:noValue'),\n i18n: req.i18n,\n key: `table-${valueOrRelationshipID}`,\n orderableFieldName: collectionConfig.orderable === true ? '_order' : undefined,\n payload: req.payload,\n query,\n useAsTitle: collectionConfig.admin.useAsTitle,\n viewType,\n })\n\n // Only need to set `columnState` once, using the first table's column state\n // This will avoid needing to generate column state explicitly for root context that wraps all tables\n if (!columnState) {\n columnState = newColumnState\n }\n\n if (!Table) {\n Table = []\n }\n\n dataByGroup[valueOrRelationshipID] = groupData\n ;(Table as Array<React.ReactNode>)[i] = NewTable\n }\n }),\n )\n\n return {\n columnState,\n data,\n Table,\n }\n}\n"],"mappings":"AAaA,SAASA,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,sBAAsB;EACtBC,YA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AACG,CAAC,CAAC;MACvB;IACF;IAEA,IAAIZ,SAAA,CAAUV,IAAI,IAAIU,SAAA,CAAUV,IAAI,CAACuB,MAAM,GAAG,GAAG;MAC/C,MAAM;QAAE7D,WAAA,EAAa8D,cAAc;QAAE/D,KAAA,EAAOgE;MAAQ,CAAE,GAAGpF,WAAA,CAAY;QACnEI,sBAAA;QACAE,gBAAA;QACAE,OAAA;QACAC,eAAA;QACAiD,IAAA,EAAMW,SAAA;QACN3D,UAAA;QACAC,mBAAA;QACAc,gBAAA;QACA4D,YAAA,EAAclB,qBAAA;QACdQ,OAAA,EAASA,OAAA,IAAW9D,GAAA,CAAIiE,IAAI,CAACG,CAAC,CAAC;QAC/BH,IAAA,EAAMjE,GAAA,CAAIiE,IAAI;QACdQ,GAAA,EAAK,SAASnB,qBAAA,EAAuB;QACrCoB,kBAAA,EAAoBjF,gBAAA,CAAiBkF,SAAS,KAAK,OAAO,WAAWlD,SAAA;QACrES,OAAA,EAASlC,GAAA,CAAIkC,OAAO;QACpBnC,KAAA;QACAiC,UAAA,EAAYvC,gBAAA,CAAiBsC,KAAK,CAACC,UAAU;QAC7C5B;MACF;MAEA;MACA;MACA,IAAI,CAACI,WAAA,EAAa;QAChBA,WAAA,GAAc8D,cAAA;MAChB;MAEA,IAAI,CAAC/D,KAAA,EAAO;QACVA,KAAA,GAAQ,EAAE;MACZ;MAEAE,WAAW,CAAC6C,qBAAA,CAAsB,GAAGE,SAAA;MACnCjD,KAAgC,CAAC6C,CAAA,CAAE,GAAGmB,QAAA;IAC1C;EACF;EAGF,OAAO;IACL/D,WAAA;IACAqC,IAAA;IACAtC;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAQhG,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,WAAW,EAAE,qBAAqB,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C;IACE,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;IAChB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,sBAAsB,EAAE,OAAO,CAAA;CAChC,EACD,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"handleServerFunction.d.ts","sourceRoot":"","sources":["../../../src/views/List/handleServerFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAQhG,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,WAAW,EAAE,qBAAqB,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAC5C;IACE,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,EAAE,SAAS,CAAA;IAChB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,sBAAsB,EAAE,OAAO,CAAA;CAChC,EACD,OAAO,CAAC,gBAAgB,CAAC,CAiJ1B,CAAA"}
|
|
@@ -59,7 +59,8 @@ export const renderListHandler = async args => {
|
|
|
59
59
|
const clientConfig = getClientConfig({
|
|
60
60
|
config,
|
|
61
61
|
i18n,
|
|
62
|
-
importMap: payload.importMap
|
|
62
|
+
importMap: payload.importMap,
|
|
63
|
+
user
|
|
63
64
|
});
|
|
64
65
|
const preferencesKey = `collection-${collectionSlug}`;
|
|
65
66
|
const preferences = await payload.find({
|