@payloadcms/next 3.0.0-canary.b6520aa → 3.0.0-canary.b922438
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/index.scss +0 -1
- package/dist/elements/DocumentHeader/index.scss +0 -2
- package/dist/elements/LeaveWithoutSaving/index.scss +1 -0
- package/dist/elements/Nav/index.client.d.ts.map +1 -1
- package/dist/elements/Nav/index.client.js +7 -8
- package/dist/elements/Nav/index.client.js.map +1 -1
- package/dist/elements/Nav/index.scss +17 -14
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +16 -1
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/scss/app.scss +5 -5
- package/dist/scss/type.scss +1 -0
- package/dist/views/API/index.scss +1 -2
- package/dist/views/Account/index.client.d.ts +3 -0
- package/dist/views/Account/index.client.d.ts.map +1 -0
- package/dist/views/Account/index.client.js +21 -0
- package/dist/views/Account/index.client.js.map +1 -0
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +33 -29
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/Dashboard/index.js +3 -4
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +3 -5
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Edit/Default/Auth/APIKey.d.ts +2 -2
- package/dist/views/Edit/Default/Auth/APIKey.d.ts.map +1 -1
- package/dist/views/Edit/Default/Auth/APIKey.js +35 -8
- package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +4 -2
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/List/Default/index.d.ts.map +1 -1
- package/dist/views/List/Default/index.js +28 -30
- package/dist/views/List/Default/index.js.map +1 -1
- package/dist/views/List/Default/index.scss +5 -12
- package/dist/views/List/index.js +3 -4
- 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 +12 -21
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/index.d.ts +1 -1
- package/dist/views/Version/index.d.ts.map +1 -1
- package/dist/views/Version/index.js +32 -5
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Versions/getLatestVersion.d.ts +13 -4
- package/dist/views/Versions/getLatestVersion.d.ts.map +1 -1
- package/dist/views/Versions/getLatestVersion.js +6 -1
- package/dist/views/Versions/getLatestVersion.js.map +1 -1
- package/dist/views/Versions/index.d.ts.map +1 -1
- package/dist/views/Versions/index.js +24 -4
- package/dist/views/Versions/index.js.map +1 -1
- package/package.json +6 -6
package/dist/scss/app.scss
CHANGED
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
|
|
39
39
|
--gutter-h: #{base(3)};
|
|
40
40
|
--spacing-view-bottom: var(--gutter-h);
|
|
41
|
-
--
|
|
42
|
-
--
|
|
41
|
+
--doc-controls-height: calc(var(--base) * 2.8);
|
|
42
|
+
--app-header-height: calc(var(--base) * 2.8);
|
|
43
43
|
--nav-width: 275px;
|
|
44
44
|
--nav-trans-time: 150ms;
|
|
45
45
|
|
|
46
46
|
@include mid-break {
|
|
47
47
|
--gutter-h: #{base(2)};
|
|
48
|
-
--app-header-height: calc(var(--base) * 2);
|
|
49
|
-
--doc-controls-height: calc(var(--base) * 2.
|
|
48
|
+
--app-header-height: calc(var(--base) * 2.4);
|
|
49
|
+
--doc-controls-height: calc(var(--base) * 2.4);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@include small-break {
|
|
53
|
-
--gutter-h: #{base(0.
|
|
53
|
+
--gutter-h: #{base(0.8)};
|
|
54
54
|
--spacing-view-bottom: calc(var(--base) * 2);
|
|
55
55
|
--nav-width: 100vw;
|
|
56
56
|
}
|
package/dist/scss/type.scss
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.client.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAgBjC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useStepNav, useTranslation } from '@payloadcms/ui';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export const AccountClient = ()=>{
|
|
5
|
+
const { setStepNav } = useStepNav();
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
React.useEffect(()=>{
|
|
8
|
+
const nav = [];
|
|
9
|
+
nav.push({
|
|
10
|
+
label: t('authentication:account'),
|
|
11
|
+
url: '/account'
|
|
12
|
+
});
|
|
13
|
+
setStepNav(nav);
|
|
14
|
+
}, [
|
|
15
|
+
setStepNav,
|
|
16
|
+
t
|
|
17
|
+
]);
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Account/index.client.tsx"],"sourcesContent":["'use client'\nimport { type StepNavItem, useStepNav, useTranslation } from '@payloadcms/ui'\nimport React from 'react'\n\nexport const AccountClient: React.FC = () => {\n const { setStepNav } = useStepNav()\n const { t } = useTranslation()\n\n React.useEffect(() => {\n const nav: StepNavItem[] = []\n\n nav.push({\n label: t('authentication:account'),\n url: '/account',\n })\n\n setStepNav(nav)\n }, [setStepNav, t])\n\n return null\n}\n"],"names":["useStepNav","useTranslation","React","AccountClient","setStepNav","t","useEffect","nav","push","label","url"],"mappings":"AAAA;AACA,SAA2BA,UAAU,EAAEC,cAAc,QAAQ,iBAAgB;AAC7E,OAAOC,WAAW,QAAO;AAEzB,OAAO,MAAMC,gBAA0B;IACrC,MAAM,EAAEC,UAAU,EAAE,GAAGJ;IACvB,MAAM,EAAEK,CAAC,EAAE,GAAGJ;IAEdC,MAAMI,SAAS,CAAC;QACd,MAAMC,MAAqB,EAAE;QAE7BA,IAAIC,IAAI,CAAC;YACPC,OAAOJ,EAAE;YACTK,KAAK;QACP;QAEAN,WAAWG;IACb,GAAG;QAACH;QAAYC;KAAE;IAElB,OAAO;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,SAAS,CAAA;AAKtE,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,SAAS,CAAA;AAKtE,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEnD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA8F5C,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DocumentInfoProvider,
|
|
2
|
+
import { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui';
|
|
3
3
|
import { RenderCustomComponent } from '@payloadcms/ui/shared';
|
|
4
4
|
import { notFound } from 'next/navigation.js';
|
|
5
5
|
import React from 'react';
|
|
@@ -8,6 +8,7 @@ import { getDocumentData } from '../Document/getDocumentData.js';
|
|
|
8
8
|
import { getDocumentPermissions } from '../Document/getDocumentPermissions.js';
|
|
9
9
|
import { EditView } from '../Edit/index.js';
|
|
10
10
|
import { Settings } from './Settings/index.js';
|
|
11
|
+
import { AccountClient } from './index.client.js';
|
|
11
12
|
export { generateAccountMetadata } from './meta.js';
|
|
12
13
|
export const Account = async ({ initPageResult, params, searchParams })=>{
|
|
13
14
|
const { languageOptions, locale, permissions, req, req: { i18n, payload, payload: { config }, user } } = initPageResult;
|
|
@@ -32,7 +33,7 @@ export const Account = async ({ initPageResult, params, searchParams })=>{
|
|
|
32
33
|
routeSegments: [],
|
|
33
34
|
searchParams
|
|
34
35
|
};
|
|
35
|
-
return /*#__PURE__*/
|
|
36
|
+
return /*#__PURE__*/ _jsx(DocumentInfoProvider, {
|
|
36
37
|
AfterFields: /*#__PURE__*/ _jsx(Settings, {
|
|
37
38
|
i18n: i18n,
|
|
38
39
|
languageOptions: languageOptions
|
|
@@ -46,33 +47,36 @@ export const Account = async ({ initPageResult, params, searchParams })=>{
|
|
|
46
47
|
initialData: data,
|
|
47
48
|
initialState: formState,
|
|
48
49
|
isEditing: true,
|
|
49
|
-
children:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
children: /*#__PURE__*/ _jsxs(EditDepthProvider, {
|
|
51
|
+
depth: 1,
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ _jsx(DocumentHeader, {
|
|
54
|
+
collectionConfig: collectionConfig,
|
|
55
|
+
config: payload.config,
|
|
56
|
+
hideTabs: true,
|
|
57
|
+
i18n: i18n,
|
|
58
|
+
permissions: permissions
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ _jsx(HydrateAuthProvider, {
|
|
61
|
+
permissions: permissions
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ _jsx(RenderCustomComponent, {
|
|
64
|
+
CustomComponent: typeof CustomAccountComponent === 'function' ? CustomAccountComponent : undefined,
|
|
65
|
+
DefaultComponent: EditView,
|
|
66
|
+
componentProps: viewComponentProps,
|
|
67
|
+
serverOnlyProps: {
|
|
68
|
+
i18n,
|
|
69
|
+
locale,
|
|
70
|
+
params,
|
|
71
|
+
payload,
|
|
72
|
+
permissions,
|
|
73
|
+
searchParams,
|
|
74
|
+
user
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ _jsx(AccountClient, {})
|
|
78
|
+
]
|
|
79
|
+
})
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
82
|
return notFound();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewProps, ServerSideEditViewProps } from 'payload'\n\nimport { DocumentInfoProvider,
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewProps, ServerSideEditViewProps } from 'payload'\n\nimport { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport { RenderCustomComponent } from '@payloadcms/ui/shared'\nimport { notFound } from 'next/navigation.js'\nimport React from 'react'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { getDocumentData } from '../Document/getDocumentData.js'\nimport { getDocumentPermissions } from '../Document/getDocumentPermissions.js'\nimport { EditView } from '../Edit/index.js'\nimport { Settings } from './Settings/index.js'\nimport { AccountClient } from './index.client.js'\n\nexport { generateAccountMetadata } from './meta.js'\n\nexport const Account: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\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: { components: { views: { Account: CustomAccountComponent } = {} } = {}, user: userSlug },\n routes: { api },\n serverURL,\n } = config\n\n const collectionConfig = config.collections.find((collection) => collection.slug === userSlug)\n\n if (collectionConfig && user?.id) {\n const { docPermissions, hasPublishPermission, hasSavePermission } =\n await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data: user,\n req,\n })\n\n const { data, formState } = await getDocumentData({\n id: user.id,\n collectionConfig,\n locale,\n req,\n })\n\n const viewComponentProps: ServerSideEditViewProps = {\n initPageResult,\n params,\n routeSegments: [],\n searchParams,\n }\n\n return (\n <DocumentInfoProvider\n AfterFields={<Settings i18n={i18n} languageOptions={languageOptions} />}\n apiURL={`${serverURL}${api}/${userSlug}${user?.id ? `/${user.id}` : ''}`}\n collectionSlug={userSlug}\n docPermissions={docPermissions}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={user?.id.toString()}\n initialData={data}\n initialState={formState}\n isEditing\n >\n <EditDepthProvider depth={1}>\n <DocumentHeader\n collectionConfig={collectionConfig}\n config={payload.config}\n hideTabs\n i18n={i18n}\n permissions={permissions}\n />\n <HydrateAuthProvider permissions={permissions} />\n <RenderCustomComponent\n CustomComponent={\n typeof CustomAccountComponent === 'function' ? CustomAccountComponent : undefined\n }\n DefaultComponent={EditView}\n componentProps={viewComponentProps}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n <AccountClient />\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n }\n\n return notFound()\n}\n"],"names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderCustomComponent","notFound","React","DocumentHeader","getDocumentData","getDocumentPermissions","EditView","Settings","AccountClient","generateAccountMetadata","Account","initPageResult","params","searchParams","languageOptions","locale","permissions","req","i18n","payload","config","user","admin","components","views","CustomAccountComponent","userSlug","routes","api","serverURL","collectionConfig","collections","find","collection","slug","id","docPermissions","hasPublishPermission","hasSavePermission","data","formState","viewComponentProps","routeSegments","AfterFields","apiURL","collectionSlug","toString","initialData","initialState","isEditing","depth","hideTabs","CustomComponent","undefined","DefaultComponent","componentProps","serverOnlyProps"],"mappings":";AAEA,SAASA,oBAAoB,EAAEC,iBAAiB,EAAEC,mBAAmB,QAAQ,iBAAgB;AAC7F,SAASC,qBAAqB,QAAQ,wBAAuB;AAC7D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,OAAOC,WAAW,QAAO;AAEzB,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,QAAQ,QAAQ,mBAAkB;AAC3C,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,SAASC,aAAa,QAAQ,oBAAmB;AAEjD,SAASC,uBAAuB,QAAQ,YAAW;AAEnD,OAAO,MAAMC,UAAoC,OAAO,EACtDC,cAAc,EACdC,MAAM,EACNC,YAAY,EACb;IACC,MAAM,EACJC,eAAe,EACfC,MAAM,EACNC,WAAW,EACXC,GAAG,EACHA,KAAK,EACHC,IAAI,EACJC,OAAO,EACPA,SAAS,EAAEC,MAAM,EAAE,EACnBC,IAAI,EACL,EACF,GAAGV;IAEJ,MAAM,EACJW,OAAO,EAAEC,YAAY,EAAEC,OAAO,EAAEd,SAASe,sBAAsB,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAEJ,MAAMK,QAAQ,EAAE,EAC/FC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,GAAGT;IAEJ,MAAMU,mBAAmBV,OAAOW,WAAW,CAACC,IAAI,CAAC,CAACC,aAAeA,WAAWC,IAAI,KAAKR;IAErF,IAAII,oBAAoBT,MAAMc,IAAI;QAChC,MAAM,EAAEC,cAAc,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAE,GAC/D,MAAMjC,uBAAuB;YAC3B8B,IAAId,KAAKc,EAAE;YACXL;YACAS,MAAMlB;YACNJ;QACF;QAEF,MAAM,EAAEsB,IAAI,EAAEC,SAAS,EAAE,GAAG,MAAMpC,gBAAgB;YAChD+B,IAAId,KAAKc,EAAE;YACXL;YACAf;YACAE;QACF;QAEA,MAAMwB,qBAA8C;YAClD9B;YACAC;YACA8B,eAAe,EAAE;YACjB7B;QACF;QAEA,qBACE,KAAChB;YACC8C,2BAAa,KAACpC;gBAASW,MAAMA;gBAAMJ,iBAAiBA;;YACpD8B,QAAQ,CAAC,EAAEf,UAAU,EAAED,IAAI,CAAC,EAAEF,SAAS,EAAEL,MAAMc,KAAK,CAAC,CAAC,EAAEd,KAAKc,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;YACxEU,gBAAgBnB;YAChBU,gBAAgBA;YAChBC,sBAAsBA;YACtBC,mBAAmBA;YACnBH,IAAId,MAAMc,GAAGW;YACbC,aAAaR;YACbS,cAAcR;YACdS,SAAS;sBAET,cAAA,MAACnD;gBAAkBoD,OAAO;;kCACxB,KAAC/C;wBACC2B,kBAAkBA;wBAClBV,QAAQD,QAAQC,MAAM;wBACtB+B,QAAQ;wBACRjC,MAAMA;wBACNF,aAAaA;;kCAEf,KAACjB;wBAAoBiB,aAAaA;;kCAClC,KAAChB;wBACCoD,iBACE,OAAO3B,2BAA2B,aAAaA,yBAAyB4B;wBAE1EC,kBAAkBhD;wBAClBiD,gBAAgBd;wBAChBe,iBAAiB;4BACftC;4BACAH;4BACAH;4BACAO;4BACAH;4BACAH;4BACAQ;wBACF;;kCAEF,KAACb;;;;IAIT;IAEA,OAAOP;AACT,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { HydrateAuthProvider } from '@payloadcms/ui';
|
|
3
3
|
import { EntityType, RenderCustomComponent, groupNavItems } from '@payloadcms/ui/shared';
|
|
4
4
|
import LinkImport from 'next/link.js';
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
@@ -41,9 +41,8 @@ export const Dashboard = ({ initPageResult, params, searchParams })=>{
|
|
|
41
41
|
};
|
|
42
42
|
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
43
43
|
children: [
|
|
44
|
-
/*#__PURE__*/ _jsx(
|
|
45
|
-
permissions: permissions
|
|
46
|
-
user: user
|
|
44
|
+
/*#__PURE__*/ _jsx(HydrateAuthProvider, {
|
|
45
|
+
permissions: permissions
|
|
47
46
|
}),
|
|
48
47
|
/*#__PURE__*/ _jsx(RenderCustomComponent, {
|
|
49
48
|
CustomComponent: typeof CustomDashboardComponent === 'function' ? CustomDashboardComponent : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Dashboard/index.tsx"],"sourcesContent":["import type { EntityToGroup } from '@payloadcms/ui/shared'\nimport type { AdminViewProps } from 'payload'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Dashboard/index.tsx"],"sourcesContent":["import type { EntityToGroup } from '@payloadcms/ui/shared'\nimport type { AdminViewProps } from 'payload'\n\nimport { HydrateAuthProvider } from '@payloadcms/ui'\nimport { EntityType, RenderCustomComponent, groupNavItems } from '@payloadcms/ui/shared'\nimport LinkImport from 'next/link.js'\nimport React, { Fragment } from 'react'\n\nimport type { DashboardProps } from './Default/index.js'\n\nimport { DefaultDashboard } from './Default/index.js'\n\nexport { generateDashboardMetadata } from './meta.js'\n\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport const Dashboard: React.FC<AdminViewProps> = ({ initPageResult, params, searchParams }) => {\n const {\n locale,\n permissions,\n req: {\n i18n,\n payload: { config },\n payload,\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const CustomDashboardComponent = config.admin.components?.views?.Dashboard\n\n const collections = config.collections.filter(\n (collection) =>\n permissions?.collections?.[collection.slug]?.read?.permission &&\n visibleEntities.collections.includes(collection.slug),\n )\n\n const globals = config.globals.filter(\n (global) =>\n permissions?.globals?.[global.slug]?.read?.permission &&\n visibleEntities.globals.includes(global.slug),\n )\n\n const navGroups = groupNavItems(\n [\n ...(collections.map((collection) => {\n const entityToGroup: EntityToGroup = {\n type: EntityType.collection,\n entity: collection,\n }\n\n return entityToGroup\n }) ?? []),\n ...(globals.map((global) => {\n const entityToGroup: EntityToGroup = {\n type: EntityType.global,\n entity: global,\n }\n\n return entityToGroup\n }) ?? []),\n ],\n permissions,\n i18n,\n )\n\n const viewComponentProps: DashboardProps = {\n Link,\n i18n,\n locale,\n navGroups,\n params,\n payload,\n permissions,\n searchParams,\n user,\n visibleEntities,\n }\n\n return (\n <Fragment>\n <HydrateAuthProvider permissions={permissions} />\n <RenderCustomComponent\n CustomComponent={\n typeof CustomDashboardComponent === 'function' ? CustomDashboardComponent : undefined\n }\n DefaultComponent={DefaultDashboard}\n componentProps={viewComponentProps}\n serverOnlyProps={{\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }}\n />\n </Fragment>\n )\n}\n"],"names":["HydrateAuthProvider","EntityType","RenderCustomComponent","groupNavItems","LinkImport","React","Fragment","DefaultDashboard","generateDashboardMetadata","Link","default","Dashboard","initPageResult","params","searchParams","locale","permissions","req","i18n","payload","config","user","visibleEntities","CustomDashboardComponent","admin","components","views","collections","filter","collection","slug","read","permission","includes","globals","global","navGroups","map","entityToGroup","type","entity","viewComponentProps","CustomComponent","undefined","DefaultComponent","componentProps","serverOnlyProps"],"mappings":";AAGA,SAASA,mBAAmB,QAAQ,iBAAgB;AACpD,SAASC,UAAU,EAAEC,qBAAqB,EAAEC,aAAa,QAAQ,wBAAuB;AACxF,OAAOC,gBAAgB,eAAc;AACrC,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAIvC,SAASC,gBAAgB,QAAQ,qBAAoB;AAErD,SAASC,yBAAyB,QAAQ,YAAW;AAErD,MAAMC,OAAQL,WAAWM,OAAO,IAAIN;AAEpC,OAAO,MAAMO,YAAsC,CAAC,EAAEC,cAAc,EA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F;;;;AAIR,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,cAAc,EAAqB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Document/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,cAAc,EAAqB,MAAM,SAAS,CAAA;AASpF,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AASrE,eAAO,MAAM,gBAAgB,EAAE,wBAAiE,CAAA;AAEhG,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAmO7C,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DocumentInfoProvider, EditDepthProvider,
|
|
2
|
+
import { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui';
|
|
3
3
|
import { RenderCustomComponent, formatAdminURL, isEditing as getIsEditing } from '@payloadcms/ui/shared';
|
|
4
4
|
import { notFound, redirect } from 'next/navigation.js';
|
|
5
|
-
import { deepCopyObjectSimple } from 'payload';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
import { DocumentHeader } from '../../elements/DocumentHeader/index.js';
|
|
8
7
|
import { NotFoundView } from '../NotFound/index.js';
|
|
@@ -149,9 +148,8 @@ export const Document = async ({ initPageResult, params, searchParams })=>{
|
|
|
149
148
|
i18n: i18n,
|
|
150
149
|
permissions: permissions
|
|
151
150
|
}),
|
|
152
|
-
/*#__PURE__*/ _jsx(
|
|
153
|
-
permissions:
|
|
154
|
-
user: user
|
|
151
|
+
/*#__PURE__*/ _jsx(HydrateAuthProvider, {
|
|
152
|
+
permissions: permissions
|
|
155
153
|
}),
|
|
156
154
|
/*#__PURE__*/ _jsx(EditDepthProvider, {
|
|
157
155
|
depth: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type { AdminViewComponent, AdminViewProps, EditViewComponent } from 'payload'\n\nimport { DocumentInfoProvider, EditDepthProvider, HydrateClientUser } from '@payloadcms/ui'\nimport {\n RenderCustomComponent,\n formatAdminURL,\n isEditing as getIsEditing,\n} from '@payloadcms/ui/shared'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { deepCopyObjectSimple } from 'payload'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getViewsFromConfig } from './getViewsFromConfig.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport const Document: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n const {\n collectionConfig,\n docID: id,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n\n const isEditing = getIsEditing({ id, collectionSlug, globalSlug })\n\n let ViewOverride: EditViewComponent\n let CustomView: EditViewComponent\n let DefaultView: EditViewComponent\n let ErrorView: AdminViewComponent\n\n let apiURL: string\n\n const { data, formState } = await getDocumentData({\n id,\n collectionConfig,\n globalConfig,\n locale,\n req,\n })\n\n const { docPermissions, hasPublishPermission, hasSavePermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data,\n globalConfig,\n req,\n })\n\n if (collectionConfig) {\n if (!visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) {\n notFound()\n }\n\n const params = new URLSearchParams()\n if (collectionConfig.versions?.drafts) {\n params.append('draft', 'true')\n }\n if (locale?.code) {\n params.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${params.toString()}`\n\n apiURL = `${serverURL}${apiRoute}/${collectionSlug}/${id}${apiQueryParams}`\n\n const editConfig = collectionConfig?.admin?.components?.views?.Edit\n ViewOverride = typeof editConfig === 'function' ? editConfig : null\n\n if (!ViewOverride) {\n const collectionViews = getViewsFromConfig({\n collectionConfig,\n config,\n docPermissions,\n routeSegments: segments,\n })\n\n CustomView = collectionViews?.CustomView\n DefaultView = collectionViews?.DefaultView\n ErrorView = collectionViews?.ErrorView\n }\n\n if (!CustomView && !DefaultView && !ViewOverride && !ErrorView) {\n ErrorView = NotFoundView\n }\n }\n\n if (globalConfig) {\n if (!visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)) {\n notFound()\n }\n\n const params = new URLSearchParams({\n locale: locale?.code,\n })\n if (globalConfig.versions?.drafts) {\n params.append('draft', 'true')\n }\n if (locale?.code) {\n params.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${params.toString()}`\n\n apiURL = `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\n\n const editConfig = globalConfig?.admin?.components?.views?.Edit\n ViewOverride = typeof editConfig === 'function' ? editConfig : null\n\n if (!ViewOverride) {\n const globalViews = getViewsFromConfig({\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n })\n\n CustomView = globalViews?.CustomView\n DefaultView = globalViews?.DefaultView\n ErrorView = globalViews?.ErrorView\n\n if (!CustomView && !DefaultView && !ViewOverride && !ErrorView) {\n ErrorView = NotFoundView\n }\n }\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n if (shouldAutosave && !validateDraftData && !id && collectionSlug) {\n const doc = await payload.create({\n collection: collectionSlug,\n data: {},\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n serverURL,\n })\n redirect(redirectURL)\n } else {\n notFound()\n }\n }\n\n return (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n disableActions={false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={data}\n initialState={formState}\n isEditing={isEditing}\n >\n {!ViewOverride && (\n <DocumentHeader\n collectionConfig={collectionConfig}\n config={payload.config}\n globalConfig={globalConfig}\n i18n={i18n}\n permissions={permissions}\n />\n )}\n {/**\n * After bumping the Next.js canary to 104, and React to 19.0.0-rc-06d0b89e-20240801\" we have to deepCopy the permissions object (https://github.com/payloadcms/payload/pull/7541).\n * If both HydrateClientUser and RenderCustomComponent receive the same permissions object (same object reference), we get a\n * \"TypeError: Cannot read properties of undefined (reading '$$typeof')\" error when loading up some version views - for example a versions\n * view in the draft-posts collection of the versions test suite. RenderCustomComponent is what renders the versions view.\n *\n * // TODO: Revisit this in the future and figure out why this is happening. Might be a React/Next.js bug. We don't know why it happens, and a future React/Next version might unbreak this (keep an eye on this and remove deepCopyObjectSimple if that's the case)\n */}\n <HydrateClientUser permissions={deepCopyObjectSimple(permissions)} user={user} />\n <EditDepthProvider\n depth={1}\n key={`${collectionSlug || globalSlug}${locale?.code ? `-${locale?.code}` : ''}`}\n >\n {ErrorView ? (\n <ErrorView initPageResult={initPageResult} searchParams={searchParams} />\n ) : (\n <RenderCustomComponent\n CustomComponent={ViewOverride || CustomView}\n DefaultComponent={DefaultView}\n serverOnlyProps={{\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n }}\n />\n )}\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n}\n"],"names":["DocumentInfoProvider","EditDepthProvider","HydrateClientUser","RenderCustomComponent","formatAdminURL","isEditing","getIsEditing","notFound","redirect","deepCopyObjectSimple","React","DocumentHeader","NotFoundView","getDocumentData","getDocumentPermissions","getMetaBySegment","getViewsFromConfig","generateMetadata","args","Document","initPageResult","params","searchParams","collectionConfig","docID","id","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","ViewOverride","CustomView","DefaultView","ErrorView","apiURL","data","formState","docPermissions","hasPublishPermission","hasSavePermission","collections","find","visibleSlug","URLSearchParams","versions","drafts","append","code","apiQueryParams","toString","editConfig","components","views","Edit","collectionViews","routeSegments","globals","globalViews","shouldAutosave","autosave","validateDraftData","validate","doc","create","collection","depth","draft","fallbackLocale","redirectURL","path","disableActions","initialData","initialState","CustomComponent","DefaultComponent","serverOnlyProps"],"mappings":";AAEA,SAASA,oBAAoB,EAAEC,iBAAiB,EAAEC,iBAAiB,QAAQ,iBAAgB;AAC3F,SACEC,qBAAqB,EACrBC,cAAc,EACdC,aAAaC,YAAY,QACpB,wBAAuB;AAC9B,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,qBAAoB;AACvD,SAASC,oBAAoB,QAAQ,UAAS;AAC9C,OAAOC,WAAW,QAAO;AAIzB,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,YAAY,QAAQ,uBAAsB;AACnD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,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BAClBS,QAAQD,QAAQC,MAAM;gBACtBN,cAAcA;gBACdI,MAAMA;gBACNF,aAAaA;;0BAWjB,KAAC1B;gBAAkB0B,aAAanB,qBAAqBmB;gBAAcW,MAAMA;;0BACzE,KAACtC;gBACCkF,OAAO;0BAGNhC,0BACC,KAACA;oBAAU/B,gBAAgBA;oBAAgBE,cAAcA;mCAEzD,KAACnB;oBACCwF,iBAAiB3C,gBAAgBC;oBACjC2C,kBAAkB1C;oBAClB2C,iBAAiB;wBACf/D;wBACAV;wBACAO;wBACAN;wBACAU;wBACAH;wBACA6C,eAAehC;wBACfnB;wBACAiB;oBACF;;eAlBC,CAAC,EAAEK,kBAAkBG,WAAW,EAAEpB,QAAQsC,OAAO,CAAC,CAAC,EAAEtC,QAAQsC,KAAK,CAAC,GAAG,GAAG,CAAC;;;AAwBvF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/views/Document/index.tsx"],"sourcesContent":["import type { AdminViewComponent, AdminViewProps, EditViewComponent } from 'payload'\n\nimport { DocumentInfoProvider, EditDepthProvider, HydrateAuthProvider } from '@payloadcms/ui'\nimport {\n RenderCustomComponent,\n formatAdminURL,\n isEditing as getIsEditing,\n} from '@payloadcms/ui/shared'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React from 'react'\n\nimport type { GenerateEditViewMetadata } from './getMetaBySegment.js'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { NotFoundView } from '../NotFound/index.js'\nimport { getDocumentData } from './getDocumentData.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\nimport { getMetaBySegment } from './getMetaBySegment.js'\nimport { getViewsFromConfig } from './getViewsFromConfig.js'\n\nexport const generateMetadata: GenerateEditViewMetadata = async (args) => getMetaBySegment(args)\n\nexport const Document: React.FC<AdminViewProps> = async ({\n initPageResult,\n params,\n searchParams,\n}) => {\n const {\n collectionConfig,\n docID: id,\n globalConfig,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: {\n config,\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n serverURL,\n },\n },\n user,\n },\n visibleEntities,\n } = initPageResult\n\n const segments = Array.isArray(params?.segments) ? params.segments : []\n const collectionSlug = collectionConfig?.slug || undefined\n const globalSlug = globalConfig?.slug || undefined\n\n const isEditing = getIsEditing({ id, collectionSlug, globalSlug })\n\n let ViewOverride: EditViewComponent\n let CustomView: EditViewComponent\n let DefaultView: EditViewComponent\n let ErrorView: AdminViewComponent\n\n let apiURL: string\n\n const { data, formState } = await getDocumentData({\n id,\n collectionConfig,\n globalConfig,\n locale,\n req,\n })\n\n const { docPermissions, hasPublishPermission, hasSavePermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data,\n globalConfig,\n req,\n })\n\n if (collectionConfig) {\n if (!visibleEntities?.collections?.find((visibleSlug) => visibleSlug === collectionSlug)) {\n notFound()\n }\n\n const params = new URLSearchParams()\n if (collectionConfig.versions?.drafts) {\n params.append('draft', 'true')\n }\n if (locale?.code) {\n params.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${params.toString()}`\n\n apiURL = `${serverURL}${apiRoute}/${collectionSlug}/${id}${apiQueryParams}`\n\n const editConfig = collectionConfig?.admin?.components?.views?.Edit\n ViewOverride = typeof editConfig === 'function' ? editConfig : null\n\n if (!ViewOverride) {\n const collectionViews = getViewsFromConfig({\n collectionConfig,\n config,\n docPermissions,\n routeSegments: segments,\n })\n\n CustomView = collectionViews?.CustomView\n DefaultView = collectionViews?.DefaultView\n ErrorView = collectionViews?.ErrorView\n }\n\n if (!CustomView && !DefaultView && !ViewOverride && !ErrorView) {\n ErrorView = NotFoundView\n }\n }\n\n if (globalConfig) {\n if (!visibleEntities?.globals?.find((visibleSlug) => visibleSlug === globalSlug)) {\n notFound()\n }\n\n const params = new URLSearchParams({\n locale: locale?.code,\n })\n if (globalConfig.versions?.drafts) {\n params.append('draft', 'true')\n }\n if (locale?.code) {\n params.append('locale', locale.code)\n }\n\n const apiQueryParams = `?${params.toString()}`\n\n apiURL = `${serverURL}${apiRoute}/${globalSlug}${apiQueryParams}`\n\n const editConfig = globalConfig?.admin?.components?.views?.Edit\n ViewOverride = typeof editConfig === 'function' ? editConfig : null\n\n if (!ViewOverride) {\n const globalViews = getViewsFromConfig({\n config,\n docPermissions,\n globalConfig,\n routeSegments: segments,\n })\n\n CustomView = globalViews?.CustomView\n DefaultView = globalViews?.DefaultView\n ErrorView = globalViews?.ErrorView\n\n if (!CustomView && !DefaultView && !ViewOverride && !ErrorView) {\n ErrorView = NotFoundView\n }\n }\n }\n\n /**\n * Handle case where autoSave is enabled and the document is being created\n * => create document and redirect\n */\n const shouldAutosave =\n hasSavePermission &&\n ((collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave))\n const validateDraftData =\n collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.validate\n\n if (shouldAutosave && !validateDraftData && !id && collectionSlug) {\n const doc = await payload.create({\n collection: collectionSlug,\n data: {},\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale: locale?.code,\n req,\n user,\n })\n\n if (doc?.id) {\n const redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${doc.id}`,\n serverURL,\n })\n redirect(redirectURL)\n } else {\n notFound()\n }\n }\n\n return (\n <DocumentInfoProvider\n apiURL={apiURL}\n collectionSlug={collectionConfig?.slug}\n disableActions={false}\n docPermissions={docPermissions}\n globalSlug={globalConfig?.slug}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n initialData={data}\n initialState={formState}\n isEditing={isEditing}\n >\n {!ViewOverride && (\n <DocumentHeader\n collectionConfig={collectionConfig}\n config={payload.config}\n globalConfig={globalConfig}\n i18n={i18n}\n permissions={permissions}\n />\n )}\n <HydrateAuthProvider permissions={permissions} />\n {/**\n * After bumping the Next.js canary to 104, and React to 19.0.0-rc-06d0b89e-20240801\" we have to deepCopy the permissions object (https://github.com/payloadcms/payload/pull/7541).\n * If both HydrateClientUser and RenderCustomComponent receive the same permissions object (same object reference), we get a\n * \"TypeError: Cannot read properties of undefined (reading '$$typeof')\" error when loading up some version views - for example a versions\n * view in the draft-posts collection of the versions test suite. RenderCustomComponent is what renders the versions view.\n *\n * // TODO: Revisit this in the future and figure out why this is happening. Might be a React/Next.js bug. We don't know why it happens, and a future React/Next version might unbreak this (keep an eye on this and remove deepCopyObjectSimple if that's the case)\n */}\n <EditDepthProvider\n depth={1}\n key={`${collectionSlug || globalSlug}${locale?.code ? `-${locale?.code}` : ''}`}\n >\n {ErrorView ? (\n <ErrorView initPageResult={initPageResult} searchParams={searchParams} />\n ) : (\n <RenderCustomComponent\n CustomComponent={ViewOverride || CustomView}\n DefaultComponent={DefaultView}\n serverOnlyProps={{\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: segments,\n searchParams,\n user,\n }}\n />\n )}\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n}\n"],"names":["DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","RenderCustomComponent","formatAdminURL","isEditing","getIsEditing","notFound","redirect","React","DocumentHeader","NotFoundView","getDocumentData","getDocumentPermissions","getMetaBySegment","getViewsFromConfig","generateMetadata","args","Document","initPageResult","params","searchParams","collectionConfig","docID","id","globalConfig","locale","permissions","req","i18n","payload","config","routes","admin","adminRoute","api","apiRoute","serverURL","user","visibleEntities","segments","Array","isArray","collectionSlug","slug","undefined","globalSlug","ViewOverride","CustomView","DefaultView","ErrorView","apiURL","data","formState","docPermissions","hasPublishPermission","hasSavePermission","collections","find","visibleSlug","URLSearchParams","versions","drafts","append","code","apiQueryParams","toString","editConfig","components","views","Edit","collectionViews","routeSegments","globals","globalViews","shouldAutosave","autosave","validateDraftData","validate","doc","create","collection","depth","draft","fallbackLocale","redirectURL","path","disableActions","initialData","initialState","CustomComponent","DefaultComponent","serverOnlyProps"],"mappings":";AAEA,SAASA,oBAAoB,EAAEC,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CAAC,CAAC;gBAChDa;YACF;YACA7B,SAAS6E;QACX,OAAO;YACL9E;QACF;IACF;IAEA,qBACE,MAACP;QACCmD,QAAQA;QACRR,gBAAgBrB,kBAAkBsB;QAClC2C,gBAAgB;QAChBjC,gBAAgBA;QAChBR,YAAYrB,cAAcmB;QAC1BW,sBAAsBA;QACtBC,mBAAmBA;QACnBhC,IAAIA;QACJgE,aAAapC;QACbqC,cAAcpC;QACdhD,WAAWA;;YAEV,CAAC0C,8BACA,KAACrC;gBACCY,kBAAkBA;gBAClBS,QAAQD,QAAQC,MAAM;gBACtBN,cAAcA;gBACdI,MAAMA;gBACNF,aAAaA;;0BAGjB,KAACzB;gBAAoByB,aAAaA;;0BASlC,KAAC1B;gBACCiF,OAAO;0BAGNhC,0BACC,KAACA;oBAAU/B,gBAAgBA;oBAAgBE,cAAcA;mCAEzD,KAAClB;oBACCuF,iBAAiB3C,gBAAgBC;oBACjC2C,kBAAkB1C;oBAClB2C,iBAAiB;wBACf/D;wBACAV;wBACAO;wBACAN;wBACAU;wBACAH;wBACA6C,eAAehC;wBACfnB;wBACAiB;oBACF;;eAlBC,CAAC,EAAEK,kBAAkBG,WAAW,EAAEpB,QAAQsC,OAAO,CAAC,CAAC,EAAEtC,QAAQsC,KAAK,CAAC,GAAG,GAAG,CAAC;;;AAwBvF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIKey.d.ts","sourceRoot":"","sources":["../../../../../src/views/Edit/Default/Auth/APIKey.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"APIKey.d.ts","sourceRoot":"","sources":["../../../../../src/views/Edit/Default/Auth/APIKey.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAO3D,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAuHvF,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
|
+
import { CopyToClipboard, FieldLabel, GenerateConfirmation, useComponentMap, useConfig, useDocumentInfo, useField, useFormFields, useTranslation } from '@payloadcms/ui';
|
|
4
5
|
import { text } from 'payload/shared';
|
|
5
6
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
6
7
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -10,9 +11,15 @@ const fieldBaseClass = 'field-type';
|
|
|
10
11
|
export const APIKey = ({ enabled, readOnly })=>{
|
|
11
12
|
const [initialAPIKey] = useState(uuidv4());
|
|
12
13
|
const [highlightedField, setHighlightedField] = useState(false);
|
|
13
|
-
const { t } = useTranslation();
|
|
14
|
+
const { i18n, t } = useTranslation();
|
|
14
15
|
const config = useConfig();
|
|
15
16
|
const apiKey = useFormFields(([fields])=>fields && fields[path] || null);
|
|
17
|
+
const { collectionSlug, docPermissions } = useDocumentInfo();
|
|
18
|
+
const { getFieldMap } = useComponentMap();
|
|
19
|
+
const fieldMap = getFieldMap({
|
|
20
|
+
collectionSlug
|
|
21
|
+
});
|
|
22
|
+
const apiKeyField = fieldMap.find((field)=>'name' in field && field.name === 'apiKey');
|
|
16
23
|
const validate = (val)=>text(val, {
|
|
17
24
|
name: 'apiKey',
|
|
18
25
|
type: 'text',
|
|
@@ -31,19 +38,39 @@ export const APIKey = ({ enabled, readOnly })=>{
|
|
|
31
38
|
siblingData: {}
|
|
32
39
|
});
|
|
33
40
|
const apiKeyValue = apiKey?.value;
|
|
34
|
-
const
|
|
41
|
+
const apiKeyLabel = useMemo(()=>{
|
|
42
|
+
let label = 'API Key';
|
|
43
|
+
if (apiKeyField && apiKeyField.fieldComponentProps.label) {
|
|
44
|
+
label = apiKeyField.fieldComponentProps.label;
|
|
45
|
+
}
|
|
46
|
+
return getTranslation(label, i18n);
|
|
47
|
+
}, [
|
|
48
|
+
apiKeyField,
|
|
49
|
+
i18n
|
|
50
|
+
]);
|
|
51
|
+
const APIKeyLabelComponent = useMemo(()=>{
|
|
52
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
35
53
|
className: `${baseClass}__label`,
|
|
36
54
|
children: [
|
|
37
55
|
/*#__PURE__*/ _jsx("span", {
|
|
38
|
-
children:
|
|
56
|
+
children: apiKeyLabel
|
|
39
57
|
}),
|
|
40
58
|
/*#__PURE__*/ _jsx(CopyToClipboard, {
|
|
41
59
|
value: apiKeyValue
|
|
42
60
|
})
|
|
43
61
|
]
|
|
44
|
-
})
|
|
62
|
+
});
|
|
63
|
+
}, [
|
|
64
|
+
apiKeyLabel,
|
|
45
65
|
apiKeyValue
|
|
46
66
|
]);
|
|
67
|
+
const canUpdateAPIKey = useMemo(()=>{
|
|
68
|
+
if (docPermissions && docPermissions?.fields?.apiKey) {
|
|
69
|
+
return docPermissions.fields.apiKey.update.permission;
|
|
70
|
+
}
|
|
71
|
+
}, [
|
|
72
|
+
docPermissions
|
|
73
|
+
]);
|
|
47
74
|
const fieldType = useField({
|
|
48
75
|
path: 'apiKey',
|
|
49
76
|
validate
|
|
@@ -92,11 +119,11 @@ export const APIKey = ({ enabled, readOnly })=>{
|
|
|
92
119
|
].filter(Boolean).join(' '),
|
|
93
120
|
children: [
|
|
94
121
|
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
95
|
-
CustomLabel:
|
|
122
|
+
CustomLabel: APIKeyLabelComponent,
|
|
96
123
|
htmlFor: path
|
|
97
124
|
}),
|
|
98
125
|
/*#__PURE__*/ _jsx("input", {
|
|
99
|
-
"aria-label":
|
|
126
|
+
"aria-label": apiKeyLabel,
|
|
100
127
|
className: highlightedField ? 'highlight' : undefined,
|
|
101
128
|
disabled: true,
|
|
102
129
|
id: "apiKey",
|
|
@@ -106,7 +133,7 @@ export const APIKey = ({ enabled, readOnly })=>{
|
|
|
106
133
|
})
|
|
107
134
|
]
|
|
108
135
|
}),
|
|
109
|
-
!readOnly && /*#__PURE__*/ _jsx(GenerateConfirmation, {
|
|
136
|
+
!readOnly && canUpdateAPIKey && /*#__PURE__*/ _jsx(GenerateConfirmation, {
|
|
110
137
|
highlightField: highlightField,
|
|
111
138
|
setKey: ()=>setValue(uuidv4())
|
|
112
139
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/views/Edit/Default/Auth/APIKey.tsx"],"sourcesContent":["'use client'\nimport type { PayloadRequest } from 'payload'\n\nimport {\n CopyToClipboard,\n FieldLabel,\n GenerateConfirmation,\n useConfig,\n useField,\n useFormFields,\n useTranslation,\n} from '@payloadcms/ui'\nimport { text } from 'payload/shared'\nimport React, { useEffect, useMemo, useState } from 'react'\nimport { v4 as uuidv4 } from 'uuid'\n\nconst path = 'apiKey'\nconst baseClass = 'api-key'\nconst fieldBaseClass = 'field-type'\n\nexport const APIKey: React.FC<{ enabled: boolean; readOnly?: boolean }> = ({\n enabled,\n readOnly,\n}) => {\n const [initialAPIKey] = useState(uuidv4())\n const [highlightedField, setHighlightedField] = useState(false)\n const { t } = useTranslation()\n const config = useConfig()\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/views/Edit/Default/Auth/APIKey.tsx"],"sourcesContent":["'use client'\nimport type { FieldMap, PayloadRequest } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n CopyToClipboard,\n FieldDescription,\n FieldLabel,\n GenerateConfirmation,\n useComponentMap,\n useConfig,\n useDocumentInfo,\n useField,\n useFormFields,\n useTranslation,\n} from '@payloadcms/ui'\nimport { text } from 'payload/shared'\nimport React, { useEffect, useMemo, useState } from 'react'\nimport { v4 as uuidv4 } from 'uuid'\n\nconst path = 'apiKey'\nconst baseClass = 'api-key'\nconst fieldBaseClass = 'field-type'\n\nexport const APIKey: React.FC<{ readonly enabled: boolean; readonly readOnly?: boolean }> = ({\n enabled,\n readOnly,\n}) => {\n const [initialAPIKey] = useState(uuidv4())\n const [highlightedField, setHighlightedField] = useState(false)\n const { i18n, t } = useTranslation()\n const config = useConfig()\n const apiKey = useFormFields(([fields]) => (fields && fields[path]) || null)\n const { collectionSlug, docPermissions } = useDocumentInfo()\n\n const { getFieldMap } = useComponentMap()\n\n const fieldMap: FieldMap = getFieldMap({\n collectionSlug,\n })\n\n const apiKeyField = fieldMap.find((field) => 'name' in field && field.name === 'apiKey')\n\n const validate = (val) =>\n text(val, {\n name: 'apiKey',\n type: 'text',\n data: {},\n maxLength: 48,\n minLength: 24,\n preferences: { fields: {} },\n req: {\n payload: {\n config,\n },\n t,\n } as PayloadRequest,\n siblingData: {},\n })\n\n const apiKeyValue = apiKey?.value\n\n const apiKeyLabel = useMemo(() => {\n let label: Record<string, string> | string = 'API Key'\n\n if (apiKeyField && apiKeyField.fieldComponentProps.label) {\n label = apiKeyField.fieldComponentProps.label\n }\n\n return getTranslation(label, i18n)\n }, [apiKeyField, i18n])\n\n const APIKeyLabelComponent = useMemo(() => {\n return (\n <div className={`${baseClass}__label`}>\n <span>{apiKeyLabel}</span>\n <CopyToClipboard value={apiKeyValue as string} />\n </div>\n )\n }, [apiKeyLabel, apiKeyValue])\n\n const canUpdateAPIKey = useMemo(() => {\n if (docPermissions && docPermissions?.fields?.apiKey) {\n return docPermissions.fields.apiKey.update.permission\n }\n }, [docPermissions])\n\n const fieldType = useField({\n path: 'apiKey',\n validate,\n })\n\n const highlightField = () => {\n if (highlightedField) {\n setHighlightedField(false)\n }\n setTimeout(() => {\n setHighlightedField(true)\n }, 1)\n }\n\n const { setValue, value } = fieldType\n\n useEffect(() => {\n if (!apiKeyValue && enabled) {\n setValue(initialAPIKey)\n }\n if (!enabled && apiKeyValue) {\n setValue(null)\n }\n }, [apiKeyValue, enabled, setValue, initialAPIKey])\n\n useEffect(() => {\n if (highlightedField) {\n setTimeout(() => {\n setHighlightedField(false)\n }, 10000)\n }\n }, [highlightedField])\n\n if (!enabled) {\n return null\n }\n\n return (\n <React.Fragment>\n <div className={[fieldBaseClass, 'api-key', 'read-only'].filter(Boolean).join(' ')}>\n <FieldLabel CustomLabel={APIKeyLabelComponent} htmlFor={path} />\n <input\n aria-label={apiKeyLabel}\n className={highlightedField ? 'highlight' : undefined}\n disabled\n id=\"apiKey\"\n name=\"apiKey\"\n type=\"text\"\n value={(value as string) || ''}\n />\n </div>\n {!readOnly && canUpdateAPIKey && (\n <GenerateConfirmation highlightField={highlightField} setKey={() => setValue(uuidv4())} />\n )}\n </React.Fragment>\n )\n}\n"],"names":["getTranslation","CopyToClipboard","FieldLabel","GenerateConfirmation","useComponentMap","useConfig","useDocumentInfo","useField","useFormFields","useTranslation","text","React","useEffect","useMemo","useState","v4","uuidv4","path","baseClass","fieldBaseClass","APIKey","enabled","readOnly","initialAPIKey","highlightedField","setHighlightedField","i18n","t","config","apiKey","fields","collectionSlug","docPermissions","getFieldMap","fieldMap","apiKeyField","find","field","name","validate","val","type","data","maxLength","minLength","preferences","req","payload","siblingData","apiKeyValue","value","apiKeyLabel","label","fieldComponentProps","APIKeyLabelComponent","div","className","span","canUpdateAPIKey","update","permission","fieldType","highlightField","setTimeout","setValue","Fragment","filter","Boolean","join","CustomLabel","htmlFor","input","aria-label","undefined","disabled","id","setKey"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,eAAe,EAEfC,UAAU,EACVC,oBAAoB,EACpBC,eAAe,EACfC,SAAS,EACTC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,SAASC,IAAI,QAAQ,iBAAgB;AACrC,OAAOC,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAC3D,SAASC,MAAMC,MAAM,QAAQ,OAAM;AAEnC,MAAMC,OAAO;AACb,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;AAEvB,OAAO,MAAMC,SAA+E,CAA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,kBAAkBA,gBAAgBF,QAAQD,QAAQ;YACpD,OAAOG,eAAeF,MAAM,CAACD,MAAM,CAAC8B,MAAM,CAACC,UAAU;QACvD;IACF,GAAG;QAAC5B;KAAe;IAEnB,MAAM6B,YAAYtD,SAAS;QACzBU,MAAM;QACNsB;IACF;IAEA,MAAMuB,iBAAiB;QACrB,IAAItC,kBAAkB;YACpBC,oBAAoB;QACtB;QACAsC,WAAW;YACTtC,oBAAoB;QACtB,GAAG;IACL;IAEA,MAAM,EAAEuC,QAAQ,EAAEd,KAAK,EAAE,GAAGW;IAE5BjD,UAAU;QACR,IAAI,CAACqC,eAAe5B,SAAS;YAC3B2C,SAASzC;QACX;QACA,IAAI,CAACF,WAAW4B,aAAa;YAC3Be,SAAS;QACX;IACF,GAAG;QAACf;QAAa5B;QAAS2C;QAAUzC;KAAc;IAElDX,UAAU;QACR,IAAIY,kBAAkB;YACpBuC,WAAW;gBACTtC,oBAAoB;YACtB,GAAG;QACL;IACF,GAAG;QAACD;KAAiB;IAErB,IAAI,CAACH,SAAS;QACZ,OAAO;IACT;IAEA,qBACE,MAACV,MAAMsD,QAAQ;;0BACb,MAACV;gBAAIC,WAAW;oBAACrC;oBAAgB;oBAAW;iBAAY,CAAC+C,MAAM,CAACC,SAASC,IAAI,CAAC;;kCAC5E,KAAClE;wBAAWmE,aAAaf;wBAAsBgB,SAASrD;;kCACxD,KAACsD;wBACCC,cAAYrB;wBACZK,WAAWhC,mBAAmB,cAAciD;wBAC5CC,QAAQ;wBACRC,IAAG;wBACHrC,MAAK;wBACLG,MAAK;wBACLS,OAAO,AAACA,SAAoB;;;;YAG/B,CAAC5B,YAAYoC,iCACZ,KAACvD;gBAAqB2D,gBAAgBA;gBAAgBc,QAAQ,IAAMZ,SAAShD;;;;AAIrF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Default/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAM9D,OAAO,cAAc,CAAA;AAOrB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Edit/Default/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAM9D,OAAO,cAAc,CAAA;AAOrB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAuPnC,CAAA"}
|
|
@@ -42,7 +42,9 @@ export const DefaultEditView = ()=>{
|
|
|
42
42
|
const classes = [
|
|
43
43
|
baseClass,
|
|
44
44
|
id && `${baseClass}--is-editing`
|
|
45
|
-
]
|
|
45
|
+
];
|
|
46
|
+
if (globalSlug) classes.push(`global-edit--${globalSlug}`);
|
|
47
|
+
if (collectionSlug) classes.push(`collection-edit--${collectionSlug}`);
|
|
46
48
|
const [schemaPath, setSchemaPath] = React.useState(entitySlug);
|
|
47
49
|
const [validateBeforeSubmit, setValidateBeforeSubmit] = useState(()=>{
|
|
48
50
|
if (operation === 'create' && collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) return true;
|
|
@@ -119,7 +121,7 @@ export const DefaultEditView = ()=>{
|
|
|
119
121
|
serverURL
|
|
120
122
|
]);
|
|
121
123
|
return /*#__PURE__*/ _jsx("main", {
|
|
122
|
-
className: classes,
|
|
124
|
+
className: classes.filter(Boolean).join(' '),
|
|
123
125
|
children: /*#__PURE__*/ _jsx(OperationProvider, {
|
|
124
126
|
operation: operation,
|
|
125
127
|
children: /*#__PURE__*/ _jsxs(Form, {
|