@payloadcms/ui 3.61.0 → 3.61.1
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/DocumentDrawer/DrawerHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js +49 -21
- package/dist/elements/DocumentDrawer/DrawerHeader/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.d.ts +8 -0
- package/dist/elements/LeaveWithoutSaving/index.d.ts.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.js +72 -46
- package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.d.ts.map +1 -1
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.js +4 -2
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.js.map +1 -1
- package/dist/elements/PreviewButton/index.d.ts.map +1 -1
- package/dist/elements/PreviewButton/index.js +21 -27
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PublishButton/index.d.ts.map +1 -1
- package/dist/elements/PublishButton/index.js +1 -0
- package/dist/elements/PublishButton/index.js.map +1 -1
- package/dist/elements/QueryPresets/cells/WhereCell/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/cells/WhereCell/index.js +5 -1
- package/dist/elements/QueryPresets/cells/WhereCell/index.js.map +1 -1
- package/dist/exports/client/index.js +24 -24
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/rsc/index.d.ts +1 -0
- package/dist/exports/rsc/index.d.ts.map +1 -1
- package/dist/exports/rsc/index.js +1 -0
- package/dist/exports/rsc/index.js.map +1 -1
- package/dist/providers/LivePreview/context.d.ts +11 -0
- package/dist/providers/LivePreview/context.d.ts.map +1 -1
- package/dist/providers/LivePreview/context.js +18 -0
- package/dist/providers/LivePreview/context.js.map +1 -1
- package/dist/providers/LivePreview/index.d.ts +8 -0
- package/dist/providers/LivePreview/index.d.ts.map +1 -1
- package/dist/providers/LivePreview/index.js +6 -0
- package/dist/providers/LivePreview/index.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts +2 -0
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +18 -0
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/buildTableState.js +6 -1
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/handlePreview.d.ts +33 -0
- package/dist/utilities/handlePreview.d.ts.map +1 -0
- package/dist/utilities/handlePreview.js +71 -0
- package/dist/utilities/handlePreview.js.map +1 -0
- package/dist/views/Edit/index.d.ts.map +1 -1
- package/dist/views/Edit/index.js +29 -17
- package/dist/views/Edit/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/elements/PreviewButton/usePreviewURL.d.ts +0 -9
- package/dist/elements/PreviewButton/usePreviewURL.d.ts.map +0 -1
- package/dist/elements/PreviewButton/usePreviewURL.js +0 -86
- package/dist/elements/PreviewButton/usePreviewURL.js.map +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { extractJWT } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Multi-level check to determine whether live preview is enabled on a collection or global.
|
|
4
|
+
* For example, live preview can be enabled at both the root config level, or on the entity's config.
|
|
5
|
+
* If a collectionConfig/globalConfig is provided, checks if it is enabled at the root level,
|
|
6
|
+
* or on the entity's own config.
|
|
7
|
+
*/
|
|
8
|
+
export const isPreviewEnabled = ({
|
|
9
|
+
collectionConfig,
|
|
10
|
+
globalConfig
|
|
11
|
+
}) => {
|
|
12
|
+
if (globalConfig) {
|
|
13
|
+
return Boolean(globalConfig.admin?.preview);
|
|
14
|
+
}
|
|
15
|
+
if (collectionConfig) {
|
|
16
|
+
return Boolean(collectionConfig.admin?.preview);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 1. Looks up the relevant live preview config, which could have been enabled:
|
|
21
|
+
* a. At the root level, e.g. `collections: ['posts']`
|
|
22
|
+
* b. On the collection or global config, e.g. `admin: { livePreview: { ... } }`
|
|
23
|
+
* 2. Determines if live preview is enabled, and if not, early returns.
|
|
24
|
+
* 3. Merges the config with the root config, if necessary.
|
|
25
|
+
* 4. Executes the `url` function, if necessary.
|
|
26
|
+
*
|
|
27
|
+
* Notice: internal function only. Subject to change at any time. Use at your own risk.
|
|
28
|
+
*/
|
|
29
|
+
export const handlePreview = async ({
|
|
30
|
+
collectionSlug,
|
|
31
|
+
config,
|
|
32
|
+
data,
|
|
33
|
+
globalSlug,
|
|
34
|
+
operation,
|
|
35
|
+
req
|
|
36
|
+
}) => {
|
|
37
|
+
const collectionConfig = collectionSlug ? req.payload.collections[collectionSlug]?.config : undefined;
|
|
38
|
+
const globalConfig = globalSlug ? config.globals.find(g => g.slug === globalSlug) : undefined;
|
|
39
|
+
const enabled = isPreviewEnabled({
|
|
40
|
+
collectionConfig,
|
|
41
|
+
globalConfig
|
|
42
|
+
});
|
|
43
|
+
if (!enabled) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
const generatePreviewURL = collectionConfig?.admin?.preview || globalConfig?.admin?.preview;
|
|
47
|
+
const token = extractJWT(req);
|
|
48
|
+
let previewURL;
|
|
49
|
+
if (typeof generatePreviewURL === 'function' && operation !== 'create') {
|
|
50
|
+
try {
|
|
51
|
+
const result = await generatePreviewURL(data, {
|
|
52
|
+
locale: req.locale,
|
|
53
|
+
req,
|
|
54
|
+
token
|
|
55
|
+
});
|
|
56
|
+
if (typeof result === 'string') {
|
|
57
|
+
previewURL = result;
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
req.payload.logger.error({
|
|
61
|
+
err,
|
|
62
|
+
msg: `There was an error executing the live preview URL function for ${collectionSlug || globalSlug}`
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
isPreviewEnabled: enabled,
|
|
68
|
+
previewURL
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=handlePreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlePreview.js","names":["extractJWT","isPreviewEnabled","collectionConfig","globalConfig","Boolean","admin","preview","handlePreview","collectionSlug","config","data","globalSlug","operation","req","payload","collections","undefined","globals","find","g","slug","enabled","generatePreviewURL","token","previewURL","result","locale","err","logger","error","msg"],"sources":["../../src/utilities/handlePreview.ts"],"sourcesContent":["import {\n type CollectionConfig,\n extractJWT,\n type GlobalConfig,\n type Operation,\n type PayloadRequest,\n type SanitizedConfig,\n} from 'payload'\n\n/**\n * Multi-level check to determine whether live preview is enabled on a collection or global.\n * For example, live preview can be enabled at both the root config level, or on the entity's config.\n * If a collectionConfig/globalConfig is provided, checks if it is enabled at the root level,\n * or on the entity's own config.\n */\nexport const isPreviewEnabled = ({\n collectionConfig,\n globalConfig,\n}: {\n collectionConfig?: CollectionConfig\n globalConfig?: GlobalConfig\n}): boolean => {\n if (globalConfig) {\n return Boolean(globalConfig.admin?.preview)\n }\n\n if (collectionConfig) {\n return Boolean(collectionConfig.admin?.preview)\n }\n}\n\n/**\n * 1. Looks up the relevant live preview config, which could have been enabled:\n * a. At the root level, e.g. `collections: ['posts']`\n * b. On the collection or global config, e.g. `admin: { livePreview: { ... } }`\n * 2. Determines if live preview is enabled, and if not, early returns.\n * 3. Merges the config with the root config, if necessary.\n * 4. Executes the `url` function, if necessary.\n *\n * Notice: internal function only. Subject to change at any time. Use at your own risk.\n */\nexport const handlePreview = async ({\n collectionSlug,\n config,\n data,\n globalSlug,\n operation,\n req,\n}: {\n collectionSlug?: string\n config: SanitizedConfig\n data: Record<string, unknown>\n globalSlug?: string\n operation?: Operation\n req: PayloadRequest\n}): Promise<{\n isPreviewEnabled?: boolean\n previewURL?: string\n}> => {\n const collectionConfig = collectionSlug\n ? req.payload.collections[collectionSlug]?.config\n : undefined\n\n const globalConfig = globalSlug ? config.globals.find((g) => g.slug === globalSlug) : undefined\n\n const enabled = isPreviewEnabled({\n collectionConfig,\n globalConfig,\n })\n\n if (!enabled) {\n return {}\n }\n\n const generatePreviewURL = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n const token = extractJWT(req)\n let previewURL: string | undefined\n\n if (typeof generatePreviewURL === 'function' && operation !== 'create') {\n try {\n const result = await generatePreviewURL(data, { locale: req.locale, req, token })\n\n if (typeof result === 'string') {\n previewURL = result\n }\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `There was an error executing the live preview URL function for ${collectionSlug || globalSlug}`,\n })\n }\n }\n\n return { isPreviewEnabled: enabled, previewURL }\n}\n"],"mappings":"AAAA,SAEEA,UAAU,QAKL;AAEP;;;;;;AAMA,OAAO,MAAMC,gBAAA,GAAmBA,CAAC;EAC/BC,gBAAgB;EAChBC;AAAY,CAIb;EACC,IAAIA,YAAA,EAAc;IAChB,OAAOC,OAAA,CAAQD,YAAA,CAAaE,KAAK,EAAEC,OAAA;EACrC;EAEA,IAAIJ,gBAAA,EAAkB;IACpB,OAAOE,OAAA,CAAQF,gBAAA,CAAiBG,KAAK,EAAEC,OAAA;EACzC;AACF;AAEA;;;;;;;;;;AAUA,OAAO,MAAMC,aAAA,GAAgB,MAAAA,CAAO;EAClCC,cAAc;EACdC,MAAM;EACNC,IAAI;EACJC,UAAU;EACVC,SAAS;EACTC;AAAG,CAQJ;EAIC,MAAMX,gBAAA,GAAmBM,cAAA,GACrBK,GAAA,CAAIC,OAAO,CAACC,WAAW,CAACP,cAAA,CAAe,EAAEC,MAAA,GACzCO,SAAA;EAEJ,MAAMb,YAAA,GAAeQ,UAAA,GAAaF,MAAA,CAAOQ,OAAO,CAACC,IAAI,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAKT,UAAA,IAAcK,SAAA;EAEtF,MAAMK,OAAA,GAAUpB,gBAAA,CAAiB;IAC/BC,gBAAA;IACAC;EACF;EAEA,IAAI,CAACkB,OAAA,EAAS;IACZ,OAAO,CAAC;EACV;EAEA,MAAMC,kBAAA,GAAqBpB,gBAAA,EAAkBG,KAAA,EAAOC,OAAA,IAAWH,YAAA,EAAcE,KAAA,EAAOC,OAAA;EACpF,MAAMiB,KAAA,GAAQvB,UAAA,CAAWa,GAAA;EACzB,IAAIW,UAAA;EAEJ,IAAI,OAAOF,kBAAA,KAAuB,cAAcV,SAAA,KAAc,UAAU;IACtE,IAAI;MACF,MAAMa,MAAA,GAAS,MAAMH,kBAAA,CAAmBZ,IAAA,EAAM;QAAEgB,MAAA,EAAQb,GAAA,CAAIa,MAAM;QAAEb,GAAA;QAAKU;MAAM;MAE/E,IAAI,OAAOE,MAAA,KAAW,UAAU;QAC9BD,UAAA,GAAaC,MAAA;MACf;IACF,EAAE,OAAOE,GAAA,EAAK;MACZd,GAAA,CAAIC,OAAO,CAACc,MAAM,CAACC,KAAK,CAAC;QACvBF,GAAA;QACAG,GAAA,EAAK,kEAAkEtB,cAAA,IAAkBG,UAAA;MAC3F;IACF;EACF;EAEA,OAAO;IAAEV,gBAAA,EAAkBoB,OAAA;IAASG;EAAW;AACjD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Edit/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Edit/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAKlE,OAAO,KAAsE,MAAM,OAAO,CAAA;AAkC1F,OAAO,cAAc,CAAA;AAKrB,MAAM,MAAM,aAAa,GAAG;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAKD,wBAAgB,eAAe,CAAC,EAC9B,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,WAAW,EAAE,iBAAiB,EAC9B,aAAa,EACb,aAAa,EACb,UAAU,EACV,eAAe,EACf,MAAM,EAAE,YAAY,EACpB,cAAc,GACf,EAAE,uBAAuB,qBAkpBzB"}
|
package/dist/views/Edit/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
+
import { useModal } from '@faceless-ui/modal';
|
|
4
5
|
import { useRouter, useSearchParams } from 'next/navigation.js';
|
|
5
6
|
import { formatAdminURL } from 'payload/shared';
|
|
6
7
|
import React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -19,7 +20,7 @@ import { useConfig } from '../../providers/Config/index.js';
|
|
|
19
20
|
import { useDocumentEvents } from '../../providers/DocumentEvents/index.js';
|
|
20
21
|
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
|
|
21
22
|
import { useEditDepth } from '../../providers/EditDepth/index.js';
|
|
22
|
-
import { useLivePreviewContext } from '../../providers/LivePreview/context.js';
|
|
23
|
+
import { useLivePreviewContext, usePreviewURL } from '../../providers/LivePreview/context.js';
|
|
23
24
|
import { OperationProvider } from '../../providers/Operation/index.js';
|
|
24
25
|
import { useRouteCache } from '../../providers/RouteCache/index.js';
|
|
25
26
|
import { useRouteTransition } from '../../providers/RouteTransition/index.js';
|
|
@@ -32,8 +33,8 @@ import { handleGoBack } from '../../utilities/handleGoBack.js';
|
|
|
32
33
|
import { handleTakeOver } from '../../utilities/handleTakeOver.js';
|
|
33
34
|
import { Auth } from './Auth/index.js';
|
|
34
35
|
import { SetDocumentStepNav } from './SetDocumentStepNav/index.js';
|
|
35
|
-
import { SetDocumentTitle } from './SetDocumentTitle/index.js';
|
|
36
36
|
import './index.scss';
|
|
37
|
+
import { SetDocumentTitle } from './SetDocumentTitle/index.js';
|
|
37
38
|
const baseClass = 'collection-edit';
|
|
38
39
|
// This component receives props only on _pages_
|
|
39
40
|
// When rendered within a drawer, props are empty
|
|
@@ -97,6 +98,9 @@ export function DefaultEditView({
|
|
|
97
98
|
onRestore,
|
|
98
99
|
onSave: onSaveFromContext
|
|
99
100
|
} = useDocumentDrawerContext();
|
|
101
|
+
const {
|
|
102
|
+
closeModal
|
|
103
|
+
} = useModal();
|
|
100
104
|
const isInDrawer = Boolean(drawerSlug);
|
|
101
105
|
const {
|
|
102
106
|
refreshCookieAsync,
|
|
@@ -146,6 +150,10 @@ export function DefaultEditView({
|
|
|
146
150
|
typeofLivePreviewURL,
|
|
147
151
|
url: livePreviewURL
|
|
148
152
|
} = useLivePreviewContext();
|
|
153
|
+
const {
|
|
154
|
+
isPreviewEnabled,
|
|
155
|
+
setPreviewURL
|
|
156
|
+
} = usePreviewURL();
|
|
149
157
|
const abortOnChangeRef = useRef(null);
|
|
150
158
|
const abortOnSaveRef = useRef(null);
|
|
151
159
|
const locale = params.get('locale');
|
|
@@ -161,12 +169,12 @@ export function DefaultEditView({
|
|
|
161
169
|
const lockDuration = typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault;
|
|
162
170
|
const lockDurationInMilliseconds = lockDuration * 1000;
|
|
163
171
|
const autosaveEnabled = Boolean(collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave || globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave);
|
|
164
|
-
const preventLeaveWithoutSaving = typeof disableLeaveWithoutSaving !== 'undefined' ? !disableLeaveWithoutSaving : !autosaveEnabled;
|
|
165
172
|
const [isReadOnlyForIncomingUser, setIsReadOnlyForIncomingUser] = useState(false);
|
|
166
173
|
const [showTakeOverModal, setShowTakeOverModal] = useState(false);
|
|
167
174
|
const [editSessionStartTime, setEditSessionStartTime] = useState(Date.now());
|
|
168
175
|
const lockExpiryTime = lastUpdateTime + lockDurationInMilliseconds;
|
|
169
176
|
const isLockExpired = Date.now() > lockExpiryTime;
|
|
177
|
+
const preventLeaveWithoutSaving = !isReadOnlyForIncomingUser && (typeof disableLeaveWithoutSaving !== 'undefined' ? !disableLeaveWithoutSaving : !autosaveEnabled);
|
|
170
178
|
const schemaPathSegments = useMemo(() => [entitySlug], [entitySlug]);
|
|
171
179
|
const [validateBeforeSubmit, setValidateBeforeSubmit] = useState(() => {
|
|
172
180
|
if (operation === 'create' && auth && !auth.disableLocalStrategy) {
|
|
@@ -208,17 +216,15 @@ export function DefaultEditView({
|
|
|
208
216
|
// Check where user is trying to go
|
|
209
217
|
const nextPath = nextHrefRef.current ? new URL(nextHrefRef.current).pathname : '';
|
|
210
218
|
const isInternalView = ['/preview', '/api', '/versions'].some(path => nextPath.includes(path));
|
|
211
|
-
//
|
|
212
|
-
if (!isInternalView) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
;
|
|
221
|
-
}
|
|
219
|
+
// Remove the lock if the user is navigating away from the document view they have locked
|
|
220
|
+
if (isLockOwnedByCurrentUser && !isInternalView) {
|
|
221
|
+
try {
|
|
222
|
+
await unlockDocument(id, collectionSlug ?? globalSlug);
|
|
223
|
+
setDocumentIsLocked(false);
|
|
224
|
+
setCurrentEditor(null);
|
|
225
|
+
} catch (err) {
|
|
226
|
+
console.error('Failed to unlock before leave', err) // eslint-disable-line no-console
|
|
227
|
+
;
|
|
222
228
|
}
|
|
223
229
|
}
|
|
224
230
|
}
|
|
@@ -270,6 +276,7 @@ export function DefaultEditView({
|
|
|
270
276
|
const docPreferences = await getDocPreferences();
|
|
271
277
|
const {
|
|
272
278
|
livePreviewURL: livePreviewURL_0,
|
|
279
|
+
previewURL,
|
|
273
280
|
state
|
|
274
281
|
} = await getFormState({
|
|
275
282
|
id,
|
|
@@ -283,6 +290,7 @@ export function DefaultEditView({
|
|
|
283
290
|
renderAllFields: false,
|
|
284
291
|
returnLivePreviewURL: isLivePreviewEnabled && typeofLivePreviewURL === 'function',
|
|
285
292
|
returnLockStatus: false,
|
|
293
|
+
returnPreviewURL: isPreviewEnabled,
|
|
286
294
|
schemaPath: schemaPathSegments.join('.'),
|
|
287
295
|
signal: controller.signal,
|
|
288
296
|
skipValidation: true
|
|
@@ -294,6 +302,9 @@ export function DefaultEditView({
|
|
|
294
302
|
if (isLivePreviewEnabled && typeofLivePreviewURL === 'function') {
|
|
295
303
|
setLivePreviewURL(livePreviewURL_0);
|
|
296
304
|
}
|
|
305
|
+
if (isPreviewEnabled) {
|
|
306
|
+
setPreviewURL(previewURL);
|
|
307
|
+
}
|
|
297
308
|
reportUpdate({
|
|
298
309
|
id,
|
|
299
310
|
entitySlug,
|
|
@@ -302,7 +313,7 @@ export function DefaultEditView({
|
|
|
302
313
|
abortOnSaveRef.current = null;
|
|
303
314
|
return state;
|
|
304
315
|
}
|
|
305
|
-
}, [reportUpdate, id, entitySlug, user, collectionSlug, userSlug, setLastUpdateTime, setData, onSaveFromContext, isEditing, depth, redirectAfterCreate, setLivePreviewURL, globalSlug, refreshCookieAsync, incrementVersionCount, adminRoute, locale, startRouteTransition, router, resetUploadEdits, getDocPermissions, getDocPreferences, getFormState, docPermissions, operation, isLivePreviewEnabled, typeofLivePreviewURL, schemaPathSegments, isLockingEnabled, setDocumentIsLocked]);
|
|
316
|
+
}, [reportUpdate, id, entitySlug, user, collectionSlug, userSlug, setLastUpdateTime, setData, onSaveFromContext, isEditing, depth, redirectAfterCreate, setLivePreviewURL, setPreviewURL, globalSlug, refreshCookieAsync, incrementVersionCount, adminRoute, locale, startRouteTransition, router, resetUploadEdits, getDocPermissions, getDocPreferences, getFormState, docPermissions, operation, isLivePreviewEnabled, isPreviewEnabled, typeofLivePreviewURL, schemaPathSegments, isLockingEnabled, setDocumentIsLocked]);
|
|
306
317
|
const onChange = useCallback(async ({
|
|
307
318
|
formState: prevFormState,
|
|
308
319
|
submitted
|
|
@@ -414,7 +425,7 @@ export function DefaultEditView({
|
|
|
414
425
|
setIsReadOnlyForIncomingUser(true);
|
|
415
426
|
setShowTakeOverModal(false);
|
|
416
427
|
}
|
|
417
|
-
}),
|
|
428
|
+
}), preventLeaveWithoutSaving && /*#__PURE__*/_jsx(LeaveWithoutSaving, {
|
|
418
429
|
onConfirm: handleLeaveConfirm,
|
|
419
430
|
onPrevent: handlePrevent
|
|
420
431
|
}), !isInDrawer && /*#__PURE__*/_jsx(SetDocumentStepNav, {
|
|
@@ -490,6 +501,7 @@ export function DefaultEditView({
|
|
|
490
501
|
readOnly: !hasSavePermission,
|
|
491
502
|
requirePassword: !id,
|
|
492
503
|
setValidateBeforeSubmit: setValidateBeforeSubmit,
|
|
504
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
493
505
|
useAPIKey: auth.useAPIKey,
|
|
494
506
|
username: data?.username,
|
|
495
507
|
verify: auth.verify
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useRouter","useSearchParams","formatAdminURL","React","Fragment","useCallback","useEffect","useMemo","useRef","useState","DocumentControls","DocumentDrawerHeader","useDocumentDrawerContext","DocumentFields","DocumentLocked","DocumentTakeOver","LeaveWithoutSaving","LivePreviewWindow","Upload","Form","useAuth","useConfig","useDocumentEvents","useDocumentInfo","useEditDepth","useLivePreviewContext","OperationProvider","useRouteCache","useRouteTransition","useServerFunctions","UploadControlsProvider","useUploadEdits","abortAndIgnore","handleAbortRef","handleBackToDashboard","handleGoBack","handleTakeOver","Auth","SetDocumentStepNav","SetDocumentTitle","baseClass","DefaultEditView","BeforeDocumentControls","Description","EditMenuItems","LivePreview","CustomLivePreview","PreviewButton","PublishButton","SaveButton","SaveDraftButton","CustomUpload","UploadControls","id","action","AfterDocument","AfterFields","apiURL","BeforeFields","collectionSlug","currentEditor","data","disableActions","disableCreate","disableLeaveWithoutSaving","docPermissions","documentIsLocked","documentLockState","getDocPermissions","getDocPreferences","globalSlug","hasPublishPermission","hasSavePermission","incrementVersionCount","initialState","isEditing","isInitializing","isLocked","isTrashed","lastUpdateTime","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","setCurrentEditor","setData","setDocumentIsLocked","setLastUpdateTime","unlockDocument","updateDocumentEditor","clearDoc","drawerSlug","onDelete","onDuplicate","onRestore","onSave","onSaveFromContext","isInDrawer","Boolean","refreshCookieAsync","user","config","admin","userSlug","routes","adminRoute","getEntityConfig","collectionConfig","globalConfig","depth","router","params","reportUpdate","resetUploadEdits","getFormState","startRouteTransition","clearRouteCache","isLivePreviewEnabled","isLivePreviewing","previewWindowType","setURL","setLivePreviewURL","typeofLivePreviewURL","url","livePreviewURL","abortOnChangeRef","abortOnSaveRef","locale","get","entitySlug","slug","operation","auth","undefined","upload","docConfig","lockDocumentsProp","lockDocuments","isLockingEnabled","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","autosaveEnabled","versions","drafts","autosave","preventLeaveWithoutSaving","isReadOnlyForIncomingUser","setIsReadOnlyForIncomingUser","showTakeOverModal","setShowTakeOverModal","editSessionStartTime","setEditSessionStartTime","Date","now","lockExpiryTime","isLockExpired","schemaPathSegments","validateBeforeSubmit","setValidateBeforeSubmit","disableLocalStrategy","nextHrefRef","handleDocumentLocking","lockedState","previousOwnerID","current","lockedUserID","hasShownLockedModal","lastEditedAt","getTime","handlePrevent","nextHref","handleLeaveConfirm","lockUser","isLockOwnedByCurrentUser","nextPath","URL","pathname","isInternalView","some","path","includes","err","console","error","json","ctx","context","formState","controller","document","doc","result","updatedAt","toISOString","redirectRoute","push","docPreferences","state","renderAllFields","returnLivePreviewURL","returnLockStatus","schemaPath","join","signal","skipValidation","onChange","prevFormState","submitted","currentTime","timeSinceLastUpdate","updateLastEdited","abortOnChange","abortOnSave","shouldShowDocumentLockedModal","isFolderCollection","folders","_jsx","className","filter","_jsxs","disabled","disableValidationOnSubmit","isDocumentForm","method","onSuccess","AfterHeader","showDocumentID","isActive","onReadOnly","onTakeOver","documentLockStateRef","isWithinDoc","onConfirm","onPrevent","pluralLabel","labels","plural","useAsTitle","fallback","toString","customComponents","onDrawerCreateNew","permissions","readOnlyForIncomingUser","email","loginWithUsername","readOnly","requirePassword","useAPIKey","username","verify","uploadConfig","fields","forceSidebarWrap","_Fragment"],"sources":["../../../src/views/Edit/index.tsx"],"sourcesContent":["/* eslint-disable react-compiler/react-compiler -- TODO: fix */\n'use client'\n\nimport type { ClientUser, DocumentViewClientProps } from 'payload'\n\nimport { useRouter, useSearchParams } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { FormProps } from '../../forms/Form/index.js'\nimport type { FormOnSuccess } from '../../forms/Form/types.js'\nimport type { LockedState } from '../../utilities/buildFormState.js'\n\nimport { DocumentControls } from '../../elements/DocumentControls/index.js'\nimport { DocumentDrawerHeader } from '../../elements/DocumentDrawer/DrawerHeader/index.js'\nimport { useDocumentDrawerContext } from '../../elements/DocumentDrawer/Provider.js'\nimport { DocumentFields } from '../../elements/DocumentFields/index.js'\nimport { DocumentLocked } from '../../elements/DocumentLocked/index.js'\nimport { DocumentTakeOver } from '../../elements/DocumentTakeOver/index.js'\nimport { LeaveWithoutSaving } from '../../elements/LeaveWithoutSaving/index.js'\nimport { LivePreviewWindow } from '../../elements/LivePreview/Window/index.js'\nimport { Upload } from '../../elements/Upload/index.js'\nimport { Form } from '../../forms/Form/index.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentEvents } from '../../providers/DocumentEvents/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useLivePreviewContext } from '../../providers/LivePreview/context.js'\nimport { OperationProvider } from '../../providers/Operation/index.js'\nimport { useRouteCache } from '../../providers/RouteCache/index.js'\nimport { useRouteTransition } from '../../providers/RouteTransition/index.js'\nimport { useServerFunctions } from '../../providers/ServerFunctions/index.js'\nimport { UploadControlsProvider } from '../../providers/UploadControls/index.js'\nimport { useUploadEdits } from '../../providers/UploadEdits/index.js'\nimport { abortAndIgnore, handleAbortRef } from '../../utilities/abortAndIgnore.js'\nimport { handleBackToDashboard } from '../../utilities/handleBackToDashboard.js'\nimport { handleGoBack } from '../../utilities/handleGoBack.js'\nimport { handleTakeOver } from '../../utilities/handleTakeOver.js'\nimport { Auth } from './Auth/index.js'\nimport { SetDocumentStepNav } from './SetDocumentStepNav/index.js'\nimport { SetDocumentTitle } from './SetDocumentTitle/index.js'\nimport './index.scss'\n\nconst baseClass = 'collection-edit'\n\nexport type OnSaveContext = {\n getDocPermissions?: boolean\n incrementVersionCount?: boolean\n}\n\n// This component receives props only on _pages_\n// When rendered within a drawer, props are empty\n// This is solely to support custom edit views which get server-rendered\nexport function DefaultEditView({\n BeforeDocumentControls,\n Description,\n EditMenuItems,\n LivePreview: CustomLivePreview,\n PreviewButton,\n PublishButton,\n SaveButton,\n SaveDraftButton,\n Upload: CustomUpload,\n UploadControls,\n}: DocumentViewClientProps) {\n const {\n id,\n action,\n AfterDocument,\n AfterFields,\n apiURL,\n BeforeFields,\n collectionSlug,\n currentEditor,\n data,\n disableActions,\n disableCreate,\n disableLeaveWithoutSaving,\n docPermissions,\n documentIsLocked,\n documentLockState,\n getDocPermissions,\n getDocPreferences,\n globalSlug,\n hasPublishPermission,\n hasSavePermission,\n incrementVersionCount,\n initialState,\n isEditing,\n isInitializing,\n isLocked,\n isTrashed,\n lastUpdateTime,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n setCurrentEditor,\n setData,\n setDocumentIsLocked,\n setLastUpdateTime,\n unlockDocument,\n updateDocumentEditor,\n } = useDocumentInfo()\n\n const {\n clearDoc,\n drawerSlug,\n onDelete,\n onDuplicate,\n onRestore,\n onSave: onSaveFromContext,\n } = useDocumentDrawerContext()\n\n const isInDrawer = Boolean(drawerSlug)\n\n const { refreshCookieAsync, user } = useAuth()\n\n const {\n config,\n config: {\n admin: { user: userSlug },\n routes: { admin: adminRoute },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n const depth = useEditDepth()\n\n const router = useRouter()\n const params = useSearchParams()\n const { reportUpdate } = useDocumentEvents()\n const { resetUploadEdits } = useUploadEdits()\n const { getFormState } = useServerFunctions()\n const { startRouteTransition } = useRouteTransition()\n const { clearRouteCache } = useRouteCache()\n const {\n isLivePreviewEnabled,\n isLivePreviewing,\n previewWindowType,\n setURL: setLivePreviewURL,\n typeofLivePreviewURL,\n url: livePreviewURL,\n } = useLivePreviewContext()\n\n const abortOnChangeRef = useRef<AbortController>(null)\n const abortOnSaveRef = useRef<AbortController>(null)\n\n const locale = params.get('locale')\n\n const entitySlug = collectionConfig?.slug || globalConfig?.slug\n\n const operation = collectionSlug && !id ? 'create' : 'update'\n\n const auth = collectionConfig ? collectionConfig.auth : undefined\n const upload = collectionConfig ? collectionConfig.upload : undefined\n\n const docConfig = collectionConfig || globalConfig\n\n const lockDocumentsProp = docConfig?.lockDocuments !== undefined ? docConfig?.lockDocuments : true\n const isLockingEnabled = lockDocumentsProp !== false\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const autosaveEnabled = Boolean(\n (collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave),\n )\n\n const preventLeaveWithoutSaving =\n typeof disableLeaveWithoutSaving !== 'undefined' ? !disableLeaveWithoutSaving : !autosaveEnabled\n\n const [isReadOnlyForIncomingUser, setIsReadOnlyForIncomingUser] = useState(false)\n const [showTakeOverModal, setShowTakeOverModal] = useState(false)\n\n const [editSessionStartTime, setEditSessionStartTime] = useState(Date.now())\n\n const lockExpiryTime = lastUpdateTime + lockDurationInMilliseconds\n\n const isLockExpired = Date.now() > lockExpiryTime\n\n const schemaPathSegments = useMemo(() => [entitySlug], [entitySlug])\n\n const [validateBeforeSubmit, setValidateBeforeSubmit] = useState(() => {\n if (operation === 'create' && auth && !auth.disableLocalStrategy) {\n return true\n }\n\n return false\n })\n\n const nextHrefRef = React.useRef<null | string>(null)\n\n const handleDocumentLocking = useCallback(\n (lockedState: LockedState) => {\n setDocumentIsLocked(true)\n const previousOwnerID =\n typeof documentLockState.current?.user === 'object'\n ? documentLockState.current?.user?.id\n : documentLockState.current?.user\n\n if (lockedState) {\n const lockedUserID =\n typeof lockedState.user === 'string' || typeof lockedState.user === 'number'\n ? lockedState.user\n : lockedState.user.id\n\n if (!documentLockState.current || lockedUserID !== previousOwnerID) {\n if (previousOwnerID === user.id && lockedUserID !== user.id) {\n setShowTakeOverModal(true)\n documentLockState.current.hasShownLockedModal = true\n }\n\n documentLockState.current = {\n hasShownLockedModal: documentLockState.current?.hasShownLockedModal || false,\n isLocked: true,\n user: lockedState.user as ClientUser,\n }\n setCurrentEditor(lockedState.user as ClientUser)\n }\n\n // Update lastUpdateTime when lock state changes\n if (lockedState.lastEditedAt) {\n setLastUpdateTime(new Date(lockedState.lastEditedAt).getTime())\n }\n }\n },\n [documentLockState, setCurrentEditor, setDocumentIsLocked, setLastUpdateTime, user?.id],\n )\n\n const handlePrevent = useCallback((nextHref: null | string) => {\n nextHrefRef.current = nextHref\n }, [])\n\n const handleLeaveConfirm = useCallback(async () => {\n const lockUser = documentLockState.current?.user\n\n const isLockOwnedByCurrentUser =\n typeof lockUser === 'object' ? lockUser?.id === user?.id : lockUser === user?.id\n\n if (isLockingEnabled && documentIsLocked && (id || globalSlug)) {\n // Check where user is trying to go\n const nextPath = nextHrefRef.current ? new URL(nextHrefRef.current).pathname : ''\n const isInternalView = ['/preview', '/api', '/versions'].some((path) =>\n nextPath.includes(path),\n )\n\n // Only retain the lock if the user is still viewing the document\n if (!isInternalView) {\n if (isLockOwnedByCurrentUser) {\n try {\n await unlockDocument(id, collectionSlug ?? globalSlug)\n setDocumentIsLocked(false)\n setCurrentEditor(null)\n } catch (err) {\n console.error('Failed to unlock before leave', err) // eslint-disable-line no-console\n }\n }\n }\n }\n }, [\n collectionSlug,\n documentIsLocked,\n documentLockState,\n globalSlug,\n id,\n isLockingEnabled,\n setCurrentEditor,\n setDocumentIsLocked,\n unlockDocument,\n user?.id,\n ])\n\n const onSave: FormOnSuccess<any, OnSaveContext> = useCallback(\n async (json, ctx) => {\n const { context, formState } = ctx || {}\n\n const controller = handleAbortRef(abortOnSaveRef)\n\n const document = json?.doc || json?.result\n\n const updatedAt = document?.updatedAt || new Date().toISOString()\n\n // If we're editing the doc of the logged-in user,\n // Refresh the cookie to get new permissions\n if (user && collectionSlug === userSlug && id === user.id) {\n void refreshCookieAsync()\n }\n\n setLastUpdateTime(updatedAt)\n\n if (context?.incrementVersionCount !== false) {\n incrementVersionCount()\n }\n\n if (typeof setData === 'function') {\n void setData(document || {})\n }\n\n if (typeof onSaveFromContext === 'function') {\n const operation = id ? 'update' : 'create'\n\n void onSaveFromContext({\n ...(json as Record<string, unknown>),\n context,\n operation,\n // @ts-expect-error todo: this is not right, should be under `doc`?\n updatedAt:\n operation === 'update'\n ? new Date().toISOString()\n : document?.updatedAt || new Date().toISOString(),\n })\n }\n\n if (!isEditing && depth < 2 && redirectAfterCreate !== false) {\n // Redirect to the same locale if it's been set\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${document?.id}${locale ? `?locale=${locale}` : ''}`,\n })\n\n startRouteTransition(() => router.push(redirectRoute))\n } else {\n resetUploadEdits()\n }\n\n if (context?.getDocPermissions !== false) {\n await getDocPermissions(json)\n }\n\n if (id || globalSlug) {\n const docPreferences = await getDocPreferences()\n\n const { livePreviewURL, state } = await getFormState({\n id,\n collectionSlug,\n data: document,\n docPermissions,\n docPreferences,\n formState,\n globalSlug,\n operation,\n renderAllFields: false,\n returnLivePreviewURL: isLivePreviewEnabled && typeofLivePreviewURL === 'function',\n returnLockStatus: false,\n schemaPath: schemaPathSegments.join('.'),\n signal: controller.signal,\n skipValidation: true,\n })\n\n // Unlock the document after save\n if (isLockingEnabled) {\n setDocumentIsLocked(false)\n }\n\n if (isLivePreviewEnabled && typeofLivePreviewURL === 'function') {\n setLivePreviewURL(livePreviewURL)\n }\n\n reportUpdate({\n id,\n entitySlug,\n updatedAt,\n })\n\n abortOnSaveRef.current = null\n\n return state\n }\n },\n [\n reportUpdate,\n id,\n entitySlug,\n user,\n collectionSlug,\n userSlug,\n setLastUpdateTime,\n setData,\n onSaveFromContext,\n isEditing,\n depth,\n redirectAfterCreate,\n setLivePreviewURL,\n globalSlug,\n refreshCookieAsync,\n incrementVersionCount,\n adminRoute,\n locale,\n startRouteTransition,\n router,\n resetUploadEdits,\n getDocPermissions,\n getDocPreferences,\n getFormState,\n docPermissions,\n operation,\n isLivePreviewEnabled,\n typeofLivePreviewURL,\n schemaPathSegments,\n isLockingEnabled,\n setDocumentIsLocked,\n ],\n )\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState, submitted }) => {\n const controller = handleAbortRef(abortOnChangeRef)\n\n const currentTime = Date.now()\n const timeSinceLastUpdate = currentTime - editSessionStartTime\n\n const updateLastEdited = isLockingEnabled && timeSinceLastUpdate >= 10000 // 10 seconds\n\n if (updateLastEdited) {\n setEditSessionStartTime(currentTime)\n }\n\n const docPreferences = await getDocPreferences()\n\n const result = await getFormState({\n id,\n collectionSlug,\n docPermissions,\n docPreferences,\n formState: prevFormState,\n globalSlug,\n operation,\n renderAllFields: false,\n returnLockStatus: isLockingEnabled,\n schemaPath: schemaPathSegments.join('.'),\n signal: controller.signal,\n skipValidation: !submitted,\n updateLastEdited,\n })\n\n if (!result) {\n return\n }\n\n const { lockedState, state } = result\n\n if (isLockingEnabled) {\n handleDocumentLocking(lockedState)\n }\n\n abortOnChangeRef.current = null\n\n return state\n },\n [\n editSessionStartTime,\n isLockingEnabled,\n getDocPreferences,\n getFormState,\n id,\n collectionSlug,\n docPermissions,\n globalSlug,\n operation,\n schemaPathSegments,\n handleDocumentLocking,\n ],\n )\n\n // Clean up when the component unmounts or when the document is unlocked\n useEffect(() => {\n return () => {\n setShowTakeOverModal(false)\n }\n }, [])\n\n useEffect(() => {\n const abortOnChange = abortOnChangeRef.current\n const abortOnSave = abortOnSaveRef.current\n\n return () => {\n abortAndIgnore(abortOnChange)\n abortAndIgnore(abortOnSave)\n }\n }, [])\n\n const shouldShowDocumentLockedModal =\n documentIsLocked &&\n currentEditor &&\n (typeof currentEditor === 'object'\n ? currentEditor.id !== user?.id\n : currentEditor !== user?.id) &&\n !isReadOnlyForIncomingUser &&\n !showTakeOverModal &&\n !documentLockState.current?.hasShownLockedModal &&\n !isLockExpired\n\n const isFolderCollection = config.folders && collectionSlug === config.folders?.slug\n\n return (\n <main\n className={[\n baseClass,\n (id || globalSlug) && `${baseClass}--is-editing`,\n globalSlug && `global-edit--${globalSlug}`,\n collectionSlug && `collection-edit--${collectionSlug}`,\n isLivePreviewing && previewWindowType === 'iframe' && `${baseClass}--is-live-previewing`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <OperationProvider operation={operation}>\n <Form\n action={action}\n className={`${baseClass}__form`}\n disabled={isReadOnlyForIncomingUser || isInitializing || !hasSavePermission || isTrashed}\n disableValidationOnSubmit={!validateBeforeSubmit}\n initialState={!isInitializing && initialState}\n isDocumentForm={true}\n isInitializing={isInitializing}\n key={`${isLocked}`}\n method={id ? 'PATCH' : 'POST'}\n onChange={[onChange]}\n onSuccess={onSave}\n >\n {isInDrawer && (\n <DocumentDrawerHeader\n AfterHeader={Description}\n drawerSlug={drawerSlug}\n showDocumentID={!isFolderCollection}\n />\n )}\n {isLockingEnabled && shouldShowDocumentLockedModal && (\n <DocumentLocked\n handleGoBack={() => handleGoBack({ adminRoute, collectionSlug, router })}\n isActive={shouldShowDocumentLockedModal}\n onReadOnly={() => {\n setIsReadOnlyForIncomingUser(true)\n setShowTakeOverModal(false)\n }}\n onTakeOver={() =>\n handleTakeOver({\n id,\n clearRouteCache,\n collectionSlug,\n documentLockStateRef: documentLockState,\n globalSlug,\n isLockingEnabled,\n isWithinDoc: false,\n setCurrentEditor,\n updateDocumentEditor,\n user,\n })\n }\n updatedAt={lastUpdateTime}\n user={currentEditor}\n />\n )}\n {isLockingEnabled && showTakeOverModal && (\n <DocumentTakeOver\n handleBackToDashboard={() => handleBackToDashboard({ adminRoute, router })}\n isActive={showTakeOverModal}\n onReadOnly={() => {\n setIsReadOnlyForIncomingUser(true)\n setShowTakeOverModal(false)\n }}\n />\n )}\n {!isReadOnlyForIncomingUser && preventLeaveWithoutSaving && (\n <LeaveWithoutSaving onConfirm={handleLeaveConfirm} onPrevent={handlePrevent} />\n )}\n {!isInDrawer && (\n <SetDocumentStepNav\n collectionSlug={collectionConfig?.slug}\n globalSlug={globalConfig?.slug}\n id={id}\n isTrashed={isTrashed}\n pluralLabel={collectionConfig?.labels?.plural}\n useAsTitle={collectionConfig?.admin?.useAsTitle}\n />\n )}\n <SetDocumentTitle\n collectionConfig={collectionConfig}\n config={config}\n fallback={depth <= 1 ? id?.toString() : undefined}\n globalConfig={globalConfig}\n />\n <DocumentControls\n apiURL={apiURL}\n BeforeDocumentControls={BeforeDocumentControls}\n customComponents={{\n PreviewButton,\n PublishButton,\n SaveButton,\n SaveDraftButton,\n }}\n data={data}\n disableActions={disableActions || isFolderCollection || isTrashed}\n disableCreate={disableCreate}\n EditMenuItems={EditMenuItems}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n isEditing={isEditing}\n isInDrawer={isInDrawer}\n isTrashed={isTrashed}\n onDelete={onDelete}\n onDrawerCreateNew={clearDoc}\n onDuplicate={onDuplicate}\n onRestore={onRestore}\n onSave={onSave}\n onTakeOver={() =>\n handleTakeOver({\n id,\n clearRouteCache,\n collectionSlug,\n documentLockStateRef: documentLockState,\n globalSlug,\n isLockingEnabled,\n isWithinDoc: true,\n setCurrentEditor,\n setIsReadOnlyForIncomingUser,\n updateDocumentEditor,\n user,\n })\n }\n permissions={docPermissions}\n readOnlyForIncomingUser={isReadOnlyForIncomingUser}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n slug={collectionConfig?.slug || globalConfig?.slug}\n user={currentEditor}\n />\n <div\n className={[\n `${baseClass}__main-wrapper`,\n previewWindowType === 'popup' && `${baseClass}--detached`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <div\n className={[\n `${baseClass}__main`,\n previewWindowType === 'popup' && `${baseClass}__main--popup-open`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <DocumentFields\n AfterFields={AfterFields}\n BeforeFields={\n BeforeFields || (\n <Fragment>\n {auth && (\n <Auth\n className={`${baseClass}__auth`}\n collectionSlug={collectionConfig.slug}\n disableLocalStrategy={collectionConfig.auth?.disableLocalStrategy}\n email={data?.email}\n loginWithUsername={auth?.loginWithUsername}\n operation={operation}\n readOnly={!hasSavePermission}\n requirePassword={!id}\n setValidateBeforeSubmit={setValidateBeforeSubmit}\n useAPIKey={auth.useAPIKey}\n username={data?.username}\n verify={auth.verify}\n />\n )}\n {upload && (\n <React.Fragment>\n <UploadControlsProvider>\n {CustomUpload || (\n <Upload\n collectionSlug={collectionConfig.slug}\n initialState={initialState}\n uploadConfig={upload}\n UploadControls={UploadControls}\n />\n )}\n </UploadControlsProvider>\n </React.Fragment>\n )}\n </Fragment>\n )\n }\n Description={Description}\n docPermissions={docPermissions}\n fields={docConfig.fields}\n forceSidebarWrap={isLivePreviewing}\n isTrashed={isTrashed}\n readOnly={isReadOnlyForIncomingUser || !hasSavePermission || isTrashed}\n schemaPathSegments={schemaPathSegments}\n />\n {AfterDocument}\n </div>\n {isLivePreviewEnabled && !isInDrawer && livePreviewURL && (\n <>\n {CustomLivePreview || (\n <LivePreviewWindow collectionSlug={collectionSlug} globalSlug={globalSlug} />\n )}\n </>\n )}\n </div>\n </Form>\n </OperationProvider>\n </main>\n )\n}\n"],"mappings":"AAA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AI;sBACrCxD,YAAA,EAAcA,YAAA;sBACdmL,YAAA,EAAcvH,MAAA;sBACdlF,cAAA,EAAgBA;;;;;cAShCT,WAAA,EAAaA,WAAA;cACbsB,cAAA,EAAgBA,cAAA;cAChB6L,MAAA,EAAQvH,SAAA,CAAUuH,MAAM;cACxBC,gBAAA,EAAkBzI,gBAAA;cAClBxC,SAAA,EAAWA,SAAA;cACX0K,QAAA,EAAUpG,yBAAA,IAA6B,CAAC5E,iBAAA,IAAqBM,SAAA;cAC7DgF,kBAAA,EAAoBA;gBAErBvG,aAAA;cAEF8D,oBAAA,IAAwB,CAACpB,UAAA,IAAc2B,cAAA,iBACtC8F,IAAA,CAAAsC,SAAA;sBACGlN,iBAAA,iBACC4K,IAAA,CAACzM,iBAAA;cAAkB0C,cAAA,EAAgBA,cAAA;cAAgBW,UAAA,EAAYA;;;;SArLlE,GAAGO,QAAA,EAAU;;;AA8L5B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useModal","useRouter","useSearchParams","formatAdminURL","React","Fragment","useCallback","useEffect","useMemo","useRef","useState","DocumentControls","DocumentDrawerHeader","useDocumentDrawerContext","DocumentFields","DocumentLocked","DocumentTakeOver","LeaveWithoutSaving","LivePreviewWindow","Upload","Form","useAuth","useConfig","useDocumentEvents","useDocumentInfo","useEditDepth","useLivePreviewContext","usePreviewURL","OperationProvider","useRouteCache","useRouteTransition","useServerFunctions","UploadControlsProvider","useUploadEdits","abortAndIgnore","handleAbortRef","handleBackToDashboard","handleGoBack","handleTakeOver","Auth","SetDocumentStepNav","SetDocumentTitle","baseClass","DefaultEditView","BeforeDocumentControls","Description","EditMenuItems","LivePreview","CustomLivePreview","PreviewButton","PublishButton","SaveButton","SaveDraftButton","CustomUpload","UploadControls","id","action","AfterDocument","AfterFields","apiURL","BeforeFields","collectionSlug","currentEditor","data","disableActions","disableCreate","disableLeaveWithoutSaving","docPermissions","documentIsLocked","documentLockState","getDocPermissions","getDocPreferences","globalSlug","hasPublishPermission","hasSavePermission","incrementVersionCount","initialState","isEditing","isInitializing","isLocked","isTrashed","lastUpdateTime","redirectAfterCreate","redirectAfterDelete","redirectAfterDuplicate","redirectAfterRestore","setCurrentEditor","setData","setDocumentIsLocked","setLastUpdateTime","unlockDocument","updateDocumentEditor","clearDoc","drawerSlug","onDelete","onDuplicate","onRestore","onSave","onSaveFromContext","closeModal","isInDrawer","Boolean","refreshCookieAsync","user","config","admin","userSlug","routes","adminRoute","getEntityConfig","collectionConfig","globalConfig","depth","router","params","reportUpdate","resetUploadEdits","getFormState","startRouteTransition","clearRouteCache","isLivePreviewEnabled","isLivePreviewing","previewWindowType","setURL","setLivePreviewURL","typeofLivePreviewURL","url","livePreviewURL","isPreviewEnabled","setPreviewURL","abortOnChangeRef","abortOnSaveRef","locale","get","entitySlug","slug","operation","auth","undefined","upload","docConfig","lockDocumentsProp","lockDocuments","isLockingEnabled","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","autosaveEnabled","versions","drafts","autosave","isReadOnlyForIncomingUser","setIsReadOnlyForIncomingUser","showTakeOverModal","setShowTakeOverModal","editSessionStartTime","setEditSessionStartTime","Date","now","lockExpiryTime","isLockExpired","preventLeaveWithoutSaving","schemaPathSegments","validateBeforeSubmit","setValidateBeforeSubmit","disableLocalStrategy","nextHrefRef","handleDocumentLocking","lockedState","previousOwnerID","current","lockedUserID","hasShownLockedModal","lastEditedAt","getTime","handlePrevent","nextHref","handleLeaveConfirm","lockUser","isLockOwnedByCurrentUser","nextPath","URL","pathname","isInternalView","some","path","includes","err","console","error","json","ctx","context","formState","controller","document","doc","result","updatedAt","toISOString","redirectRoute","push","docPreferences","previewURL","state","renderAllFields","returnLivePreviewURL","returnLockStatus","returnPreviewURL","schemaPath","join","signal","skipValidation","onChange","prevFormState","submitted","currentTime","timeSinceLastUpdate","updateLastEdited","abortOnChange","abortOnSave","shouldShowDocumentLockedModal","isFolderCollection","folders","_jsx","className","filter","_jsxs","disabled","disableValidationOnSubmit","isDocumentForm","method","onSuccess","AfterHeader","showDocumentID","isActive","onReadOnly","onTakeOver","documentLockStateRef","isWithinDoc","onConfirm","onPrevent","pluralLabel","labels","plural","useAsTitle","fallback","toString","customComponents","onDrawerCreateNew","permissions","readOnlyForIncomingUser","email","loginWithUsername","readOnly","requirePassword","useAPIKey","username","verify","uploadConfig","fields","forceSidebarWrap","_Fragment"],"sources":["../../../src/views/Edit/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientUser, DocumentViewClientProps } from 'payload'\n\nimport { useModal } from '@faceless-ui/modal'\nimport { useRouter, useSearchParams } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { FormProps } from '../../forms/Form/index.js'\nimport type { FormOnSuccess } from '../../forms/Form/types.js'\nimport type { LockedState } from '../../utilities/buildFormState.js'\n\nimport { DocumentControls } from '../../elements/DocumentControls/index.js'\nimport { DocumentDrawerHeader } from '../../elements/DocumentDrawer/DrawerHeader/index.js'\nimport { useDocumentDrawerContext } from '../../elements/DocumentDrawer/Provider.js'\nimport { DocumentFields } from '../../elements/DocumentFields/index.js'\nimport { DocumentLocked } from '../../elements/DocumentLocked/index.js'\nimport { DocumentTakeOver } from '../../elements/DocumentTakeOver/index.js'\nimport { LeaveWithoutSaving } from '../../elements/LeaveWithoutSaving/index.js'\nimport { LivePreviewWindow } from '../../elements/LivePreview/Window/index.js'\nimport { Upload } from '../../elements/Upload/index.js'\nimport { Form } from '../../forms/Form/index.js'\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentEvents } from '../../providers/DocumentEvents/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { useLivePreviewContext, usePreviewURL } from '../../providers/LivePreview/context.js'\nimport { OperationProvider } from '../../providers/Operation/index.js'\nimport { useRouteCache } from '../../providers/RouteCache/index.js'\nimport { useRouteTransition } from '../../providers/RouteTransition/index.js'\nimport { useServerFunctions } from '../../providers/ServerFunctions/index.js'\nimport { UploadControlsProvider } from '../../providers/UploadControls/index.js'\nimport { useUploadEdits } from '../../providers/UploadEdits/index.js'\nimport { abortAndIgnore, handleAbortRef } from '../../utilities/abortAndIgnore.js'\nimport { handleBackToDashboard } from '../../utilities/handleBackToDashboard.js'\nimport { handleGoBack } from '../../utilities/handleGoBack.js'\nimport { handleTakeOver } from '../../utilities/handleTakeOver.js'\nimport { Auth } from './Auth/index.js'\nimport { SetDocumentStepNav } from './SetDocumentStepNav/index.js'\nimport './index.scss'\nimport { SetDocumentTitle } from './SetDocumentTitle/index.js'\n\nconst baseClass = 'collection-edit'\n\nexport type OnSaveContext = {\n getDocPermissions?: boolean\n incrementVersionCount?: boolean\n}\n\n// This component receives props only on _pages_\n// When rendered within a drawer, props are empty\n// This is solely to support custom edit views which get server-rendered\nexport function DefaultEditView({\n BeforeDocumentControls,\n Description,\n EditMenuItems,\n LivePreview: CustomLivePreview,\n PreviewButton,\n PublishButton,\n SaveButton,\n SaveDraftButton,\n Upload: CustomUpload,\n UploadControls,\n}: DocumentViewClientProps) {\n const {\n id,\n action,\n AfterDocument,\n AfterFields,\n apiURL,\n BeforeFields,\n collectionSlug,\n currentEditor,\n data,\n disableActions,\n disableCreate,\n disableLeaveWithoutSaving,\n docPermissions,\n documentIsLocked,\n documentLockState,\n getDocPermissions,\n getDocPreferences,\n globalSlug,\n hasPublishPermission,\n hasSavePermission,\n incrementVersionCount,\n initialState,\n isEditing,\n isInitializing,\n isLocked,\n isTrashed,\n lastUpdateTime,\n redirectAfterCreate,\n redirectAfterDelete,\n redirectAfterDuplicate,\n redirectAfterRestore,\n setCurrentEditor,\n setData,\n setDocumentIsLocked,\n setLastUpdateTime,\n unlockDocument,\n updateDocumentEditor,\n } = useDocumentInfo()\n\n const {\n clearDoc,\n drawerSlug,\n onDelete,\n onDuplicate,\n onRestore,\n onSave: onSaveFromContext,\n } = useDocumentDrawerContext()\n const { closeModal } = useModal()\n\n const isInDrawer = Boolean(drawerSlug)\n\n const { refreshCookieAsync, user } = useAuth()\n\n const {\n config,\n config: {\n admin: { user: userSlug },\n routes: { admin: adminRoute },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n const globalConfig = getEntityConfig({ globalSlug })\n\n const depth = useEditDepth()\n\n const router = useRouter()\n const params = useSearchParams()\n const { reportUpdate } = useDocumentEvents()\n const { resetUploadEdits } = useUploadEdits()\n const { getFormState } = useServerFunctions()\n const { startRouteTransition } = useRouteTransition()\n const { clearRouteCache } = useRouteCache()\n const {\n isLivePreviewEnabled,\n isLivePreviewing,\n previewWindowType,\n setURL: setLivePreviewURL,\n typeofLivePreviewURL,\n url: livePreviewURL,\n } = useLivePreviewContext()\n const { isPreviewEnabled, setPreviewURL } = usePreviewURL()\n\n const abortOnChangeRef = useRef<AbortController>(null)\n const abortOnSaveRef = useRef<AbortController>(null)\n\n const locale = params.get('locale')\n\n const entitySlug = collectionConfig?.slug || globalConfig?.slug\n\n const operation = collectionSlug && !id ? 'create' : 'update'\n\n const auth = collectionConfig ? collectionConfig.auth : undefined\n const upload = collectionConfig ? collectionConfig.upload : undefined\n\n const docConfig = collectionConfig || globalConfig\n\n const lockDocumentsProp = docConfig?.lockDocuments !== undefined ? docConfig?.lockDocuments : true\n const isLockingEnabled = lockDocumentsProp !== false\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const autosaveEnabled = Boolean(\n (collectionConfig?.versions?.drafts && collectionConfig?.versions?.drafts?.autosave) ||\n (globalConfig?.versions?.drafts && globalConfig?.versions?.drafts?.autosave),\n )\n\n const [isReadOnlyForIncomingUser, setIsReadOnlyForIncomingUser] = useState(false)\n const [showTakeOverModal, setShowTakeOverModal] = useState(false)\n\n const [editSessionStartTime, setEditSessionStartTime] = useState(Date.now())\n\n const lockExpiryTime = lastUpdateTime + lockDurationInMilliseconds\n const isLockExpired = Date.now() > lockExpiryTime\n\n const preventLeaveWithoutSaving =\n !isReadOnlyForIncomingUser &&\n (typeof disableLeaveWithoutSaving !== 'undefined'\n ? !disableLeaveWithoutSaving\n : !autosaveEnabled)\n\n const schemaPathSegments = useMemo(() => [entitySlug], [entitySlug])\n\n const [validateBeforeSubmit, setValidateBeforeSubmit] = useState(() => {\n if (operation === 'create' && auth && !auth.disableLocalStrategy) {\n return true\n }\n\n return false\n })\n\n const nextHrefRef = React.useRef<null | string>(null)\n\n const handleDocumentLocking = useCallback(\n (lockedState: LockedState) => {\n setDocumentIsLocked(true)\n const previousOwnerID =\n typeof documentLockState.current?.user === 'object'\n ? documentLockState.current?.user?.id\n : documentLockState.current?.user\n\n if (lockedState) {\n const lockedUserID =\n typeof lockedState.user === 'string' || typeof lockedState.user === 'number'\n ? lockedState.user\n : lockedState.user.id\n\n if (!documentLockState.current || lockedUserID !== previousOwnerID) {\n if (previousOwnerID === user.id && lockedUserID !== user.id) {\n setShowTakeOverModal(true)\n documentLockState.current.hasShownLockedModal = true\n }\n\n documentLockState.current = {\n hasShownLockedModal: documentLockState.current?.hasShownLockedModal || false,\n isLocked: true,\n user: lockedState.user as ClientUser,\n }\n setCurrentEditor(lockedState.user as ClientUser)\n }\n\n // Update lastUpdateTime when lock state changes\n if (lockedState.lastEditedAt) {\n setLastUpdateTime(new Date(lockedState.lastEditedAt).getTime())\n }\n }\n },\n [documentLockState, setCurrentEditor, setDocumentIsLocked, setLastUpdateTime, user?.id],\n )\n\n const handlePrevent = useCallback((nextHref: null | string) => {\n nextHrefRef.current = nextHref\n }, [])\n\n const handleLeaveConfirm = useCallback(async () => {\n const lockUser = documentLockState.current?.user\n\n const isLockOwnedByCurrentUser =\n typeof lockUser === 'object' ? lockUser?.id === user?.id : lockUser === user?.id\n\n if (isLockingEnabled && documentIsLocked && (id || globalSlug)) {\n // Check where user is trying to go\n const nextPath = nextHrefRef.current ? new URL(nextHrefRef.current).pathname : ''\n const isInternalView = ['/preview', '/api', '/versions'].some((path) =>\n nextPath.includes(path),\n )\n\n // Remove the lock if the user is navigating away from the document view they have locked\n if (isLockOwnedByCurrentUser && !isInternalView) {\n try {\n await unlockDocument(id, collectionSlug ?? globalSlug)\n setDocumentIsLocked(false)\n setCurrentEditor(null)\n } catch (err) {\n console.error('Failed to unlock before leave', err) // eslint-disable-line no-console\n }\n }\n }\n }, [\n collectionSlug,\n documentIsLocked,\n documentLockState,\n globalSlug,\n id,\n isLockingEnabled,\n setCurrentEditor,\n setDocumentIsLocked,\n unlockDocument,\n user?.id,\n ])\n\n const onSave: FormOnSuccess<any, OnSaveContext> = useCallback(\n async (json, ctx) => {\n const { context, formState } = ctx || {}\n\n const controller = handleAbortRef(abortOnSaveRef)\n\n const document = json?.doc || json?.result\n\n const updatedAt = document?.updatedAt || new Date().toISOString()\n\n // If we're editing the doc of the logged-in user,\n // Refresh the cookie to get new permissions\n if (user && collectionSlug === userSlug && id === user.id) {\n void refreshCookieAsync()\n }\n\n setLastUpdateTime(updatedAt)\n\n if (context?.incrementVersionCount !== false) {\n incrementVersionCount()\n }\n\n if (typeof setData === 'function') {\n void setData(document || {})\n }\n\n if (typeof onSaveFromContext === 'function') {\n const operation = id ? 'update' : 'create'\n\n void onSaveFromContext({\n ...(json as Record<string, unknown>),\n context,\n operation,\n // @ts-expect-error todo: this is not right, should be under `doc`?\n updatedAt:\n operation === 'update'\n ? new Date().toISOString()\n : document?.updatedAt || new Date().toISOString(),\n })\n }\n\n if (!isEditing && depth < 2 && redirectAfterCreate !== false) {\n // Redirect to the same locale if it's been set\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionSlug}/${document?.id}${locale ? `?locale=${locale}` : ''}`,\n })\n\n startRouteTransition(() => router.push(redirectRoute))\n } else {\n resetUploadEdits()\n }\n\n if (context?.getDocPermissions !== false) {\n await getDocPermissions(json)\n }\n\n if (id || globalSlug) {\n const docPreferences = await getDocPreferences()\n\n const { livePreviewURL, previewURL, state } = await getFormState({\n id,\n collectionSlug,\n data: document,\n docPermissions,\n docPreferences,\n formState,\n globalSlug,\n operation,\n renderAllFields: false,\n returnLivePreviewURL: isLivePreviewEnabled && typeofLivePreviewURL === 'function',\n returnLockStatus: false,\n returnPreviewURL: isPreviewEnabled,\n schemaPath: schemaPathSegments.join('.'),\n signal: controller.signal,\n skipValidation: true,\n })\n\n // Unlock the document after save\n if (isLockingEnabled) {\n setDocumentIsLocked(false)\n }\n\n if (isLivePreviewEnabled && typeofLivePreviewURL === 'function') {\n setLivePreviewURL(livePreviewURL)\n }\n\n if (isPreviewEnabled) {\n setPreviewURL(previewURL)\n }\n\n reportUpdate({\n id,\n entitySlug,\n updatedAt,\n })\n\n abortOnSaveRef.current = null\n\n return state\n }\n },\n [\n reportUpdate,\n id,\n entitySlug,\n user,\n collectionSlug,\n userSlug,\n setLastUpdateTime,\n setData,\n onSaveFromContext,\n isEditing,\n depth,\n redirectAfterCreate,\n setLivePreviewURL,\n setPreviewURL,\n globalSlug,\n refreshCookieAsync,\n incrementVersionCount,\n adminRoute,\n locale,\n startRouteTransition,\n router,\n resetUploadEdits,\n getDocPermissions,\n getDocPreferences,\n getFormState,\n docPermissions,\n operation,\n isLivePreviewEnabled,\n isPreviewEnabled,\n typeofLivePreviewURL,\n schemaPathSegments,\n isLockingEnabled,\n setDocumentIsLocked,\n ],\n )\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState, submitted }) => {\n const controller = handleAbortRef(abortOnChangeRef)\n\n const currentTime = Date.now()\n const timeSinceLastUpdate = currentTime - editSessionStartTime\n\n const updateLastEdited = isLockingEnabled && timeSinceLastUpdate >= 10000 // 10 seconds\n\n if (updateLastEdited) {\n setEditSessionStartTime(currentTime)\n }\n\n const docPreferences = await getDocPreferences()\n\n const result = await getFormState({\n id,\n collectionSlug,\n docPermissions,\n docPreferences,\n formState: prevFormState,\n globalSlug,\n operation,\n renderAllFields: false,\n returnLockStatus: isLockingEnabled,\n schemaPath: schemaPathSegments.join('.'),\n signal: controller.signal,\n skipValidation: !submitted,\n updateLastEdited,\n })\n\n if (!result) {\n return\n }\n\n const { lockedState, state } = result\n\n if (isLockingEnabled) {\n handleDocumentLocking(lockedState)\n }\n\n abortOnChangeRef.current = null\n\n return state\n },\n [\n editSessionStartTime,\n isLockingEnabled,\n getDocPreferences,\n getFormState,\n id,\n collectionSlug,\n docPermissions,\n globalSlug,\n operation,\n schemaPathSegments,\n handleDocumentLocking,\n ],\n )\n\n // Clean up when the component unmounts or when the document is unlocked\n useEffect(() => {\n return () => {\n setShowTakeOverModal(false)\n }\n }, [])\n\n useEffect(() => {\n const abortOnChange = abortOnChangeRef.current\n const abortOnSave = abortOnSaveRef.current\n\n return () => {\n abortAndIgnore(abortOnChange)\n abortAndIgnore(abortOnSave)\n }\n }, [])\n\n const shouldShowDocumentLockedModal =\n documentIsLocked &&\n currentEditor &&\n (typeof currentEditor === 'object'\n ? currentEditor.id !== user?.id\n : currentEditor !== user?.id) &&\n !isReadOnlyForIncomingUser &&\n !showTakeOverModal &&\n !documentLockState.current?.hasShownLockedModal &&\n !isLockExpired\n\n const isFolderCollection = config.folders && collectionSlug === config.folders?.slug\n\n return (\n <main\n className={[\n baseClass,\n (id || globalSlug) && `${baseClass}--is-editing`,\n globalSlug && `global-edit--${globalSlug}`,\n collectionSlug && `collection-edit--${collectionSlug}`,\n isLivePreviewing && previewWindowType === 'iframe' && `${baseClass}--is-live-previewing`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <OperationProvider operation={operation}>\n <Form\n action={action}\n className={`${baseClass}__form`}\n disabled={isReadOnlyForIncomingUser || isInitializing || !hasSavePermission || isTrashed}\n disableValidationOnSubmit={!validateBeforeSubmit}\n initialState={!isInitializing && initialState}\n isDocumentForm={true}\n isInitializing={isInitializing}\n key={`${isLocked}`}\n method={id ? 'PATCH' : 'POST'}\n onChange={[onChange]}\n onSuccess={onSave}\n >\n {isInDrawer && (\n <DocumentDrawerHeader\n AfterHeader={Description}\n drawerSlug={drawerSlug}\n showDocumentID={!isFolderCollection}\n />\n )}\n {isLockingEnabled && shouldShowDocumentLockedModal && (\n <DocumentLocked\n handleGoBack={() => handleGoBack({ adminRoute, collectionSlug, router })}\n isActive={shouldShowDocumentLockedModal}\n onReadOnly={() => {\n setIsReadOnlyForIncomingUser(true)\n setShowTakeOverModal(false)\n }}\n onTakeOver={() =>\n handleTakeOver({\n id,\n clearRouteCache,\n collectionSlug,\n documentLockStateRef: documentLockState,\n globalSlug,\n isLockingEnabled,\n isWithinDoc: false,\n setCurrentEditor,\n updateDocumentEditor,\n user,\n })\n }\n updatedAt={lastUpdateTime}\n user={currentEditor}\n />\n )}\n {isLockingEnabled && showTakeOverModal && (\n <DocumentTakeOver\n handleBackToDashboard={() => handleBackToDashboard({ adminRoute, router })}\n isActive={showTakeOverModal}\n onReadOnly={() => {\n setIsReadOnlyForIncomingUser(true)\n setShowTakeOverModal(false)\n }}\n />\n )}\n {preventLeaveWithoutSaving && (\n <LeaveWithoutSaving onConfirm={handleLeaveConfirm} onPrevent={handlePrevent} />\n )}\n {!isInDrawer && (\n <SetDocumentStepNav\n collectionSlug={collectionConfig?.slug}\n globalSlug={globalConfig?.slug}\n id={id}\n isTrashed={isTrashed}\n pluralLabel={collectionConfig?.labels?.plural}\n useAsTitle={collectionConfig?.admin?.useAsTitle}\n />\n )}\n <SetDocumentTitle\n collectionConfig={collectionConfig}\n config={config}\n fallback={depth <= 1 ? id?.toString() : undefined}\n globalConfig={globalConfig}\n />\n <DocumentControls\n apiURL={apiURL}\n BeforeDocumentControls={BeforeDocumentControls}\n customComponents={{\n PreviewButton,\n PublishButton,\n SaveButton,\n SaveDraftButton,\n }}\n data={data}\n disableActions={disableActions || isFolderCollection || isTrashed}\n disableCreate={disableCreate}\n EditMenuItems={EditMenuItems}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n id={id}\n isEditing={isEditing}\n isInDrawer={isInDrawer}\n isTrashed={isTrashed}\n onDelete={onDelete}\n onDrawerCreateNew={clearDoc}\n onDuplicate={onDuplicate}\n onRestore={onRestore}\n onSave={onSave}\n onTakeOver={() =>\n handleTakeOver({\n id,\n clearRouteCache,\n collectionSlug,\n documentLockStateRef: documentLockState,\n globalSlug,\n isLockingEnabled,\n isWithinDoc: true,\n setCurrentEditor,\n setIsReadOnlyForIncomingUser,\n updateDocumentEditor,\n user,\n })\n }\n permissions={docPermissions}\n readOnlyForIncomingUser={isReadOnlyForIncomingUser}\n redirectAfterDelete={redirectAfterDelete}\n redirectAfterDuplicate={redirectAfterDuplicate}\n redirectAfterRestore={redirectAfterRestore}\n slug={collectionConfig?.slug || globalConfig?.slug}\n user={currentEditor}\n />\n <div\n className={[\n `${baseClass}__main-wrapper`,\n previewWindowType === 'popup' && `${baseClass}--detached`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <div\n className={[\n `${baseClass}__main`,\n previewWindowType === 'popup' && `${baseClass}__main--popup-open`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <DocumentFields\n AfterFields={AfterFields}\n BeforeFields={\n BeforeFields || (\n <Fragment>\n {auth && (\n <Auth\n className={`${baseClass}__auth`}\n collectionSlug={collectionConfig.slug}\n disableLocalStrategy={collectionConfig.auth?.disableLocalStrategy}\n email={data?.email}\n loginWithUsername={auth?.loginWithUsername}\n operation={operation}\n readOnly={!hasSavePermission}\n requirePassword={!id}\n setValidateBeforeSubmit={setValidateBeforeSubmit}\n // eslint-disable-next-line react-compiler/react-compiler\n useAPIKey={auth.useAPIKey}\n username={data?.username}\n verify={auth.verify}\n />\n )}\n {upload && (\n <React.Fragment>\n <UploadControlsProvider>\n {CustomUpload || (\n <Upload\n collectionSlug={collectionConfig.slug}\n initialState={initialState}\n uploadConfig={upload}\n UploadControls={UploadControls}\n />\n )}\n </UploadControlsProvider>\n </React.Fragment>\n )}\n </Fragment>\n )\n }\n Description={Description}\n docPermissions={docPermissions}\n fields={docConfig.fields}\n forceSidebarWrap={isLivePreviewing}\n isTrashed={isTrashed}\n readOnly={isReadOnlyForIncomingUser || !hasSavePermission || isTrashed}\n schemaPathSegments={schemaPathSegments}\n />\n {AfterDocument}\n </div>\n {isLivePreviewEnabled && !isInDrawer && livePreviewURL && (\n <>\n {CustomLivePreview || (\n <LivePreviewWindow collectionSlug={collectionSlug} globalSlug={globalSlug} />\n )}\n </>\n )}\n </div>\n </Form>\n </OperationProvider>\n </main>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,QAAQ,QAAQ;AACzB,SAASC,SAAS,EAAEC,eAAe,QAAQ;AAC3C,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAMnF,SAASC,gBAAgB,QAAQ;AACjC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,MAAM,QAAQ;AACvB,SAASC,IAAI,QAAQ;AACrB,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAC7B,SAASC,qBAAqB,EAAEC,aAAa,QAAQ;AACrD,SAASC,iBAAiB,QAAQ;AAClC,SAASC,aAAa,QAAQ;AAC9B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,EAAEC,cAAc,QAAQ;AAC/C,SAASC,qBAAqB,Q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|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.61.
|
|
3
|
+
"version": "3.61.1",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"ts-essentials": "10.0.3",
|
|
137
137
|
"use-context-selector": "2.0.0",
|
|
138
138
|
"uuid": "10.0.0",
|
|
139
|
-
"@payloadcms/translations": "3.61.
|
|
139
|
+
"@payloadcms/translations": "3.61.1"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"@babel/cli": "7.27.2",
|
|
@@ -151,14 +151,14 @@
|
|
|
151
151
|
"babel-plugin-react-compiler": "19.1.0-rc.3",
|
|
152
152
|
"esbuild": "0.25.5",
|
|
153
153
|
"esbuild-sass-plugin": "3.3.1",
|
|
154
|
-
"payload": "3.61.
|
|
154
|
+
"payload": "3.61.1",
|
|
155
155
|
"@payloadcms/eslint-config": "3.28.0"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"next": "^15.2.3",
|
|
159
159
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
160
160
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
161
|
-
"payload": "3.61.
|
|
161
|
+
"payload": "3.61.1"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePreviewURL.d.ts","sourceRoot":"","sources":["../../../src/elements/PreviewButton/usePreviewURL.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,aAAa,QAAO;IAC/B,kBAAkB,EAAE,CAAC,EAAE,iBAAiB,EAAE,EAAE;QAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;IACpF,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CAqFnB,CAAA"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as qs from 'qs-esm';
|
|
4
|
-
import { useCallback, useRef, useState } from 'react';
|
|
5
|
-
import { toast } from 'sonner';
|
|
6
|
-
import { useConfig } from '../../providers/Config/index.js';
|
|
7
|
-
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
|
|
8
|
-
import { useLocale } from '../../providers/Locale/index.js';
|
|
9
|
-
import { useTranslation } from '../../providers/Translation/index.js';
|
|
10
|
-
export const usePreviewURL = () => {
|
|
11
|
-
const {
|
|
12
|
-
id,
|
|
13
|
-
collectionSlug,
|
|
14
|
-
globalSlug,
|
|
15
|
-
versionCount
|
|
16
|
-
} = useDocumentInfo();
|
|
17
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
18
|
-
const [previewURL, setPreviewURL] = useState('');
|
|
19
|
-
const {
|
|
20
|
-
code: locale
|
|
21
|
-
} = useLocale();
|
|
22
|
-
const hasVersions = versionCount > 0;
|
|
23
|
-
const {
|
|
24
|
-
config: {
|
|
25
|
-
routes: {
|
|
26
|
-
api
|
|
27
|
-
},
|
|
28
|
-
serverURL
|
|
29
|
-
}
|
|
30
|
-
} = useConfig();
|
|
31
|
-
const {
|
|
32
|
-
t
|
|
33
|
-
} = useTranslation();
|
|
34
|
-
const isGeneratingPreviewURL = useRef(false);
|
|
35
|
-
// we need to regenerate the preview URL every time the button is clicked
|
|
36
|
-
// to do this we need to fetch the document data fresh from the API
|
|
37
|
-
// this will ensure the latest data is used when generating the preview URL
|
|
38
|
-
const generatePreviewURL = useCallback(async ({
|
|
39
|
-
openPreviewWindow = false
|
|
40
|
-
}) => {
|
|
41
|
-
if (isGeneratingPreviewURL.current) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
isGeneratingPreviewURL.current = true;
|
|
45
|
-
try {
|
|
46
|
-
setIsLoading(true);
|
|
47
|
-
let url = `${serverURL}${api}`;
|
|
48
|
-
if (collectionSlug) {
|
|
49
|
-
url = `${url}/${collectionSlug}/${id}/preview`;
|
|
50
|
-
}
|
|
51
|
-
if (globalSlug) {
|
|
52
|
-
url = `${url}/globals/${globalSlug}/preview`;
|
|
53
|
-
}
|
|
54
|
-
const params = {
|
|
55
|
-
draft: hasVersions ? 'true' : 'false',
|
|
56
|
-
locale: locale || undefined
|
|
57
|
-
};
|
|
58
|
-
const res = await fetch(`${url}?${qs.stringify(params)}`);
|
|
59
|
-
if (!res.ok) {
|
|
60
|
-
throw new Error();
|
|
61
|
-
}
|
|
62
|
-
const newPreviewURL = await res.json();
|
|
63
|
-
if (!newPreviewURL) {
|
|
64
|
-
throw new Error();
|
|
65
|
-
}
|
|
66
|
-
setPreviewURL(newPreviewURL);
|
|
67
|
-
setIsLoading(false);
|
|
68
|
-
isGeneratingPreviewURL.current = false;
|
|
69
|
-
if (openPreviewWindow) {
|
|
70
|
-
window.open(newPreviewURL, '_blank');
|
|
71
|
-
}
|
|
72
|
-
} catch (_err) {
|
|
73
|
-
setIsLoading(false);
|
|
74
|
-
isGeneratingPreviewURL.current = false;
|
|
75
|
-
toast.error(t('error:previewing'));
|
|
76
|
-
}
|
|
77
|
-
}, [serverURL, api, collectionSlug, globalSlug, hasVersions, locale, id, t]);
|
|
78
|
-
return {
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
80
|
-
generatePreviewURL,
|
|
81
|
-
isLoading,
|
|
82
|
-
label: isLoading ? t('general:loading') : t('version:preview'),
|
|
83
|
-
previewURL
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=usePreviewURL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePreviewURL.js","names":["qs","useCallback","useRef","useState","toast","useConfig","useDocumentInfo","useLocale","useTranslation","usePreviewURL","id","collectionSlug","globalSlug","versionCount","isLoading","setIsLoading","previewURL","setPreviewURL","code","locale","hasVersions","config","routes","api","serverURL","t","isGeneratingPreviewURL","generatePreviewURL","openPreviewWindow","current","url","params","draft","undefined","res","fetch","stringify","ok","Error","newPreviewURL","json","window","open","_err","error","label"],"sources":["../../../src/elements/PreviewButton/usePreviewURL.tsx"],"sourcesContent":["'use client'\nimport * as qs from 'qs-esm'\nimport { useCallback, useRef, useState } from 'react'\nimport { toast } from 'sonner'\n\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\n\nexport const usePreviewURL = (): {\n generatePreviewURL: ({ openPreviewWindow }: { openPreviewWindow?: boolean }) => void\n isLoading: boolean\n label: string\n previewURL: string\n} => {\n const { id, collectionSlug, globalSlug, versionCount } = useDocumentInfo()\n\n const [isLoading, setIsLoading] = useState(false)\n const [previewURL, setPreviewURL] = useState('')\n const { code: locale } = useLocale()\n\n const hasVersions = versionCount > 0\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const { t } = useTranslation()\n\n const isGeneratingPreviewURL = useRef(false)\n\n // we need to regenerate the preview URL every time the button is clicked\n // to do this we need to fetch the document data fresh from the API\n // this will ensure the latest data is used when generating the preview URL\n const generatePreviewURL = useCallback(\n async ({ openPreviewWindow = false }) => {\n if (isGeneratingPreviewURL.current) {\n return\n }\n\n isGeneratingPreviewURL.current = true\n\n try {\n setIsLoading(true)\n\n let url = `${serverURL}${api}`\n\n if (collectionSlug) {\n url = `${url}/${collectionSlug}/${id}/preview`\n }\n\n if (globalSlug) {\n url = `${url}/globals/${globalSlug}/preview`\n }\n\n const params = {\n draft: hasVersions ? 'true' : 'false',\n locale: locale || undefined,\n }\n\n const res = await fetch(`${url}?${qs.stringify(params)}`)\n\n if (!res.ok) {\n throw new Error()\n }\n\n const newPreviewURL = await res.json()\n\n if (!newPreviewURL) {\n throw new Error()\n }\n\n setPreviewURL(newPreviewURL)\n setIsLoading(false)\n isGeneratingPreviewURL.current = false\n\n if (openPreviewWindow) {\n window.open(newPreviewURL, '_blank')\n }\n } catch (_err) {\n setIsLoading(false)\n isGeneratingPreviewURL.current = false\n toast.error(t('error:previewing'))\n }\n },\n [serverURL, api, collectionSlug, globalSlug, hasVersions, locale, id, t],\n )\n\n return {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n generatePreviewURL,\n isLoading,\n label: isLoading ? t('general:loading') : t('version:preview'),\n previewURL,\n }\n}\n"],"mappings":"AAAA;;AACA,YAAYA,EAAA,MAAQ;AACpB,SAASC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAC9C,SAASC,KAAK,QAAQ;AAEtB,SAASC,SAAS,QAAQ;AAC1B,SAASC,eAAe,QAAQ;AAChC,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,aAAA,GAAgBA,CAAA;EAM3B,MAAM;IAAEC,EAAE;IAAEC,cAAc;IAAEC,UAAU;IAAEC;EAAY,CAAE,GAAGP,eAAA;EAEzD,MAAM,CAACQ,SAAA,EAAWC,YAAA,CAAa,GAAGZ,QAAA,CAAS;EAC3C,MAAM,CAACa,UAAA,EAAYC,aAAA,CAAc,GAAGd,QAAA,CAAS;EAC7C,MAAM;IAAEe,IAAA,EAAMC;EAAM,CAAE,GAAGZ,SAAA;EAEzB,MAAMa,WAAA,GAAcP,YAAA,GAAe;EAEnC,MAAM;IACJQ,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC;MAAG,CAAE;MACfC;IAAS;EACV,CACF,GAAGnB,SAAA;EAEJ,MAAM;IAAEoB;EAAC,CAAE,GAAGjB,cAAA;EAEd,MAAMkB,sBAAA,GAAyBxB,MAAA,CAAO;EAEtC;EACA;EACA;EACA,MAAMyB,kBAAA,GAAqB1B,WAAA,CACzB,OAAO;IAAE2B,iBAAA,GAAoB;E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