@payloadcms/next 3.89.0-internal.95c9cba → 3.90.0
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 +2 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js +3 -2
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.d.ts +2 -1
- package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.js +5 -3
- package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/index.d.ts +2 -1
- package/dist/elements/DocumentHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/index.js +4 -2
- package/dist/elements/DocumentHeader/index.js.map +1 -1
- package/dist/layouts/Root/index.js +6 -5
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +55 -47
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +6 -3
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js +35 -2
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/utilities/initReq.spec.js +240 -0
- package/dist/utilities/initReq.spec.js.map +1 -0
- package/dist/utilities/isPublicAdminRoute.d.ts.map +1 -1
- package/dist/utilities/isPublicAdminRoute.js +11 -9
- package/dist/utilities/isPublicAdminRoute.js.map +1 -1
- package/dist/utilities/isPublicAdminRoute.spec.js +34 -0
- package/dist/utilities/isPublicAdminRoute.spec.js.map +1 -0
- package/dist/views/Account/index.d.ts +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +10 -7
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/BrowseByFolder/buildView.js +4 -4
- package/dist/views/BrowseByFolder/buildView.js.map +1 -1
- package/dist/views/CollectionFolders/buildView.js +4 -4
- package/dist/views/CollectionFolders/buildView.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.js +1 -0
- package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +3 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +2 -0
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/Dashboard/index.js +5 -3
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +2 -0
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/Document/index.d.ts +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +9 -4
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Document/renderDocumentSlots.d.ts +1 -0
- package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
- package/dist/views/Document/renderDocumentSlots.js +7 -4
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +1 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +212 -159
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +3 -11
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +4 -2
- 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 +2 -1
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/NotFound/index.d.ts.map +1 -1
- package/dist/views/NotFound/index.js +3 -2
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +6 -4
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Verify/index.d.ts +1 -1
- package/dist/views/Verify/index.d.ts.map +1 -1
- package/dist/views/Verify/index.js +4 -4
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts +1 -0
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +56 -50
- package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +42 -28
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.spec.js +258 -0
- package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.spec.js.map +1 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +10 -0
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js +33 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +56 -2
- package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts +8 -2
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +17 -19
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +3 -13
- package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +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,
|
|
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,OAuBH,CAAA"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { getRouteWithoutAdmin } from './getRouteWithoutAdmin.js';
|
|
2
|
-
// Routes that
|
|
2
|
+
// Routes that are accessible without admin authentication
|
|
3
3
|
const publicAdminRoutes = ['createFirstUser', 'forgot', 'login', 'logout', 'forgot', 'inactivity', 'unauthorized', 'reset'];
|
|
4
4
|
export const isPublicAdminRoute = ({
|
|
5
5
|
adminRoute,
|
|
6
6
|
config,
|
|
7
7
|
route
|
|
8
8
|
}) => {
|
|
9
|
-
const
|
|
9
|
+
const routeWithoutAdmin = getRouteWithoutAdmin({
|
|
10
|
+
adminRoute,
|
|
11
|
+
route
|
|
12
|
+
});
|
|
13
|
+
const routeSegments = routeWithoutAdmin.split('/').filter(Boolean);
|
|
14
|
+
const isVerifyRoute = routeSegments.length === 3 && routeSegments[1] === 'verify' && config.collections.some(collection => collection.slug === routeSegments[0] && Boolean(collection.auth));
|
|
15
|
+
if (isVerifyRoute) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return publicAdminRoutes.some(routeSegment => {
|
|
10
19
|
const segment = config.admin?.routes?.[routeSegment] || routeSegment;
|
|
11
|
-
const routeWithoutAdmin = getRouteWithoutAdmin({
|
|
12
|
-
adminRoute,
|
|
13
|
-
route
|
|
14
|
-
});
|
|
15
20
|
if (routeWithoutAdmin.startsWith(segment)) {
|
|
16
21
|
return true;
|
|
17
|
-
} else if (routeWithoutAdmin.includes('/verify/')) {
|
|
18
|
-
return true;
|
|
19
22
|
} else {
|
|
20
23
|
return false;
|
|
21
24
|
}
|
|
22
25
|
});
|
|
23
|
-
return isPublicAdminRoute;
|
|
24
26
|
};
|
|
25
27
|
//# sourceMappingURL=isPublicAdminRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPublicAdminRoute.js","names":["getRouteWithoutAdmin","publicAdminRoutes","isPublicAdminRoute","adminRoute","config","route","some","
|
|
1
|
+
{"version":3,"file":"isPublicAdminRoute.js","names":["getRouteWithoutAdmin","publicAdminRoutes","isPublicAdminRoute","adminRoute","config","route","routeWithoutAdmin","routeSegments","split","filter","Boolean","isVerifyRoute","length","collections","some","collection","slug","auth","routeSegment","segment","admin","routes","startsWith"],"sources":["../../src/utilities/isPublicAdminRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { getRouteWithoutAdmin } from './getRouteWithoutAdmin.js'\n\n// Routes that are accessible without 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 routeWithoutAdmin = getRouteWithoutAdmin({ adminRoute, route })\n const routeSegments = routeWithoutAdmin.split('/').filter(Boolean)\n const isVerifyRoute =\n routeSegments.length === 3 &&\n routeSegments[1] === 'verify' &&\n config.collections.some(\n (collection) => collection.slug === routeSegments[0] && Boolean(collection.auth),\n )\n\n if (isVerifyRoute) {\n return true\n }\n\n return publicAdminRoutes.some((routeSegment) => {\n const segment = config.admin?.routes?.[routeSegment] || routeSegment\n\n if (routeWithoutAdmin.startsWith(segment)) {\n return true\n } else {\n return false\n }\n })\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,MAAMC,iBAAA,GAAoBN,oBAAA,CAAqB;IAAEG,UAAA;IAAYE;EAAM;EACnE,MAAME,aAAA,GAAgBD,iBAAA,CAAkBE,KAAK,CAAC,KAAKC,MAAM,CAACC,OAAA;EAC1D,MAAMC,aAAA,GACJJ,aAAA,CAAcK,MAAM,KAAK,KACzBL,aAAa,CAAC,EAAE,KAAK,YACrBH,MAAA,CAAOS,WAAW,CAACC,IAAI,CACpBC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKT,aAAa,CAAC,EAAE,IAAIG,OAAA,CAAQK,UAAA,CAAWE,IAAI;EAGnF,IAAIN,aAAA,EAAe;IACjB,OAAO;EACT;EAEA,OAAOV,iBAAA,CAAkBa,IAAI,CAAEI,YAAA;IAC7B,MAAMC,OAAA,GAAUf,MAAA,CAAOgB,KAAK,EAAEC,MAAA,GAASH,YAAA,CAAa,IAAIA,YAAA;IAExD,IAAIZ,iBAAA,CAAkBgB,UAAU,CAACH,OAAA,GAAU;MACzC,OAAO;IACT,OAAO;MACL,OAAO;IACT;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { isPublicAdminRoute } from './isPublicAdminRoute.js';
|
|
3
|
+
describe('isPublicAdminRoute', () => {
|
|
4
|
+
const config = {
|
|
5
|
+
collections: [{
|
|
6
|
+
auth: true,
|
|
7
|
+
slug: 'users'
|
|
8
|
+
}, {
|
|
9
|
+
slug: 'pages'
|
|
10
|
+
}]
|
|
11
|
+
};
|
|
12
|
+
it('should allow collection verification routes', () => {
|
|
13
|
+
expect(isPublicAdminRoute({
|
|
14
|
+
adminRoute: '/admin',
|
|
15
|
+
config,
|
|
16
|
+
route: '/admin/users/verify/token'
|
|
17
|
+
})).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it('should not allow verification routes for collections without auth', () => {
|
|
20
|
+
expect(isPublicAdminRoute({
|
|
21
|
+
adminRoute: '/admin',
|
|
22
|
+
config,
|
|
23
|
+
route: '/admin/pages/verify/token'
|
|
24
|
+
})).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
it('should not allow unrelated routes containing the verification segment', () => {
|
|
27
|
+
expect(isPublicAdminRoute({
|
|
28
|
+
adminRoute: '/admin',
|
|
29
|
+
config,
|
|
30
|
+
route: '/admin/custom/verify/dashboard'
|
|
31
|
+
})).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=isPublicAdminRoute.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPublicAdminRoute.spec.js","names":["describe","expect","it","isPublicAdminRoute","config","collections","auth","slug","adminRoute","route","toBe"],"sources":["../../src/utilities/isPublicAdminRoute.spec.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { isPublicAdminRoute } from './isPublicAdminRoute.js'\n\ndescribe('isPublicAdminRoute', () => {\n const config = {\n collections: [{ auth: true, slug: 'users' }, { slug: 'pages' }],\n } as unknown as SanitizedConfig\n\n it('should allow collection verification routes', () => {\n expect(\n isPublicAdminRoute({\n adminRoute: '/admin',\n config,\n route: '/admin/users/verify/token',\n }),\n ).toBe(true)\n })\n\n it('should not allow verification routes for collections without auth', () => {\n expect(\n isPublicAdminRoute({\n adminRoute: '/admin',\n config,\n route: '/admin/pages/verify/token',\n }),\n ).toBe(false)\n })\n\n it('should not allow unrelated routes containing the verification segment', () => {\n expect(\n isPublicAdminRoute({\n adminRoute: '/admin',\n config,\n route: '/admin/custom/verify/dashboard',\n }),\n ).toBe(false)\n })\n})\n"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,kBAAkB,QAAQ;AAEnCH,QAAA,CAAS,sBAAsB;EAC7B,MAAMI,MAAA,GAAS;IACbC,WAAA,EAAa,CAAC;MAAEC,IAAA,EAAM;MAAMC,IAAA,EAAM;IAAQ,GAAG;MAAEA,IAAA,EAAM;IAAQ;EAC/D;EAEAL,EAAA,CAAG,+CAA+C;IAChDD,MAAA,CACEE,kBAAA,CAAmB;MACjBK,UAAA,EAAY;MACZJ,MAAA;MACAK,KAAA,EAAO;IACT,IACAC,IAAI,CAAC;EACT;EAEAR,EAAA,CAAG,qEAAqE;IACtED,MAAA,CACEE,kBAAA,CAAmB;MACjBK,UAAA,EAAY;MACZJ,MAAA;MACAK,KAAA,EAAO;IACT,IACAC,IAAI,CAAC;EACT;EAEAR,EAAA,CAAG,yEAAyE;IAC1ED,MAAA,CACEE,kBAAA,CAAmB;MACjBK,UAAA,EAAY;MACZJ,MAAA;MACAK,KAAA,EAAO;IACT,IACAC,IAAI,CAAC;EACT;AACF","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AdminViewServerProps } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare function AccountView({ initPageResult, params, searchParams }: AdminViewServerProps): Promise<React.JSX.Element>;
|
|
3
|
+
export declare function AccountView({ initPageResult, params, searchParams, user: userWithReadAccess, }: AdminViewServerProps): Promise<React.JSX.Element>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,SAAS,CAAA;AAOhF,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,wBAAsB,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,SAAS,CAAA;AAOhF,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,wBAAsB,WAAW,CAAC,EAChC,cAAc,EACd,MAAM,EACN,YAAY,EACZ,IAAI,EAAE,kBAAkB,GACzB,EAAE,oBAAoB,8BAkKtB"}
|
|
@@ -17,7 +17,8 @@ import { Settings } from './Settings/index.js';
|
|
|
17
17
|
export async function AccountView({
|
|
18
18
|
initPageResult,
|
|
19
19
|
params,
|
|
20
|
-
searchParams
|
|
20
|
+
searchParams,
|
|
21
|
+
user: userWithReadAccess
|
|
21
22
|
}) {
|
|
22
23
|
const {
|
|
23
24
|
languageOptions,
|
|
@@ -91,7 +92,8 @@ export async function AccountView({
|
|
|
91
92
|
renderAllFields: true,
|
|
92
93
|
req,
|
|
93
94
|
schemaPath: collectionConfig.slug,
|
|
94
|
-
skipValidation: true
|
|
95
|
+
skipValidation: true,
|
|
96
|
+
user: userWithReadAccess
|
|
95
97
|
});
|
|
96
98
|
// Fetch document lock state
|
|
97
99
|
const {
|
|
@@ -125,11 +127,11 @@ export async function AccountView({
|
|
|
125
127
|
languageOptions: languageOptions,
|
|
126
128
|
payload: payload,
|
|
127
129
|
theme: theme,
|
|
128
|
-
user:
|
|
130
|
+
user: userWithReadAccess
|
|
129
131
|
}),
|
|
130
132
|
apiURL: formatAdminURL({
|
|
131
133
|
apiRoute: api,
|
|
132
|
-
path: `/${userSlug}
|
|
134
|
+
path: `/${userSlug}/${user.id}`
|
|
133
135
|
}),
|
|
134
136
|
collectionSlug: userSlug,
|
|
135
137
|
currentEditor: currentEditor,
|
|
@@ -139,7 +141,7 @@ export async function AccountView({
|
|
|
139
141
|
hasPublishPermission: hasPublishPermission,
|
|
140
142
|
hasSavePermission: hasSavePermission,
|
|
141
143
|
hasTrashPermission: hasTrashPermission,
|
|
142
|
-
id: user
|
|
144
|
+
id: user.id,
|
|
143
145
|
initialData: data,
|
|
144
146
|
initialState: formState,
|
|
145
147
|
isEditing: true,
|
|
@@ -153,7 +155,8 @@ export async function AccountView({
|
|
|
153
155
|
collectionConfig: collectionConfig,
|
|
154
156
|
hideTabs: true,
|
|
155
157
|
permissions: permissions,
|
|
156
|
-
req: req
|
|
158
|
+
req: req,
|
|
159
|
+
user: userWithReadAccess
|
|
157
160
|
}), /*#__PURE__*/_jsx(HydrateAuthProvider, {
|
|
158
161
|
permissions: permissions
|
|
159
162
|
}), RenderServerComponent({
|
|
@@ -171,7 +174,7 @@ export async function AccountView({
|
|
|
171
174
|
permissions,
|
|
172
175
|
routeSegments: [],
|
|
173
176
|
searchParams,
|
|
174
|
-
user
|
|
177
|
+
user: userWithReadAccess
|
|
175
178
|
}
|
|
176
179
|
}), /*#__PURE__*/_jsx(AccountClient, {})]
|
|
177
180
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderServerComponent","buildFormState","notFound","formatAdminURL","React","DocumentHeader","getDocPreferences","getDocumentData","getDocumentPermissions","getIsLocked","getVersions","EditView","AccountClient","Settings","AccountView","initPageResult","params","searchParams","languageOptions","locale","permissions","req","i18n","payload","config","user","admin","theme","userSlug","routes","api","serverURL","collectionConfig","collections","id","data","collectionSlug","slug","Error","docPreferences","docPermissions","hasDeletePermission","hasPublishPermission","hasSavePermission","hasTrashPermission","state","formState","code","operation","renderAllFields","schemaPath","skipValidation","currentEditor","isLocked","lastUpdateTime","isEditing","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","doc","_jsx","AfterFields","apiURL","apiRoute","path","initialData","initialState","_jsxs","hideTabs","Component","components","views","account","Fallback","importMap","serverProps","routeSegments"],"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewServerProps, DocumentViewServerPropsOnly } from 'payload'\n\nimport { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getDocPreferences } from '../Document/getDocPreferences.js'\nimport { getDocumentData } from '../Document/getDocumentData.js'\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { getIsLocked } from '../Document/getIsLocked.js'\nimport { getVersions } from '../Document/getVersions.js'\nimport { EditView } from '../Edit/index.js'\nimport { AccountClient } from './index.client.js'\nimport { Settings } from './Settings/index.js'\n\nexport async function AccountView({ initPageResult, params, searchParams }: AdminViewServerProps) {\n const {\n languageOptions,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: { theme, user: userSlug },\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = payload?.collections?.[userSlug]?.config\n\n if (collectionConfig && user?.id) {\n // Fetch the data required for the view\n const data = await getDocumentData({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n locale,\n payload,\n req,\n user,\n })\n\n if (!data) {\n throw new Error('not-found')\n }\n\n // Get document preferences\n const docPreferences = await getDocPreferences({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n payload,\n user,\n })\n\n // Get permissions\n const {\n docPermissions,\n hasDeletePermission,\n hasPublishPermission,\n hasSavePermission,\n hasTrashPermission,\n } = await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data,\n req,\n })\n\n // Build initial form state from data\n const { state: formState } = await buildFormState({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n data,\n docPermissions,\n docPreferences,\n locale: locale?.code,\n operation: 'update',\n renderAllFields: true,\n req,\n schemaPath: collectionConfig.slug,\n skipValidation: true,\n })\n\n // Fetch document lock state\n const { currentEditor, isLocked, lastUpdateTime } = await getIsLocked({\n id: user.id,\n collectionConfig,\n isEditing: true,\n req,\n })\n\n // Get all versions required for UI\n const { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount } =\n await getVersions({\n id: user.id,\n collectionConfig,\n doc: data,\n docPermissions,\n locale: locale?.code,\n payload,\n user,\n })\n\n return (\n <DocumentInfoProvider\n AfterFields={\n <Settings\n i18n={i18n}\n languageOptions={languageOptions}\n payload={payload}\n theme={theme}\n user={user}\n />\n }\n apiURL={formatAdminURL({\n apiRoute: api,\n path: `/${userSlug}${user?.id ? `/${user.id}` : ''}`,\n })}\n collectionSlug={userSlug}\n currentEditor={currentEditor}\n docPermissions={docPermissions}\n hasDeletePermission={hasDeletePermission}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n hasTrashPermission={hasTrashPermission}\n id={user?.id}\n initialData={data}\n initialState={formState}\n isEditing\n isLocked={isLocked}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <EditDepthProvider>\n <DocumentHeader\n collectionConfig={collectionConfig}\n hideTabs\n permissions={permissions}\n req={req}\n />\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n Component: config.admin?.components?.views?.account?.Component,\n Fallback: EditView,\n importMap: payload.importMap,\n serverProps: {\n doc: data,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: [],\n searchParams,\n user,\n } satisfies DocumentViewServerPropsOnly,\n })}\n <AccountClient />\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n }\n\n return notFound()\n}\n"],"mappings":";AAEA,SAASA,oBAAoB,EAAEC,iBAAiB,EAAEC,mBAAmB,QAAQ;AAC7E,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,WAAW,QAAQ;AAC5B,SAASC,WAAW,QAAQ;AAC5B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAAS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rBe,eAAA,EAAiBA,eAAA;MACjBd,oBAAA,EAAsBA,oBAAA;MACtBC,iBAAA,EAAmBA,iBAAA;MACnBC,kBAAA,EAAoBA,kBAAA;MACpBV,EAAA,EAAIT,IAAA,EAAMS,EAAA;MACVgC,WAAA,EAAa/B,IAAA;MACbgC,YAAA,EAAcrB,SAAA;MACdS,SAAS;MACTF,QAAA,EAAUA,QAAA;MACVC,cAAA,EAAgBA,cAAA;MAChBG,4BAAA,EAA8BA,4BAAA;MAC9BC,uBAAA,EAAyBA,uBAAA;MACzBC,YAAA,EAAcA,YAAA;gBAEd,aAAAS,KAAA,CAACtE,iBAAA;gCACC+D,IAAA,CAACxD,cAAA;UACC2B,gBAAA,EAAkBA,gBAAA;UAClBqC,QAAQ;UACRjD,WAAA,EAAaA,WAAA;UACbC,GAAA,EAAKA;yBAEPwC,IAAA,CAAC9D,mBAAA;UAAoBqB,WAAA,EAAaA;YACjCpB,qBAAA,CAAsB;UACrBsE,SAAA,EAAW9C,MAAA,CAAOE,KAAK,EAAE6C,UAAA,EAAYC,KAAA,EAAOC,OAAA,EAASH,SAAA;UACrDI,QAAA,EAAU/D,QAAA;UACVgE,SAAA,EAAWpD,OAAA,CAAQoD,SAAS;UAC5BC,WAAA,EAAa;YACXhB,GAAA,EAAKzB,IAAA;YACLqB,eAAA;YACAlC,IAAA;YACAP,cAAA;YACAI,MAAA;YACAH,MAAA;YACAO,OAAA;YACAH,WAAA;YACAyD,aAAA,EAAe,EAAE;YACjB5D,YAAA;YACAQ;UACF;QACF,I,aACAoC,IAAA,CAACjD,aAAA;;;EAIT;EAEA,OAAOV,QAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderServerComponent","buildFormState","notFound","formatAdminURL","React","DocumentHeader","getDocPreferences","getDocumentData","getDocumentPermissions","getIsLocked","getVersions","EditView","AccountClient","Settings","AccountView","initPageResult","params","searchParams","user","userWithReadAccess","languageOptions","locale","permissions","req","i18n","payload","config","admin","theme","userSlug","routes","api","serverURL","collectionConfig","collections","id","data","collectionSlug","slug","Error","docPreferences","docPermissions","hasDeletePermission","hasPublishPermission","hasSavePermission","hasTrashPermission","state","formState","code","operation","renderAllFields","schemaPath","skipValidation","currentEditor","isLocked","lastUpdateTime","isEditing","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","doc","_jsx","AfterFields","apiURL","apiRoute","path","initialData","initialState","_jsxs","hideTabs","Component","components","views","account","Fallback","importMap","serverProps","routeSegments"],"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewServerProps, DocumentViewServerPropsOnly } from 'payload'\n\nimport { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { buildFormState } from '@payloadcms/ui/utilities/buildFormState'\nimport { notFound } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getDocPreferences } from '../Document/getDocPreferences.js'\nimport { getDocumentData } from '../Document/getDocumentData.js'\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { getIsLocked } from '../Document/getIsLocked.js'\nimport { getVersions } from '../Document/getVersions.js'\nimport { EditView } from '../Edit/index.js'\nimport { AccountClient } from './index.client.js'\nimport { Settings } from './Settings/index.js'\n\nexport async function AccountView({\n initPageResult,\n params,\n searchParams,\n user: userWithReadAccess,\n}: AdminViewServerProps) {\n const {\n languageOptions,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: { theme, user: userSlug },\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = payload?.collections?.[userSlug]?.config\n\n if (collectionConfig && user?.id) {\n // Fetch the data required for the view\n const data = await getDocumentData({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n locale,\n payload,\n req,\n user,\n })\n\n if (!data) {\n throw new Error('not-found')\n }\n\n // Get document preferences\n const docPreferences = await getDocPreferences({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n payload,\n user,\n })\n\n // Get permissions\n const {\n docPermissions,\n hasDeletePermission,\n hasPublishPermission,\n hasSavePermission,\n hasTrashPermission,\n } = await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data,\n req,\n })\n\n // Build initial form state from data\n const { state: formState } = await buildFormState({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n data,\n docPermissions,\n docPreferences,\n locale: locale?.code,\n operation: 'update',\n renderAllFields: true,\n req,\n schemaPath: collectionConfig.slug,\n skipValidation: true,\n user: userWithReadAccess,\n })\n\n // Fetch document lock state\n const { currentEditor, isLocked, lastUpdateTime } = await getIsLocked({\n id: user.id,\n collectionConfig,\n isEditing: true,\n req,\n })\n\n // Get all versions required for UI\n const { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount } =\n await getVersions({\n id: user.id,\n collectionConfig,\n doc: data,\n docPermissions,\n locale: locale?.code,\n payload,\n user,\n })\n\n return (\n <DocumentInfoProvider\n AfterFields={\n <Settings\n i18n={i18n}\n languageOptions={languageOptions}\n payload={payload}\n theme={theme}\n user={userWithReadAccess}\n />\n }\n apiURL={formatAdminURL({\n apiRoute: api,\n path: `/${userSlug}/${user.id}`,\n })}\n collectionSlug={userSlug}\n currentEditor={currentEditor}\n docPermissions={docPermissions}\n hasDeletePermission={hasDeletePermission}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n hasTrashPermission={hasTrashPermission}\n id={user.id}\n initialData={data}\n initialState={formState}\n isEditing\n isLocked={isLocked}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <EditDepthProvider>\n <DocumentHeader\n collectionConfig={collectionConfig}\n hideTabs\n permissions={permissions}\n req={req}\n user={userWithReadAccess}\n />\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n Component: config.admin?.components?.views?.account?.Component,\n Fallback: EditView,\n importMap: payload.importMap,\n serverProps: {\n doc: data,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: [],\n searchParams,\n user: userWithReadAccess,\n } satisfies DocumentViewServerPropsOnly,\n })}\n <AccountClient />\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n }\n\n return notFound()\n}\n"],"mappings":";AAEA,SAASA,oBAAoB,EAAEC,iBAAiB,EAAEC,mBAAmB,QAAQ;AAC7E,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,WAAW,QAAQ;AAC5B,SAASC,WAAW,QAAQ;AAC5B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAEzB,OAAO,eAAeC,YAAY;EAChCC,cAAc;EACdC,MAAM;EACNC,YAAY;EACZC,IAAA,EAAMC;AAAkB,CACH;EACrB,MAAM;IACJC,eAAe;IACfC,MAAM;IACNC,WAAW;IACXC,GAAG;IACHA,GAAA,EAAK;MACHC,IAAI;MACJC,OAAO;MACPA,OAAA,EAAS;QAAEC;MAAM,CAAE;MACnBR;IAAI;EACL,CACF,GAAGH,cAAA;EAEJ,MAAM;IACJY,KAAA,EAAO;MAAEC,KAAK;MAAEV,IAAA,EAAMW;IAAQ,CAAE;IAChCC,MAAA,EAAQ;MAAEC;IAAG,CAAE;IACfC;EAAS,CACV,GAAGN,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CAACzD,cAAA;UACC4B,gBAAA,EAAkBA,gBAAA;UAClBqC,QAAQ;UACRhD,WAAA,EAAaA,WAAA;UACbC,GAAA,EAAKA,GAAA;UACLL,IAAA,EAAMC;yBAER2C,IAAA,CAAC/D,mBAAA;UAAoBuB,WAAA,EAAaA;YACjCtB,qBAAA,CAAsB;UACrBuE,SAAA,EAAW7C,MAAA,CAAOC,KAAK,EAAE6C,UAAA,EAAYC,KAAA,EAAOC,OAAA,EAASH,SAAA;UACrDI,QAAA,EAAUhE,QAAA;UACViE,SAAA,EAAWnD,OAAA,CAAQmD,SAAS;UAC5BC,WAAA,EAAa;YACXhB,GAAA,EAAKzB,IAAA;YACLqB,eAAA;YACAjC,IAAA;YACAT,cAAA;YACAM,MAAA;YACAL,MAAA;YACAS,OAAA;YACAH,WAAA;YACAwD,aAAA,EAAe,EAAE;YACjB7D,YAAA;YACAC,IAAA,EAAMC;UACR;QACF,I,aACA2C,IAAA,CAAClD,aAAA;;;EAIT;EAEA,OAAOV,QAAA;AACT","ignoreList":[]}
|
|
@@ -17,7 +17,8 @@ export const buildBrowseByFolderView = async args => {
|
|
|
17
17
|
isInDrawer,
|
|
18
18
|
params,
|
|
19
19
|
query: queryFromArgs,
|
|
20
|
-
searchParams
|
|
20
|
+
searchParams,
|
|
21
|
+
user: userWithReadAccess
|
|
21
22
|
} = args;
|
|
22
23
|
const {
|
|
23
24
|
locale: fullLocale,
|
|
@@ -28,8 +29,7 @@ export const buildBrowseByFolderView = async args => {
|
|
|
28
29
|
payload: {
|
|
29
30
|
config
|
|
30
31
|
},
|
|
31
|
-
query: queryFromReq
|
|
32
|
-
user
|
|
32
|
+
query: queryFromReq
|
|
33
33
|
},
|
|
34
34
|
visibleEntities
|
|
35
35
|
} = initPageResult;
|
|
@@ -109,7 +109,7 @@ export const buildBrowseByFolderView = async args => {
|
|
|
109
109
|
permissions,
|
|
110
110
|
searchParams,
|
|
111
111
|
subfolders,
|
|
112
|
-
user
|
|
112
|
+
user: userWithReadAccess
|
|
113
113
|
};
|
|
114
114
|
// const folderViewSlots = renderFolderViewSlots({
|
|
115
115
|
// clientProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildView.js","names":["DefaultBrowseByFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","PREFERENCE_KEYS","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","foldersSlug","slug","allowReadCollectionSlugs","filter","collectionSlug","collections","read","includes","relationTo","JSON","parse","undefined","collectionsToDisplay","Array","isArray","routes","admin","adminRoute","browseByFolderPreferences","key","BROWSE_BY_FOLDER","value","sort","sortPreference","viewPreference","breadcrumbs","documents","folderAssignedCollections","FolderResultsComponent","subfolders","displayAs","resolvedFolderID","length","id","path","serverProps","allAvailableCollectionSlugs","availableActiveCollectionFolderSlugs","allowCreateCollectionSlugs","create","View","_jsxs","_Fragment","_jsx","clientProps","activeCollectionFolderSlugs","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 { PREFERENCE_KEYS } from 'payload/shared'\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 foldersSlug = config.folders.slug\n\n /**\n * All visiible folder enabled collection slugs that the user has read permissions for.\n */\n const allowReadCollectionSlugs = browseByFolderSlugsFromArgs.filter(\n (collectionSlug) =>\n permissions?.collections?.[collectionSlug]?.read &&\n visibleEntities.collections.includes(collectionSlug),\n )\n\n const query =\n queryFromArgs ||\n ((queryFromReq\n ? {\n ...queryFromReq,\n relationTo:\n typeof queryFromReq?.relationTo === 'string'\n ? JSON.parse(queryFromReq.relationTo)\n : undefined,\n }\n : {}) as ListQuery)\n\n /**\n * If a folderID is provided and the relationTo query param exists,\n * we filter the collection slugs to only those that are allowed to be read.\n *\n * If no folderID is provided, only folders should be active and displayed (the root view).\n */\n let collectionsToDisplay: string[] = []\n if (folderID && Array.isArray(query?.relationTo)) {\n collectionsToDisplay = query.relationTo.filter(\n (slug) => allowReadCollectionSlugs.includes(slug) || slug === foldersSlug,\n )\n } else if (folderID) {\n collectionsToDisplay = [...allowReadCollectionSlugs, foldersSlug]\n } else {\n collectionsToDisplay = [foldersSlug]\n }\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: PREFERENCE_KEYS.BROWSE_BY_FOLDER,\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys = browseByFolderPreferences?.sort || 'name'\n const viewPreference = browseByFolderPreferences?.viewPreference || 'grid'\n\n const { breadcrumbs, documents, folderAssignedCollections, FolderResultsComponent, subfolders } =\n await getFolderResultsComponentAndData({\n browseByFolder: true,\n collectionsToDisplay,\n displayAs: viewPreference,\n folderAssignedCollections: collectionsToDisplay.filter((slug) => slug !== foldersSlug) || [],\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 }),\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 // Filter down allCollectionFolderSlugs by the ones the current folder is assingned to\n const allAvailableCollectionSlugs =\n folderID && Array.isArray(folderAssignedCollections) && folderAssignedCollections.length\n ? allowReadCollectionSlugs.filter((slug) => folderAssignedCollections.includes(slug))\n : allowReadCollectionSlugs\n\n // Filter down activeCollectionFolderSlugs by the ones the current folder is assingned to\n const availableActiveCollectionFolderSlugs = collectionsToDisplay.filter((slug) => {\n if (slug === foldersSlug) {\n return permissions?.collections?.[foldersSlug]?.read\n } else {\n return !folderAssignedCollections || folderAssignedCollections.includes(slug)\n }\n })\n\n // Documents cannot be created without a parent folder in this view\n const allowCreateCollectionSlugs = (\n resolvedFolderID ? [foldersSlug, ...allAvailableCollectionSlugs] : [foldersSlug]\n ).filter((collectionSlug) => {\n if (collectionSlug === foldersSlug) {\n return permissions?.collections?.[foldersSlug]?.create\n }\n return (\n permissions?.collections?.[collectionSlug]?.create &&\n visibleEntities.collections.includes(collectionSlug)\n )\n })\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n activeCollectionFolderSlugs: availableActiveCollectionFolderSlugs,\n allCollectionFolderSlugs: allAvailableCollectionSlugs,\n allowCreateCollectionSlugs,\n baseFolderPath: `/browse-by-folder`,\n breadcrumbs,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderAssignedCollections,\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,SAASC,eAAe,QAAQ;AAChC,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;IACV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;UACAC,eAAA;UACAgD,SAAA;UACA/C,mBAAA;UACAgD,yBAAA;UACAqB,eAAA,EAAiBvD,MAAA,CAAOI,OAAO,CAACoD,SAAS;UACzCrE,QAAA,EAAUmD,gBAAA,IAAoB;UAC9BH,sBAAA;UACAN,IAAA,EAAMC,cAAA;UACNM,UAAA;UACAL;QACF;QACA;QACA0B,QAAA,EAAUtF,yBAAA;QACVuF,SAAA,EAAW3D,OAAA,CAAQ2D,SAAS;QAC5BhB;MACF;;EAGN;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"buildView.js","names":["DefaultBrowseByFolderView","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","PREFERENCE_KEYS","React","buildBrowseByFolderView","args","browseByFolderSlugs","browseByFolderSlugsFromArgs","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","params","query","queryFromArgs","searchParams","user","userWithReadAccess","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","visibleEntities","folders","browseByFolder","Error","foldersSlug","slug","allowReadCollectionSlugs","filter","collectionSlug","collections","read","includes","relationTo","JSON","parse","undefined","collectionsToDisplay","Array","isArray","routes","admin","adminRoute","browseByFolderPreferences","key","BROWSE_BY_FOLDER","value","sort","sortPreference","viewPreference","breadcrumbs","documents","folderAssignedCollections","FolderResultsComponent","subfolders","displayAs","resolvedFolderID","length","id","path","serverProps","allAvailableCollectionSlugs","availableActiveCollectionFolderSlugs","allowCreateCollectionSlugs","create","View","_jsxs","_Fragment","_jsx","clientProps","activeCollectionFolderSlugs","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 { PREFERENCE_KEYS } from 'payload/shared'\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 user: userWithReadAccess,\n } = args\n\n const {\n locale: fullLocale,\n permissions,\n req: {\n i18n,\n payload,\n payload: { config },\n query: queryFromReq,\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 foldersSlug = config.folders.slug\n\n /**\n * All visiible folder enabled collection slugs that the user has read permissions for.\n */\n const allowReadCollectionSlugs = browseByFolderSlugsFromArgs.filter(\n (collectionSlug) =>\n permissions?.collections?.[collectionSlug]?.read &&\n visibleEntities.collections.includes(collectionSlug),\n )\n\n const query =\n queryFromArgs ||\n ((queryFromReq\n ? {\n ...queryFromReq,\n relationTo:\n typeof queryFromReq?.relationTo === 'string'\n ? JSON.parse(queryFromReq.relationTo)\n : undefined,\n }\n : {}) as ListQuery)\n\n /**\n * If a folderID is provided and the relationTo query param exists,\n * we filter the collection slugs to only those that are allowed to be read.\n *\n * If no folderID is provided, only folders should be active and displayed (the root view).\n */\n let collectionsToDisplay: string[] = []\n if (folderID && Array.isArray(query?.relationTo)) {\n collectionsToDisplay = query.relationTo.filter(\n (slug) => allowReadCollectionSlugs.includes(slug) || slug === foldersSlug,\n )\n } else if (folderID) {\n collectionsToDisplay = [...allowReadCollectionSlugs, foldersSlug]\n } else {\n collectionsToDisplay = [foldersSlug]\n }\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: PREFERENCE_KEYS.BROWSE_BY_FOLDER,\n req: initPageResult.req,\n value: {\n sort: query?.sort as FolderSortKeys,\n },\n })\n\n const sortPreference: FolderSortKeys = browseByFolderPreferences?.sort || 'name'\n const viewPreference = browseByFolderPreferences?.viewPreference || 'grid'\n\n const { breadcrumbs, documents, folderAssignedCollections, FolderResultsComponent, subfolders } =\n await getFolderResultsComponentAndData({\n browseByFolder: true,\n collectionsToDisplay,\n displayAs: viewPreference,\n folderAssignedCollections: collectionsToDisplay.filter((slug) => slug !== foldersSlug) || [],\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 }),\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: userWithReadAccess,\n }\n\n // const folderViewSlots = renderFolderViewSlots({\n // clientProps: {\n // },\n // description: staticDescription,\n // payload,\n // serverProps,\n // })\n\n // Filter down allCollectionFolderSlugs by the ones the current folder is assingned to\n const allAvailableCollectionSlugs =\n folderID && Array.isArray(folderAssignedCollections) && folderAssignedCollections.length\n ? allowReadCollectionSlugs.filter((slug) => folderAssignedCollections.includes(slug))\n : allowReadCollectionSlugs\n\n // Filter down activeCollectionFolderSlugs by the ones the current folder is assingned to\n const availableActiveCollectionFolderSlugs = collectionsToDisplay.filter((slug) => {\n if (slug === foldersSlug) {\n return permissions?.collections?.[foldersSlug]?.read\n } else {\n return !folderAssignedCollections || folderAssignedCollections.includes(slug)\n }\n })\n\n // Documents cannot be created without a parent folder in this view\n const allowCreateCollectionSlugs = (\n resolvedFolderID ? [foldersSlug, ...allAvailableCollectionSlugs] : [foldersSlug]\n ).filter((collectionSlug) => {\n if (collectionSlug === foldersSlug) {\n return permissions?.collections?.[foldersSlug]?.create\n }\n return (\n permissions?.collections?.[collectionSlug]?.create &&\n visibleEntities.collections.includes(collectionSlug)\n )\n })\n\n return {\n View: (\n <>\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n clientProps: {\n // ...folderViewSlots,\n activeCollectionFolderSlugs: availableActiveCollectionFolderSlugs,\n allCollectionFolderSlugs: allAvailableCollectionSlugs,\n allowCreateCollectionSlugs,\n baseFolderPath: `/browse-by-folder`,\n breadcrumbs,\n disableBulkDelete,\n disableBulkEdit,\n documents,\n enableRowSelections,\n folderAssignedCollections,\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,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;EAEA,OAAO;IACLoC,IAAA,eACEC,KAAA,CAAAC,SAAA;8BACEC,IAAA,CAAC/E,mBAAA;QAAoB0B,WAAA,EAAaA;UACjCzB,qBAAA,CAAsB;QACrB+E,WAAA,EAAa;UACX;UACAC,2BAAA,EAA6BR,oCAAA;UAC7BS,wBAAA,EAA0BV,2BAAA;UAC1BE,0BAAA;UACAS,cAAA,EAAgB,mBAAmB;UACnCtB,WAAA;UACAjD,iBAAA;UACAC,eAAA;UACAiD,SAAA;UACAhD,mBAAA;UACAiD,yBAAA;UACAqB,eAAA,EAAiBtD,MAAA,CAAOG,OAAO,CAACoD,SAAS;UACzCtE,QAAA,EAAUoD,gBAAA,IAAoB;UAC9BH,sBAAA;UACAN,IAAA,EAAMC,cAAA;UACNM,UAAA;UACAL;QACF;QACA;QACA0B,QAAA,EAAUvF,yBAAA;QACVwF,SAAA,EAAW1D,OAAA,CAAQ0D,SAAS;QAC5BhB;MACF;;EAGN;AACF","ignoreList":[]}
|
|
@@ -19,7 +19,8 @@ export const buildCollectionFolderView = async args => {
|
|
|
19
19
|
overrideEntityVisibility,
|
|
20
20
|
params,
|
|
21
21
|
query: queryFromArgs,
|
|
22
|
-
searchParams
|
|
22
|
+
searchParams,
|
|
23
|
+
user: userWithReadAccess
|
|
23
24
|
} = args;
|
|
24
25
|
const {
|
|
25
26
|
collectionConfig,
|
|
@@ -34,8 +35,7 @@ export const buildCollectionFolderView = async args => {
|
|
|
34
35
|
payload: {
|
|
35
36
|
config
|
|
36
37
|
},
|
|
37
|
-
query: queryFromReq
|
|
38
|
-
user
|
|
38
|
+
query: queryFromReq
|
|
39
39
|
},
|
|
40
40
|
visibleEntities
|
|
41
41
|
} = initPageResult;
|
|
@@ -101,7 +101,7 @@ export const buildCollectionFolderView = async args => {
|
|
|
101
101
|
permissions,
|
|
102
102
|
searchParams,
|
|
103
103
|
subfolders,
|
|
104
|
-
user
|
|
104
|
+
user: userWithReadAccess
|
|
105
105
|
};
|
|
106
106
|
// We could support slots in the folder view in the future
|
|
107
107
|
// const folderViewSlots = renderFolderViewSlots({
|
|
@@ -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","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 }),\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;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A;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,MACJkC,gBAAA,IAAoB9B,WAAA,EAAaU,WAAA,GAAcb,cAAA,CAAe,EAAE8C,MAAA,GAC5D9C,cAAA,GACA,KACL,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;YACAsC,yBAAA;YACAuB,eAAA,EAAiB3C,MAAA,CAAOI,OAAO,CAACwC,SAAS;YACzC7D,QAAA,EAAU2C,gBAAA,IAAoB;YAC9BL,sBAAA;YACAU,MAAA;YACAnB,IAAA,EAAMC,cAAA;YACNS,UAAA;YACAR;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","HydrateAuthProvider","RenderServerComponent","getFolderResultsComponentAndData","upsertPreferences","formatAdminURL","redirect","React","buildCollectionFolderView","args","disableBulkDelete","disableBulkEdit","enableRowSelections","folderID","initPageResult","isInDrawer","overrideEntityVisibility","params","query","queryFromArgs","searchParams","user","userWithReadAccess","collectionConfig","slug","collectionSlug","locale","fullLocale","permissions","req","i18n","payload","config","queryFromReq","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","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 user: userWithReadAccess,\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 },\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 }),\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: userWithReadAccess,\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,GAA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A,CAAAC,SAAA;gCACEC,IAAA,CAACjE,mBAAA;UAAoB2B,WAAA,EAAaA;YACjC1B,qBAAA,CAAsB;UACrBiE,WAAA,EAAa;YACX;YACAC,wBAAA,EAA0B,CAACpC,MAAA,CAAOG,OAAO,CAACX,IAAI,EAAEC,cAAA,CAAe;YAC/D4C,0BAAA,EAA4B,CAC1BzC,WAAA,EAAaS,WAAA,GAAcL,MAAA,CAAOG,OAAO,CAACX,IAAI,CAAC,EAAE8C,MAAA,GAC7CtC,MAAA,CAAOG,OAAO,CAACX,IAAI,GACnB,MACJiC,gBAAA,IAAoB7B,WAAA,EAAaS,WAAA,GAAcZ,cAAA,CAAe,EAAE6C,MAAA,GAC5D7C,cAAA,GACA,KACL,CAAC8C,MAAM,CAACC,OAAA;YACTC,cAAA,EAAgB,gBAAgBhD,cAAA,IAAkBO,MAAA,CAAOG,OAAO,CAACX,IAAI,EAAE;YACvEyB,WAAA;YACAxB,cAAA;YACAf,iBAAA;YACAC,eAAA;YACAuC,SAAA;YACAtC,mBAAA;YACAuC,yBAAA;YACAuB,eAAA,EAAiB1C,MAAA,CAAOG,OAAO,CAACwC,SAAS;YACzC9D,QAAA,EAAU4C,gBAAA,IAAoB;YAC9BL,sBAAA;YACAU,MAAA;YACAnB,IAAA,EAAMC,cAAA;YACNS,UAAA;YACAR;UACF;UACA;UACA+B,QAAA,EAAU5E,2BAAA;UACV6E,SAAA,EAAW9C,OAAA,CAAQ8C,SAAS;UAC5BhB;QACF;;IAGN;EACF;EAEA,MAAM,IAAIzB,KAAA,CAAM;AAClB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAO3D,OAAO,cAAc,CAAA;AAIrB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAO3D,OAAO,cAAc,CAAA;AAIrB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,8BAkDrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RenderServerComponent","React","ModularDashboardClient","getItemsFromConfig","getItemsFromPreferences","extractLocaleData","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","cookies","locale","permissions","req","initPageResult","i18n","layout","serverLayout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","widgetConfig","find","widget","slug","widgetData","fields","length","data","component","Component","serverProps","item","clientWidgets","_","__","label","rest","t","_jsx","clientLayout"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type { ClientWidget, Field, WidgetServerProps } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport type { DashboardViewServerProps } from '../index.js'\nimport type { WidgetInstanceClient } from './index.client.js'\n\nimport { ModularDashboardClient } from './index.client.js'\nimport { getItemsFromConfig } from './utils/getItemsFromConfig.js'\nimport { getItemsFromPreferences } from './utils/getItemsFromPreferences.js'\nimport { extractLocaleData } from './utils/localeUtils.js'\nimport './index.scss'\n\ntype ServerLayout = WidgetInstanceClient[]\n\nexport async function ModularDashboard(props: DashboardViewServerProps) {\n const { defaultLayout = [], widgets = [] } = props.payload.config.admin.dashboard || {}\n const { importMap } = props.payload\n const { user } = props\n const { cookies, locale, permissions, req } = props.initPageResult\n const { i18n } = req\n\n const layout =\n (await getItemsFromPreferences(props.payload, user)) ??\n (await getItemsFromConfig(defaultLayout, req, widgets))\n\n const serverLayout: ServerLayout = layout.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n const widgetData = widgetConfig?.fields?.length\n ? extractLocaleData(layoutItem.data || {}, req.locale || 'en', widgetConfig.fields as Field[])\n : layoutItem.data || {}\n\n return {\n component: RenderServerComponent({\n Component: widgetConfig?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n widgetData,\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n // Resolve function labels to static labels for client components\n const clientWidgets: ClientWidget[] = widgets.map((widget) => {\n const { Component: _, fields: __, label, ...rest } = widget\n return {\n ...rest,\n label: typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n })\n\n return (\n <div>\n <ModularDashboardClient clientLayout={serverLayout} widgets={clientWidgets} />\n </div>\n )\n}\n"],"mappings":";AAGA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAKlB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,iBAAiB,QAAQ;AAKlC,OAAO,eAAeC,iBAAiBC,KAA+B;EACpE,MAAM;IAAEC,aAAA,GAAgB,EAAE;IAAEC,OAAA,GAAU;EAAE,CAAE,GAAGF,KAAA,CAAMG,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EACtF,MAAM;IAAEC;EAAS,CAAE,GAAGP,KAAA,CAAMG,OAAO;EACnC,MAAM;IAAEK;EAAI,CAAE,GAAGR,KAAA;EACjB,MAAM;IAAES,OAAO;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGZ,KAAA,CAAMa,cAAc;EAClE,MAAM;IAAEC;EAAI,CAAE,GAAGF,GAAA;EAEjB,MAAMG,MAAA,GACJ,OAAOlB,uBAAA,CAAwBG,KAAA,CAAMG,OAAO,EAAEK,IAAA,OAC7C,MAAMZ,kBAAA,CAAmBK,aAAA,EAAeW,GAAA,EAAKV,OAAA;EAEhD,MAAMc,YAAA,GAA6BD,MAAA,CAAOE,GAAG,CAAEC,UAAA;IAC7C,MAAMC,UAAA,GAAaD,UAAA,CAAWE,EAAE,CAACC,KAAK,CAAC,GAAGH,UAAA,CAAWE,EAAE,CAACE,WAAW,CAAC;IACpE,MAAMC,YAAA,GAAerB,OAAA,CAAQsB,IAAI,CAAEC,MAAA,IAAWA,MAAA,CAAOC,IAAI,KAAKP,UAAA;IAC9D,MAAMQ,UAAA,GAAaJ,YAAA,EAAcK,MAAA,EAAQC,MAAA,GACrC/B,iBAAA,CAAkBoB,UAAA,CAAWY,IAAI,IAAI,CAAC,GAAGlB,GAAA,CAAIF,MAAM,IAAI,MAAMa,YAAA,CAAaK,MAAM,IAChFV,UAAA,CAAWY,IAAI,IAAI,CAAC;IAExB,OAAO;MACLC,SAAA,EAAWtC,qBAAA,CAAsB;QAC/BuC,SAAA,EAAWT,YAAA,EAAcS,SAAA;QACzBzB,SAAA;QACA0B,WAAA,EAAa;UACXxB,OAAA;UACAC,MAAA;UACAC,WAAA;UACAC,GAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["RenderServerComponent","React","ModularDashboardClient","getItemsFromConfig","getItemsFromPreferences","extractLocaleData","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","cookies","locale","permissions","req","initPageResult","i18n","layout","serverLayout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","widgetConfig","find","widget","slug","widgetData","fields","length","data","component","Component","serverProps","item","clientWidgets","_","__","label","rest","t","_jsx","clientLayout"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type { ClientWidget, Field, WidgetServerProps } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport type { DashboardViewServerProps } from '../index.js'\nimport type { WidgetInstanceClient } from './index.client.js'\n\nimport { ModularDashboardClient } from './index.client.js'\nimport { getItemsFromConfig } from './utils/getItemsFromConfig.js'\nimport { getItemsFromPreferences } from './utils/getItemsFromPreferences.js'\nimport { extractLocaleData } from './utils/localeUtils.js'\nimport './index.scss'\n\ntype ServerLayout = WidgetInstanceClient[]\n\nexport async function ModularDashboard(props: DashboardViewServerProps) {\n const { defaultLayout = [], widgets = [] } = props.payload.config.admin.dashboard || {}\n const { importMap } = props.payload\n const { user } = props\n const { cookies, locale, permissions, req } = props.initPageResult\n const { i18n } = req\n\n const layout =\n (await getItemsFromPreferences(props.payload, user)) ??\n (await getItemsFromConfig(defaultLayout, req, widgets))\n\n const serverLayout: ServerLayout = layout.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n const widgetData = widgetConfig?.fields?.length\n ? extractLocaleData(layoutItem.data || {}, req.locale || 'en', widgetConfig.fields as Field[])\n : layoutItem.data || {}\n\n return {\n component: RenderServerComponent({\n Component: widgetConfig?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n user,\n widgetData,\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n // Resolve function labels to static labels for client components\n const clientWidgets: ClientWidget[] = widgets.map((widget) => {\n const { Component: _, fields: __, label, ...rest } = widget\n return {\n ...rest,\n label: typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n })\n\n return (\n <div>\n <ModularDashboardClient clientLayout={serverLayout} widgets={clientWidgets} />\n </div>\n )\n}\n"],"mappings":";AAGA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAKlB,SAASC,sBAAsB,QAAQ;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;QACzBzB,SAAA;QACA0B,WAAA,EAAa;UACXxB,OAAA;UACAC,MAAA;UACAC,WAAA;UACAC,GAAA;UACAJ,IAAA;UACAmB,UAAA;UACAR;QACF;MACF;MACAe,IAAA,EAAMhB;IACR;EACF;EAEA;EACA,MAAMiB,aAAA,GAAgCjC,OAAA,CAAQe,GAAG,CAAEQ,MAAA;IACjD,MAAM;MAAEO,SAAA,EAAWI,CAAC;MAAER,MAAA,EAAQS,EAAE;MAAEC,KAAK;MAAE,GAAGC;IAAA,CAAM,GAAGd,MAAA;IACrD,OAAO;MACL,GAAGc,IAAI;MACPD,KAAA,EAAO,OAAOA,KAAA,KAAU,aAAaA,KAAA,CAAM;QAAExB,IAAA;QAAM0B,CAAA,EAAG1B,IAAA,CAAK0B;MAAe,KAAKF;IACjF;EACF;EAEA,oBACEG,IAAA,CAAC;cACC,aAAAA,IAAA,CAAC9C,sBAAA;MAAuB+C,YAAA,EAAc1B,YAAA;MAAcd,OAAA,EAASiC;;;AAGnE","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAE1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAIhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAE1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,CAgC5C,CAAA"}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js
CHANGED
|
@@ -7,7 +7,8 @@ export const getDefaultLayoutHandler = async ({
|
|
|
7
7
|
cookies,
|
|
8
8
|
locale,
|
|
9
9
|
permissions,
|
|
10
|
-
req
|
|
10
|
+
req,
|
|
11
|
+
user
|
|
11
12
|
}) => {
|
|
12
13
|
if (!req.user) {
|
|
13
14
|
throw new Error('Unauthorized');
|
|
@@ -31,6 +32,7 @@ export const getDefaultLayoutHandler = async ({
|
|
|
31
32
|
locale,
|
|
32
33
|
permissions,
|
|
33
34
|
req,
|
|
35
|
+
user,
|
|
34
36
|
widgetData: layoutItem.data || {},
|
|
35
37
|
widgetSlug
|
|
36
38
|
}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","cookies","locale","permissions","req","user","Error","defaultLayout","widgets","payload","config","admin","dashboard","importMap","layoutItems","getItemsFromConfig","layout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","serverProps","widgetData","data","item","widgetInstances","widgetInstance","index","w","maxWidth","minWidth","width"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"sourcesContent":["import type {\n DashboardConfig,\n PayloadRequest,\n ServerFunction,\n Widget,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\n\nimport type { WidgetInstanceClient, WidgetItem } from '../index.client.js'\n\nexport type GetDefaultLayoutServerFnArgs = Record<string, never>\n\nexport type GetDefaultLayoutServerFnReturnType = {\n layout: WidgetInstanceClient[]\n}\n\n/**\n * Server function to get the default dashboard layout on-demand.\n * Used when resetting the dashboard to its default configuration.\n */\nexport const getDefaultLayoutHandler: ServerFunction<\n GetDefaultLayoutServerFnArgs,\n Promise<GetDefaultLayoutServerFnReturnType>\n> = async ({ cookies, locale, permissions, req }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { defaultLayout = [], widgets = [] } = req.payload.config.admin.dashboard || {}\n const { importMap } = req.payload\n\n const layoutItems = await getItemsFromConfig(defaultLayout, req, widgets)\n\n const layout: WidgetInstanceClient[] = layoutItems.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n widgetData: layoutItem.data || {},\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n return { layout }\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Pick<Widget, 'maxWidth' | 'minWidth' | 'slug'>[],\n): Promise<WidgetItem[]> {\n let widgetInstances\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((w) => w.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n data: widgetInstance.data,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":"AAQA,SAASA,qBAAqB,QAAQ;AAUtC;;;;AAIA,OAAO,MAAMC,uBAAA,GAGT,MAAAA,CAAO;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC;
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","cookies","locale","permissions","req","user","Error","defaultLayout","widgets","payload","config","admin","dashboard","importMap","layoutItems","getItemsFromConfig","layout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","serverProps","widgetData","data","item","widgetInstances","widgetInstance","index","w","maxWidth","minWidth","width"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"sourcesContent":["import type {\n DashboardConfig,\n PayloadRequest,\n ServerFunction,\n Widget,\n WidgetServerProps,\n} from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\n\nimport type { WidgetInstanceClient, WidgetItem } from '../index.client.js'\n\nexport type GetDefaultLayoutServerFnArgs = Record<string, never>\n\nexport type GetDefaultLayoutServerFnReturnType = {\n layout: WidgetInstanceClient[]\n}\n\n/**\n * Server function to get the default dashboard layout on-demand.\n * Used when resetting the dashboard to its default configuration.\n */\nexport const getDefaultLayoutHandler: ServerFunction<\n GetDefaultLayoutServerFnArgs,\n Promise<GetDefaultLayoutServerFnReturnType>\n> = async ({ cookies, locale, permissions, req, user }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { defaultLayout = [], widgets = [] } = req.payload.config.admin.dashboard || {}\n const { importMap } = req.payload\n\n const layoutItems = await getItemsFromConfig(defaultLayout, req, widgets)\n\n const layout: WidgetInstanceClient[] = layoutItems.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n user,\n widgetData: layoutItem.data || {},\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n return { layout }\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Pick<Widget, 'maxWidth' | 'minWidth' | 'slug'>[],\n): Promise<WidgetItem[]> {\n let widgetInstances\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((w) => w.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n data: widgetInstance.data,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":"AAQA,SAASA,qBAAqB,QAAQ;AAUtC;;;;AAIA,OAAO,MAAMC,uBAAA,GAGT,MAAAA,CAAO;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC,GAAG;EAAEC;AAAI,CAAE;EACpD,IAAI,CAACD,GAAA,CAAIC,IAAI,EAAE;IACb,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAM;IAAEC,aAAA,GAAgB,EAAE;IAAEC,OAAA,GAAU;EAAE,CAAE,GAAGJ,GAAA,CAAIK,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EACpF,MAAM;IAAEC;EAAS,CAAE,GAAGT,GA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UX,MAAA,EAAQW,QAAA,IAAY;MAC9BC,KAAA,EAAOL,cAAA,CAAeK,KAAK,IAAI;IACjC;EACF;AACF","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,cAAc,EAAqB,MAAM,SAAS,CAAA;AAGvE,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,cAAc,EAAqB,MAAM,SAAS,CAAA;AAGvE,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,CA+E/B,CAAA"}
|
|
@@ -10,6 +10,7 @@ export const renderWidgetHandler = ({
|
|
|
10
10
|
locale,
|
|
11
11
|
permissions,
|
|
12
12
|
req,
|
|
13
|
+
user,
|
|
13
14
|
widgetData,
|
|
14
15
|
widgetSlug
|
|
15
16
|
}) => {
|
|
@@ -45,6 +46,7 @@ export const renderWidgetHandler = ({
|
|
|
45
46
|
locale,
|
|
46
47
|
permissions,
|
|
47
48
|
req,
|
|
49
|
+
user,
|
|
48
50
|
widgetData: localeFilteredData,
|
|
49
51
|
widgetSlug
|
|
50
52
|
};
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.js","names":["RenderServerComponent","React","extractLocaleData","renderWidgetHandler","cookies","locale","permissions","req","
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.js","names":["RenderServerComponent","React","extractLocaleData","renderWidgetHandler","cookies","locale","permissions","req","user","widgetData","widgetSlug","Error","widgets","payload","config","admin","dashboard","importMap","widgetConfig","find","widget","slug","component","createElement","style","background","border","borderRadius","color","padding","textAlign","localeFilteredData","fields","length","serverProps","Component","error","errorMessage","message","String","logger","err","msg"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"sourcesContent":["import type { Field, ServerFunction, WidgetServerProps } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport React from 'react'\n\nimport { extractLocaleData } from '../utils/localeUtils.js'\n\nexport type RenderWidgetServerFnArgs = {\n /**\n * Instance-specific data for this widget\n */\n widgetData?: Record<string, unknown>\n /**\n * The slug of the widget to render\n */\n widgetSlug: string\n}\n\nexport type RenderWidgetServerFnReturnType = {\n component: React.ReactNode\n}\n\n/**\n * Server function to render a widget on-demand.\n * Similar to render-field but specifically for dashboard widgets.\n */\nexport const renderWidgetHandler: ServerFunction<\n RenderWidgetServerFnArgs,\n RenderWidgetServerFnReturnType\n> = ({ cookies, locale, permissions, req, user, widgetData, widgetSlug }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { widgets } = req.payload.config.admin.dashboard\n const { importMap } = req.payload\n\n // Find the widget configuration\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n\n if (!widgetConfig) {\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--theme-elevation-50)',\n border: '1px solid var(--theme-elevation-200)',\n borderRadius: '4px',\n color: 'var(--theme-text)',\n padding: '20px',\n textAlign: 'center',\n },\n },\n `Widget \"${widgetSlug}\" not found`,\n ),\n }\n }\n\n try {\n const localeFilteredData = widgetConfig.fields?.length\n ? extractLocaleData(widgetData || {}, req.locale || 'en', widgetConfig.fields as Field[])\n : widgetData || {}\n\n const serverProps: WidgetServerProps = {\n cookies,\n locale,\n permissions,\n req,\n user,\n widgetData: localeFilteredData,\n widgetSlug,\n }\n\n // Render the widget server component\n const component = RenderServerComponent({\n Component: widgetConfig.Component,\n importMap,\n serverProps,\n })\n\n return { component }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n\n req.payload.logger.error({\n err: error,\n msg: `Error rendering widget \"${widgetSlug}\": ${errorMessage}`,\n })\n\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--theme-error-50)',\n border: '1px solid var(--theme-error-200)',\n borderRadius: '4px',\n color: 'var(--theme-error-text)',\n padding: '20px',\n textAlign: 'center',\n },\n },\n 'Error loading widget',\n ),\n }\n }\n}\n"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ;AACtC,OAAOC,KAAA,MAAW;AAElB,SAASC,iBAAiB,QAAQ;AAiBlC;;;;AAIA,OAAO,MAAMC,mBAAA,GAGTA,CAAC;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC,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,OAAO,GAAGC,MAAA,CAAOH,KAAA;IAErE7B,GAAA,CAAIM,OAAO,CAAC2B,MAAM,CAACJ,KAAK,CAAC;MACvBK,GAAA,EAAKL,KAAA;MACLM,GAAA,EAAK,2BAA2BhC,UAAA,MAAgB2B,YAAA;IAClD;IAEA,OAAO;MACLf,SAAA,EAAWrB,KAAA,CAAMsB,aAAa,CAC5B,OACA;QACEC,KAAA,EAAO;UACLC,UAAA,EAAY;UACZC,MAAA,EAAQ;UACRC,YAAA,EAAc;UACdC,KAAA,EAAO;UACPC,OAAA,EAAS;UACTC,SAAA,EAAW;QACb;MACF,GACA;IAEJ;EACF;AACF","ignoreList":[]}
|
|
@@ -5,6 +5,9 @@ import { getGlobalData, getNavGroups } from '@payloadcms/ui/shared';
|
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import { DefaultDashboard } from './Default/index.js';
|
|
7
7
|
export async function DashboardView(props) {
|
|
8
|
+
const {
|
|
9
|
+
user: userWithReadAccess
|
|
10
|
+
} = props;
|
|
8
11
|
const {
|
|
9
12
|
locale,
|
|
10
13
|
permissions,
|
|
@@ -13,8 +16,7 @@ export async function DashboardView(props) {
|
|
|
13
16
|
payload: {
|
|
14
17
|
config
|
|
15
18
|
},
|
|
16
|
-
payload
|
|
17
|
-
user
|
|
19
|
+
payload
|
|
18
20
|
},
|
|
19
21
|
req,
|
|
20
22
|
visibleEntities
|
|
@@ -41,7 +43,7 @@ export async function DashboardView(props) {
|
|
|
41
43
|
navGroups,
|
|
42
44
|
payload,
|
|
43
45
|
permissions,
|
|
44
|
-
user,
|
|
46
|
+
user: userWithReadAccess,
|
|
45
47
|
visibleEntities
|
|
46
48
|
}
|
|
47
49
|
})]
|