@payloadcms/next 3.74.0-canary.6 → 3.74.0-internal.03ca72a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/login.d.ts +9 -12
- package/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.d.ts +2 -2
- package/dist/auth/logout.d.ts.map +1 -1
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js.map +1 -1
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +7 -5
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/initReq.d.ts +2 -13
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
- package/dist/views/Document/renderDocumentSlots.js +8 -0
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/Version/VersionPillLabel/VersionPillLabel.d.ts.map +1 -1
- package/dist/views/Version/VersionPillLabel/VersionPillLabel.js +22 -17
- package/dist/views/Version/VersionPillLabel/VersionPillLabel.js.map +1 -1
- package/dist/views/Version/VersionPillLabel/getVersionLabel.d.ts +3 -2
- package/dist/views/Version/VersionPillLabel/getVersionLabel.d.ts.map +1 -1
- package/dist/views/Version/VersionPillLabel/getVersionLabel.js +2 -6
- package/dist/views/Version/VersionPillLabel/getVersionLabel.js.map +1 -1
- package/dist/views/Version/index.d.ts.map +1 -1
- package/dist/views/Version/index.js +3 -0
- package/dist/views/Version/index.js.map +1 -1
- package/package.json +6 -6
package/dist/auth/login.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type LoginWithEmail = {
|
|
3
|
-
collection:
|
|
4
|
-
config:
|
|
1
|
+
import type { AuthCollectionSlug, LoginResult, MaybePromise, SanitizedConfig } from 'payload';
|
|
2
|
+
type LoginWithEmail<TSlug extends AuthCollectionSlug> = {
|
|
3
|
+
collection: TSlug;
|
|
4
|
+
config: MaybePromise<SanitizedConfig>;
|
|
5
5
|
email: string;
|
|
6
6
|
password: string;
|
|
7
7
|
username?: never;
|
|
8
8
|
};
|
|
9
|
-
type LoginWithUsername = {
|
|
10
|
-
collection:
|
|
11
|
-
config:
|
|
9
|
+
type LoginWithUsername<TSlug extends AuthCollectionSlug> = {
|
|
10
|
+
collection: TSlug;
|
|
11
|
+
config: MaybePromise<SanitizedConfig>;
|
|
12
12
|
email?: never;
|
|
13
13
|
password: string;
|
|
14
14
|
username: string;
|
|
15
15
|
};
|
|
16
|
-
type LoginArgs = LoginWithEmail | LoginWithUsername
|
|
17
|
-
export declare function login({ collection, config, email, password, username }: LoginArgs): Promise<
|
|
18
|
-
token?: string;
|
|
19
|
-
user: any;
|
|
20
|
-
}>;
|
|
16
|
+
type LoginArgs<TSlug extends AuthCollectionSlug> = LoginWithEmail<TSlug> | LoginWithUsername<TSlug>;
|
|
17
|
+
export declare function login<TSlug extends AuthCollectionSlug>({ collection, config, email, password, username, }: LoginArgs<TSlug>): Promise<LoginResult<TSlug>>;
|
|
21
18
|
export {};
|
|
22
19
|
//# sourceMappingURL=login.d.ts.map
|
package/dist/auth/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM7F,KAAK,cAAc,CAAC,KAAK,SAAS,kBAAkB,IAAI;IACtD,UAAU,EAAE,KAAK,CAAA;IACjB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB,CAAA;AAED,KAAK,iBAAiB,CAAC,KAAK,SAAS,kBAAkB,IAAI;IACzD,UAAU,EAAE,KAAK,CAAA;IACjB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AACD,KAAK,SAAS,CAAC,KAAK,SAAS,kBAAkB,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAEnG,wBAAsB,KAAK,CAAC,KAAK,SAAS,kBAAkB,EAAE,EAC5D,UAAU,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAqDhD"}
|
package/dist/auth/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { AuthCollectionSlug, LoginResult, MaybePromise, SanitizedConfig } from 'payload'\n\nimport { getPayload } from 'payload'\n\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\ntype LoginWithEmail<TSlug extends AuthCollectionSlug> = {\n collection: TSlug\n config: MaybePromise<SanitizedConfig>\n email: string\n password: string\n username?: never\n}\n\ntype LoginWithUsername<TSlug extends AuthCollectionSlug> = {\n collection: TSlug\n config: MaybePromise<SanitizedConfig>\n email?: never\n password: string\n username: string\n}\ntype LoginArgs<TSlug extends AuthCollectionSlug> = LoginWithEmail<TSlug> | LoginWithUsername<TSlug>\n\nexport async function login<TSlug extends AuthCollectionSlug>({\n collection,\n config,\n email,\n password,\n username,\n}: LoginArgs<TSlug>): Promise<LoginResult<TSlug>> {\n const payload = await getPayload({ config, cron: true })\n\n const authConfig = payload.collections[collection]?.config.auth\n\n if (!authConfig) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const loginWithUsername = authConfig?.loginWithUsername ?? false\n\n if (loginWithUsername) {\n if (loginWithUsername.allowEmailLogin) {\n if (!email && !username) {\n throw new Error('Email or username is required.')\n }\n } else {\n if (!username) {\n throw new Error('Username is required.')\n }\n }\n } else {\n if (!email) {\n throw new Error('Email is required.')\n }\n }\n\n let loginData\n\n if (loginWithUsername) {\n loginData = username ? { password, username } : { email, password }\n } else {\n loginData = { email, password }\n }\n\n const result = await payload.login({\n collection,\n data: loginData,\n })\n\n if (result.token) {\n await setPayloadAuthCookie({\n authConfig,\n cookiePrefix: payload.config.cookiePrefix,\n token: result.token,\n })\n }\n\n if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n"],"mappings":"AAAA;;AAIA,SAASA,UAAU,QAAQ;AAE3B,SAASC,oBAAoB,QAAQ;AAmBrC,OAAO,eAAeC,MAAwC;EAC5DC,UAAU;EACVC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC;AAAQ,CACS;EACjB,MAAMC,OAAA,GAAU,MAAMR,UAAA,CAAW;IAAEI,MAAA;IAAQK,IAAA,EAAM;EAAK;EAEtD,MAAMC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itizedConfig } from 'payload';
|
|
1
|
+
import type { MaybePromise, SanitizedConfig } from 'payload';
|
|
2
2
|
export declare function logout({ allSessions, config, }: {
|
|
3
3
|
allSessions?: boolean;
|
|
4
|
-
config:
|
|
4
|
+
config: MaybePromise<SanitizedConfig>;
|
|
5
5
|
}): Promise<{
|
|
6
6
|
message: string;
|
|
7
7
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO5D,wBAAsB,MAAM,CAAC,EAC3B,WAAmB,EACnB,MAAM,GACP,EAAE;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;CACtC;;;GA8BA"}
|
package/dist/auth/logout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config:
|
|
1
|
+
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { MaybePromise, SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config: MaybePromise<SanitizedConfig>\n}) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (existingCookie) {\n const cookies = await getCookies()\n cookies.delete(existingCookie.name)\n }\n\n return { message: 'User logged out successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,UAAU,EAAEC,OAAA,IAAWC,WAAW,QAAQ;AAC9D,SAASC,cAAc,EAAEC,UAAU,EAAEC,eAAe,QAAQ;AAE5D,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,OAAO;EAC3BC,WAAA,GAAc,KAAK;EACnBC;AAAM,CAIP;EACC,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,UAAA,GAAa,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAEhD,IAAI,CAACW,UAAA,CAAWE,IAAI,EAAE;IACpB,OAAO;MAAEC,OAAA,EAAS;MAA2BC,OAAA,EAAS;IAAK;EAC7D;EAEA,MAAM;IAAEF;EAAI,CAAE,GAAGF,UAAA;EACjB,MAAMK,GAAA,GAAM,MAAMd,cAAA,CAAe;IAAEW;EAAK,GAAGJ,OAAA;EAC3C,MAAMQ,UAAA,GAAaR,OAAA,CAAQS,WAAW,CAACL,IAAA,CAAKI,UAAU,CAAC;EAEvD,MAAME,YAAA,GAAe,MAAMf,eAAA,CAAgB;IACzCG,WAAA;IACAU,UAAA;IACAD;EACF;EAEA,IAAI,CAACG,YAAA,EAAc;IACjB,OAAO;MAAEL,OAAA,EAAS;MAAiBC,OAAA,EAAS;IAAM;EACpD;EAEA,MAAMK,cAAA,GAAiB,MAAMf,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACa,YAAY;EAC7E,IAAID,cAAA,EAAgB;IAClB,MAAMtB,OAAA,GAAU,MAAMC,UAAA;IACtBD,OAAA,CAAQwB,MAAM,CAACF,cAAA,CAAeG,IAAI;EACpC;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
|
package/dist/auth/refresh.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAQ5E,wBAAsB,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;CAAE;;;GAuClF"}
|
package/dist/auth/refresh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config:
|
|
1
|
+
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug, MaybePromise, SanitizedConfig } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config: MaybePromise<SanitizedConfig> }) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n await setPayloadAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n token: refreshResult.refreshedToken,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,WAAW,QAAQ;AACvC,SAASC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ;AAE7D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,QAAQ;EAAEC;AAAM,CAA6C;EACjF,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,MAAA,GAAS,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAE5C,IAAI,CAACW,MAAA,CAAOE,IAAI,EAAE;IAChB,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAMC,cAAA,GAAiB,MAAMV,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACQ,YAAY;EAC7E,IAAI,CAACD,cAAA,EAAgB;IACnB,OAAO;MAAEE,OAAA,EAAS;MAAmCC,OAAA,EAAS;IAAM;EACtE;EAEA,MAAMC,UAAA,GAAyCR,MAAA,CAAOE,IAAI,CAACM,UAAU;EACrE,MAAMC,gBAAA,GAAmBX,OAAA,CAAQY,WAAW,CAACF,UAAA,CAAW;EAExD,IAAI,CAACC,gBAAA,EAAkBZ,MAAA,CAAOI,IAAA,EAAM;IAClC,MAAM,IAAIE,KAAA,CAAM,wCAAwCK,UAAA,EAAY;EACtE;EAEA,MAAMG,GAAA,GAAM,MAAMpB,cAAA,CAAe;IAAEW,IAAA,EAAMF,MAAA,CAAOE;EAAK,GAAGJ,OAAA;EAExD,MAAMc,aAAA,GAAgB,MAAMnB,gBAAA,CAAiB;IAC3Ce,UAAA,EAAYC,gBAAA;IACZE;EACF;EAEA,IAAI,CAACC,aAAA,EAAe;IAClB,OAAO;MAAEN,OAAA,EAAS;MAAwBC,OAAA,EAAS;IAAM;EAC3D;EAEA,MAAMZ,oBAAA,CAAqB;IACzBkB,UAAA,EAAYJ,gBAAA,CAAiBZ,MAAM,CAACI,IAAI;IACxCI,YAAA,EAAcP,OAAA,CAAQD,MAAM,CAACQ,YAAY;IACzCS,KAAA,EAAOF,aAAA,CAAcG;EACvB;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.d.ts","sourceRoot":"","sources":["../../src/utilities/handleServerFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,qBAAqB,EAAE,MAAM,SAAS,CAAA;AA+B/F,eAAO,MAAM,qBAAqB,EAAE,qBA+BnC,CAAA"}
|
|
@@ -33,6 +33,9 @@ export const handleServerFunctions = async args => {
|
|
|
33
33
|
serverFunctions: extraServerFunctions
|
|
34
34
|
} = args;
|
|
35
35
|
const {
|
|
36
|
+
cookies,
|
|
37
|
+
locale,
|
|
38
|
+
permissions,
|
|
36
39
|
req
|
|
37
40
|
} = await initReq({
|
|
38
41
|
configPromise,
|
|
@@ -41,14 +44,13 @@ export const handleServerFunctions = async args => {
|
|
|
41
44
|
});
|
|
42
45
|
const augmentedArgs = {
|
|
43
46
|
...fnArgs,
|
|
47
|
+
cookies,
|
|
44
48
|
importMap,
|
|
49
|
+
locale,
|
|
50
|
+
permissions,
|
|
45
51
|
req
|
|
46
52
|
};
|
|
47
|
-
const
|
|
48
|
-
...baseServerFunctions,
|
|
49
|
-
...(extraServerFunctions || {})
|
|
50
|
-
};
|
|
51
|
-
const fn = serverFunctions[fnKey];
|
|
53
|
+
const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey];
|
|
52
54
|
if (!fn) {
|
|
53
55
|
throw new Error(`Unknown Server Function: ${fnKey}`);
|
|
54
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleServerFunctions.js","names":["_internal_renderFieldHandler","copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","slugifyHandler","baseServerFunctions","slugify","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","req","key","augmentedArgs","fn","Error"],"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { _internal_renderFieldHandler, copyDataFromLocaleHandler } from '@payloadcms/ui/rsc'\nimport { buildFormStateHandler } from '@payloadcms/ui/utilities/buildFormState'\nimport { buildTableStateHandler } from '@payloadcms/ui/utilities/buildTableState'\nimport { getFolderResultsComponentAndDataHandler } from '@payloadcms/ui/utilities/getFolderResultsComponentAndData'\nimport { schedulePublishHandler } from '@payloadcms/ui/utilities/schedulePublishHandler'\n\nimport { getDefaultLayoutHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js'\nimport { renderWidgetHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js'\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { initReq } from './initReq.js'\nimport { slugifyHandler } from './slugify.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'get-default-layout': getDefaultLayoutHandler,\n 'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,\n 'render-document': renderDocumentHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-list': renderListHandler,\n 'render-widget': renderWidgetHandler,\n 'schedule-publish': schedulePublishHandler,\n slugify: slugifyHandler,\n 'table-state': buildTableStateHandler,\n}\n\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { req } = await initReq({\n configPromise,\n importMap,\n key: 'RootLayout',\n })\n\n const augmentedArgs:
|
|
1
|
+
{"version":3,"file":"handleServerFunctions.js","names":["_internal_renderFieldHandler","copyDataFromLocaleHandler","buildFormStateHandler","buildTableStateHandler","getFolderResultsComponentAndDataHandler","schedulePublishHandler","getDefaultLayoutHandler","renderWidgetHandler","renderDocumentHandler","renderDocumentSlotsHandler","renderListHandler","initReq","slugifyHandler","baseServerFunctions","slugify","handleServerFunctions","args","name","fnKey","fnArgs","config","configPromise","importMap","serverFunctions","extraServerFunctions","cookies","locale","permissions","req","key","augmentedArgs","fn","Error"],"sources":["../../src/utilities/handleServerFunctions.ts"],"sourcesContent":["import type { DefaultServerFunctionArgs, ServerFunction, ServerFunctionHandler } from 'payload'\n\nimport { _internal_renderFieldHandler, copyDataFromLocaleHandler } from '@payloadcms/ui/rsc'\nimport { buildFormStateHandler } from '@payloadcms/ui/utilities/buildFormState'\nimport { buildTableStateHandler } from '@payloadcms/ui/utilities/buildTableState'\nimport { getFolderResultsComponentAndDataHandler } from '@payloadcms/ui/utilities/getFolderResultsComponentAndData'\nimport { schedulePublishHandler } from '@payloadcms/ui/utilities/schedulePublishHandler'\n\nimport { getDefaultLayoutHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js'\nimport { renderWidgetHandler } from '../views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js'\nimport { renderDocumentHandler } from '../views/Document/handleServerFunction.js'\nimport { renderDocumentSlotsHandler } from '../views/Document/renderDocumentSlots.js'\nimport { renderListHandler } from '../views/List/handleServerFunction.js'\nimport { initReq } from './initReq.js'\nimport { slugifyHandler } from './slugify.js'\n\nconst baseServerFunctions: Record<string, ServerFunction<any, any>> = {\n 'copy-data-from-locale': copyDataFromLocaleHandler,\n 'form-state': buildFormStateHandler,\n 'get-default-layout': getDefaultLayoutHandler,\n 'get-folder-results-component-and-data': getFolderResultsComponentAndDataHandler,\n 'render-document': renderDocumentHandler,\n 'render-document-slots': renderDocumentSlotsHandler,\n 'render-field': _internal_renderFieldHandler,\n 'render-list': renderListHandler,\n 'render-widget': renderWidgetHandler,\n 'schedule-publish': schedulePublishHandler,\n slugify: slugifyHandler,\n 'table-state': buildTableStateHandler,\n}\n\nexport const handleServerFunctions: ServerFunctionHandler = async (args) => {\n const {\n name: fnKey,\n args: fnArgs,\n config: configPromise,\n importMap,\n serverFunctions: extraServerFunctions,\n } = args\n\n const { cookies, locale, permissions, req } = await initReq({\n configPromise,\n importMap,\n key: 'RootLayout',\n })\n\n const augmentedArgs: DefaultServerFunctionArgs = {\n ...fnArgs,\n cookies,\n importMap,\n locale,\n permissions,\n req,\n }\n\n const fn = extraServerFunctions?.[fnKey] || baseServerFunctions[fnKey]\n\n if (!fn) {\n throw new Error(`Unknown Server Function: ${fnKey}`)\n }\n\n return fn(augmentedArgs)\n}\n"],"mappings":"AAEA,SAASA,4BAA4B,EAAEC,yBAAyB,QAAQ;AACxE,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,uCAAuC,QAAQ;AACxD,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,iBAAiB,QAAQ;AAClC,SAASC,OAAO,QAAQ;AACxB,SAASC,cAAc,QAAQ;AAE/B,MAAMC,mBAAA,GAAgE;EACpE,yBAAyBZ,yBAAA;EACzB,cAAcC,qBAAA;EACd,sBAAsBI,uBAAA;EACtB,yCAAyCF,uCAAA;EACzC,mBAAmBI,qBAAA;EACnB,yBAAyBC,0BAAA;EACzB,gBAAgBT,4BAAA;EAChB,eAAeU,iBAAA;EACf,iBAAiBH,mBAAA;EACjB,oBAAoBF,sBAAA;EACpBS,OAAA,EAASF,cAAA;EACT,eAAeT;AACjB;AAEA,OAAO,MAAMY,qBAAA,GAA+C,MAAOC,IAAA;EACjE,MAAM;IACJC,IAAA,EAAMC,KAAK;IACXF,IAAA,EAAMG,MAAM;IACZC,MAAA,EAAQC,aAAa;IACrBC,SAAS;IACTC,eAAA,EAAiBC;EAAoB,CACtC,GAAGR,IAAA;EAEJ,MAAM;IAAES,OAAO;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAG,MAAMjB,OAAA,CAAQ;IAC1DU,aAAA;IACAC,SAAA;IACAO,GAAA,EAAK;EACP;EAEA,MAAMC,aAAA,GAA2C;IAC/C,GAAGX,MAAM;IACTM,OAAA;IACAH,SAAA;IACAI,MAAA;IACAC,WAAA;IACAC;EACF;EAEA,MAAMG,EAAA,GAAKP,oBAAA,GAAuBN,KAAA,CAAM,IAAIL,mBAAmB,CAACK,KAAA,CAAM;EAEtE,IAAI,CAACa,EAAA,EAAI;IACP,MAAM,IAAIC,KAAA,CAAM,4BAA4Bd,KAAA,EAAO;EACrD;EAEA,OAAOa,EAAA,CAAGD,aAAA;AACZ","ignoreList":[]}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ImportMap, Locale, PayloadRequest, SanitizedConfig, SanitizedPermissions } from 'payload';
|
|
3
|
-
import { headers as getHeaders } from 'next/headers.js';
|
|
1
|
+
import type { ImportMap, InitReqResult, SanitizedConfig } from 'payload';
|
|
4
2
|
import { createLocalReq } from 'payload';
|
|
5
|
-
type Result = {
|
|
6
|
-
cookies: Map<string, string>;
|
|
7
|
-
headers: Awaited<ReturnType<typeof getHeaders>>;
|
|
8
|
-
languageCode: AcceptedLanguages;
|
|
9
|
-
locale?: Locale;
|
|
10
|
-
permissions: SanitizedPermissions;
|
|
11
|
-
req: PayloadRequest;
|
|
12
|
-
};
|
|
13
3
|
/**
|
|
14
4
|
* Initializes a full request object, including the `req` object and access control.
|
|
15
5
|
* As access control and getting the request locale is dependent on the current URL and
|
|
@@ -20,6 +10,5 @@ export declare const initReq: ({ canSetHeaders, configPromise, importMap, key, o
|
|
|
20
10
|
importMap: ImportMap;
|
|
21
11
|
key: string;
|
|
22
12
|
overrides?: Parameters<typeof createLocalReq>[0];
|
|
23
|
-
}) => Promise<
|
|
24
|
-
export {};
|
|
13
|
+
}) => Promise<InitReqResult>;
|
|
25
14
|
//# sourceMappingURL=initReq.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initReq.d.ts","sourceRoot":"","sources":["../../src/utilities/initReq.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAA;AAIxF,OAAO,EACL,cAAc,EAMf,MAAM,SAAS,CAAA;AAchB;;;GAGG;AACH,eAAO,MAAM,OAAO,iEAMjB;IACD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IACzD,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;CACjD,KAAG,OAAO,CAAC,aAAa,CA0FxB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initReq.js","names":["initI18n","headers","getHeaders","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","getRequestLocale","selectiveCache","partialReqCache","reqCache","initReq","canSetHeaders","configPromise","importMap","key","overrides","cookies","partialResult","get","config","payload","cron","languageCode","i18n","context","language","responseHeaders","user","req","reqOverrides","optionsOverrides","host","locale","code","permissions","then","result"],"sources":["../../src/utilities/initReq.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"initReq.js","names":["initI18n","headers","getHeaders","createLocalReq","executeAuthStrategies","getAccessResults","getPayload","getRequestLanguage","parseCookies","getRequestLocale","selectiveCache","partialReqCache","reqCache","initReq","canSetHeaders","configPromise","importMap","key","overrides","cookies","partialResult","get","config","payload","cron","languageCode","i18n","context","language","responseHeaders","user","req","reqOverrides","optionsOverrides","host","locale","code","permissions","then","result"],"sources":["../../src/utilities/initReq.ts"],"sourcesContent":["import type { I18n, I18nClient } from '@payloadcms/translations'\nimport type { ImportMap, InitReqResult, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { headers as getHeaders } from 'next/headers.js'\nimport {\n createLocalReq,\n executeAuthStrategies,\n getAccessResults,\n getPayload,\n getRequestLanguage,\n parseCookies,\n} from 'payload'\n\nimport { getRequestLocale } from './getRequestLocale.js'\nimport { selectiveCache } from './selectiveCache.js'\n\ntype PartialResult = {\n i18n: I18nClient\n} & Pick<InitReqResult, 'languageCode'> &\n Pick<PayloadRequest, 'payload' | 'responseHeaders' | 'user'>\n\n// Create cache instances for different parts of our application\nconst partialReqCache = selectiveCache<PartialResult>('partialReq')\nconst reqCache = selectiveCache<InitReqResult>('req')\n\n/**\n * Initializes a full request object, including the `req` object and access control.\n * As access control and getting the request locale is dependent on the current URL and\n */\nexport const initReq = async function ({\n canSetHeaders,\n configPromise,\n importMap,\n key,\n overrides,\n}: {\n canSetHeaders?: boolean\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n key: string\n overrides?: Parameters<typeof createLocalReq>[0]\n}): Promise<InitReqResult> {\n const headers = await getHeaders()\n const cookies = parseCookies(headers)\n\n const partialResult = await partialReqCache.get(async () => {\n const config = await configPromise\n const payload = await getPayload({ config, cron: true, importMap })\n const languageCode = getRequestLanguage({\n config,\n cookies,\n headers,\n })\n\n const i18n: I18nClient = await initI18n({\n config: config.i18n,\n context: 'client',\n language: languageCode,\n })\n\n const { responseHeaders, user } = await executeAuthStrategies({\n canSetHeaders,\n headers,\n payload,\n })\n\n return {\n i18n,\n languageCode,\n payload,\n responseHeaders,\n user,\n }\n }, 'global')\n\n return reqCache\n .get(async () => {\n const { i18n, languageCode, payload, responseHeaders, user } = partialResult\n\n const { req: reqOverrides, ...optionsOverrides } = overrides || {}\n\n const req = await createLocalReq(\n {\n req: {\n headers,\n host: headers.get('host'),\n i18n: i18n as I18n,\n responseHeaders,\n user,\n ...(reqOverrides || {}),\n },\n ...(optionsOverrides || {}),\n },\n payload,\n )\n\n const locale = await getRequestLocale({\n req,\n })\n\n req.locale = locale?.code\n\n const permissions = await getAccessResults({\n req,\n })\n\n return {\n cookies,\n headers,\n languageCode,\n locale,\n permissions,\n req,\n }\n }, key)\n .then((result) => {\n // CRITICAL: Create a shallow copy of req before returning to prevent\n // mutations from propagating to the cached req object.\n // This ensures parallel operations using the same cache key don't affect each other.\n return {\n ...result,\n req: {\n ...result.req,\n ...(result.req?.context\n ? {\n context: { ...result.req.context },\n }\n : {}),\n },\n }\n })\n}\n"],"mappings":"AAGA,SAASA,QAAQ,QAAQ;AACzB,SAASC,OAAA,IAAWC,UAAU,QAAQ;AACtC,SACEC,cAAc,EACdC,qBAAqB,EACrBC,gBAAgB,EAChBC,UAAU,EACVC,kBAAkB,EAClBC,YAAY,QACP;AAEP,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAO/B;AACA,MAAMC,eAAA,GAAkBD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AMA,IAAA;QACNG,eAAA;QACAC,IAAA;QACA,IAAIE,YAAA,IAAgB,CAAC,CAAC;MACxB;MACA,IAAIC,gBAAA,IAAoB,CAAC,CAAC;IAC5B,GACAV,OAAA;IAGF,MAAMY,MAAA,GAAS,MAAM1B,gBAAA,CAAiB;MACpCsB;IACF;IAEAA,GAAA,CAAII,MAAM,GAAGA,MAAA,EAAQC,IAAA;IAErB,MAAMC,WAAA,GAAc,MAAMhC,gBAAA,CAAiB;MACzC0B;IACF;IAEA,OAAO;MACLZ,OAAA;MACAlB,OAAA;MACAwB,YAAA;MACAU,MAAA;MACAE,WAAA;MACAN;IACF;EACF,GAAGd,GAAA,EACFqB,IAAI,CAAEC,MAAA;IACL;IACA;IACA;IACA,OAAO;MACL,GAAGA,MAAM;MACTR,GAAA,EAAK;QACH,GAAGQ,MAAA,CAAOR,GAAG;QACb,IAAIQ,MAAA,CAAOR,GAAG,EAAEJ,OAAA,GACZ;UACEA,OAAA,EAAS;YAAE,GAAGY,MAAA,CAAOR,GAAG,CAACJ;UAAQ;QACnC,IACA,CAAC,CAAC;MACR;IACF;EACF;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,cAAc,EAGd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EAGrB,cAAc,
|
|
1
|
+
{"version":3,"file":"renderDocumentSlots.d.ts","sourceRoot":"","sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAEb,cAAc,EAGd,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EAGrB,cAAc,EAMf,MAAM,SAAS,CAAA;AAQhB,eAAO,MAAM,mBAAmB,EAAE,CAAC,IAAI,EAAE;IACvC,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,WAAW,EAAE,4BAA4B,CAAA;IACzC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,aA+KL,CAAA;AAED,eAAO,MAAM,0BAA0B,EAAE,cAAc,CAAC;IACtD,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAsBA,CAAA"}
|
|
@@ -89,6 +89,14 @@ export const renderDocumentSlots = args => {
|
|
|
89
89
|
serverProps: serverProps
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
+
const CustomUnpublishButton = collectionConfig?.admin?.components?.edit?.UnpublishButton || globalConfig?.admin?.components?.elements?.UnpublishButton;
|
|
93
|
+
if (CustomUnpublishButton) {
|
|
94
|
+
components.UnpublishButton = RenderServerComponent({
|
|
95
|
+
Component: CustomUnpublishButton,
|
|
96
|
+
importMap: req.payload.importMap,
|
|
97
|
+
serverProps: serverProps
|
|
98
|
+
});
|
|
99
|
+
}
|
|
92
100
|
const CustomSaveDraftButton = collectionConfig?.admin?.components?.edit?.SaveDraftButton || globalConfig?.admin?.components?.elements?.SaveDraftButton;
|
|
93
101
|
const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig);
|
|
94
102
|
if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","docPermissions","data","permissions"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n permissions: SanitizedDocumentPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n payload: req.payload,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.elements?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description ||\n globalConfig?.admin?.components?.elements?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.elements?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.elements?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { docPermissions, hasSavePermission } = await getDocumentPermissions({\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n}\n"],"mappings":"AAmBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAOUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC;EAAG,CAAE,GAAGL,IAAA;EAEvE,MAAMM,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBP,gBAAA,EAAkBQ,KAAA,EAAOC,OAAA,IAAWR,YAAA,EAAcO,KAAA,EAAOC,OAAA;EAElF,MAAMC,WAAA,GAA2B;IAC/BX,EAAA;IACAY,IAAA,EAAMR,GAAA,CAAIQ,IAAI;IACdC,OAAA,EAAST,GAAA,CAAIS,OAAO;IACpBC,IAAA,EAAMV,GAAA,CAAIU;EAEZ;EAEA,MAAMC,sBAAA,GACJd,gBAAA,EAAkBQ,KAAA,EAAOJ,UAAA,EAAYW,IAAA,EAAMC,sBAAA,IAC3Cf,YAAA,EAAcO,KAAA,EAAOJ,UAAA,EAAYa,QAAA,EAAUD,sBAAA;EAE7C,IAAIF,sBAAA,EAAwB;IAC1BV,UAAA,CAAWU,sBAAsB,GAAGpB,qBAAA,CAAsB;MACxDwB,SAAA,EAAWJ,sBAAA;MACXK,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT,WAAA,EAAaA;IACf;EACF;EAEA,MAAMU,aAAA,GAAgBpB,gBAAA,EAAkBQ,KAAA,EAAOJ,UAAA,EA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AACW,IAAI,CAACmC,MAAM;MACxD/B,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,IAAIV,gBAAA,EAAkBiD,MAAA,IAAUjD,gBAAA,CAAiBiD,MAAM,CAACzC,KAAK,EAAEJ,UAAA,EAAY+C,QAAA,EAAU;IACnF/C,UAAA,CAAWgD,cAAc,GAAG1D,qBAAA,CAAsB;MAChDwB,SAAA,EAAWlB,gBAAA,CAAiBiD,MAAM,CAACzC,KAAK,CAACJ,UAAU,CAAC+C,QAAQ;MAC5DhC,SAAA,EAAWhB,GAAA,CAAIS,OAAO,CAACO,SAAS;MAChCT;IACF;EACF;EAEA,OAAON,UAAA;AACT;AAEA,OAAO,MAAMiD,0BAAA,GAGR,MAAOvD,IAAA;EACV,MAAM;IAAEC,EAAE;IAAEoC,cAAc;IAAEhC;EAAG,CAAE,GAAGL,IAAA;EAEpC,MAAME,gBAAA,GAAmBG,GAAA,CAAIS,OAAO,CAAC0C,WAAW,CAACnB,cAAA,CAAe,EAAEoB,MAAA;EAElE,IAAI,CAACvD,gBAAA,EAAkB;IACrB,MAAM,IAAIwD,KAAA,CAAMrD,GAAA,CAAI2B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE2B,cAAc;IAAEvD;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzEI,gBAAA;IACA0D,IAAA,EAAM,CAAC;IACPvD;EACF;EAEA,OAAON,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACAyD,WAAA,EAAaF,cAAA;IACbtD;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderDocumentSlots.js","names":["ViewDescription","RenderServerComponent","hasDraftsEnabled","getDocumentPermissions","renderDocumentSlots","args","id","collectionConfig","globalConfig","hasSavePermission","req","components","unsavedDraftWithValidations","undefined","isPreviewEnabled","admin","preview","serverProps","i18n","payload","user","BeforeDocumentControls","edit","beforeDocumentControls","elements","Component","importMap","EditMenuItems","editMenuItems","CustomPreviewButton","PreviewButton","LivePreview","views","livePreview","descriptionFromConfig","description","staticDescription","t","CustomDescription","Description","hasDescription","clientProps","collectionSlug","slug","Fallback","versions","drafts","CustomStatus","Status","CustomPublishButton","PublishButton","CustomUnpublishButton","UnpublishButton","CustomSaveDraftButton","SaveDraftButton","draftsEnabled","CustomSaveButton","SaveButton","upload","Upload","controls","UploadControls","renderDocumentSlotsHandler","collections","config","Error","docPermissions","data","permissions"],"sources":["../../../src/views/Document/renderDocumentSlots.tsx"],"sourcesContent":["import type {\n BeforeDocumentControlsServerPropsOnly,\n DocumentSlots,\n EditMenuItemsServerPropsOnly,\n PayloadRequest,\n PreviewButtonServerPropsOnly,\n PublishButtonServerPropsOnly,\n SanitizedCollectionConfig,\n SanitizedDocumentPermissions,\n SanitizedGlobalConfig,\n SaveButtonServerPropsOnly,\n SaveDraftButtonServerPropsOnly,\n ServerFunction,\n ServerProps,\n StaticDescription,\n UnpublishButtonServerPropsOnly,\n ViewDescriptionClientProps,\n ViewDescriptionServerPropsOnly,\n} from 'payload'\n\nimport { ViewDescription } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { hasDraftsEnabled } from 'payload/shared'\n\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport const renderDocumentSlots: (args: {\n collectionConfig?: SanitizedCollectionConfig\n globalConfig?: SanitizedGlobalConfig\n hasSavePermission: boolean\n id?: number | string\n permissions: SanitizedDocumentPermissions\n req: PayloadRequest\n}) => DocumentSlots = (args) => {\n const { id, collectionConfig, globalConfig, hasSavePermission, req } = args\n\n const components: DocumentSlots = {} as DocumentSlots\n\n const unsavedDraftWithValidations = undefined\n\n const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview\n\n const serverProps: ServerProps = {\n id,\n i18n: req.i18n,\n payload: req.payload,\n user: req.user,\n // TODO: Add remaining serverProps\n }\n\n const BeforeDocumentControls =\n collectionConfig?.admin?.components?.edit?.beforeDocumentControls ||\n globalConfig?.admin?.components?.elements?.beforeDocumentControls\n\n if (BeforeDocumentControls) {\n components.BeforeDocumentControls = RenderServerComponent({\n Component: BeforeDocumentControls,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies BeforeDocumentControlsServerPropsOnly,\n })\n }\n\n const EditMenuItems = collectionConfig?.admin?.components?.edit?.editMenuItems\n\n if (EditMenuItems) {\n components.EditMenuItems = RenderServerComponent({\n Component: EditMenuItems,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies EditMenuItemsServerPropsOnly,\n })\n }\n\n const CustomPreviewButton =\n collectionConfig?.admin?.components?.edit?.PreviewButton ||\n globalConfig?.admin?.components?.elements?.PreviewButton\n\n if (isPreviewEnabled && CustomPreviewButton) {\n components.PreviewButton = RenderServerComponent({\n Component: CustomPreviewButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PreviewButtonServerPropsOnly,\n })\n }\n\n const LivePreview =\n collectionConfig?.admin?.components?.views?.edit?.livePreview ||\n globalConfig?.admin?.components?.views?.edit?.livePreview\n\n if (LivePreview?.Component) {\n components.LivePreview = RenderServerComponent({\n Component: LivePreview.Component,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n const descriptionFromConfig =\n collectionConfig?.admin?.description || globalConfig?.admin?.description\n\n const staticDescription: StaticDescription =\n typeof descriptionFromConfig === 'function'\n ? descriptionFromConfig({ t: req.i18n.t })\n : descriptionFromConfig\n\n const CustomDescription =\n collectionConfig?.admin?.components?.Description ||\n globalConfig?.admin?.components?.elements?.Description\n\n const hasDescription = CustomDescription || staticDescription\n\n if (hasDescription) {\n components.Description = RenderServerComponent({\n clientProps: {\n collectionSlug: collectionConfig?.slug,\n description: staticDescription,\n } satisfies ViewDescriptionClientProps,\n Component: CustomDescription,\n Fallback: ViewDescription,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies ViewDescriptionServerPropsOnly,\n })\n }\n\n if (collectionConfig?.versions?.drafts || globalConfig?.versions?.drafts) {\n const CustomStatus =\n collectionConfig?.admin?.components?.edit?.Status ||\n globalConfig?.admin?.components?.elements?.Status\n\n if (CustomStatus) {\n components.Status = RenderServerComponent({\n Component: CustomStatus,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n }\n\n if (hasSavePermission) {\n if (hasDraftsEnabled(collectionConfig || globalConfig)) {\n const CustomPublishButton =\n collectionConfig?.admin?.components?.edit?.PublishButton ||\n globalConfig?.admin?.components?.elements?.PublishButton\n\n if (CustomPublishButton) {\n components.PublishButton = RenderServerComponent({\n Component: CustomPublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies PublishButtonServerPropsOnly,\n })\n }\n\n const CustomUnpublishButton =\n collectionConfig?.admin?.components?.edit?.UnpublishButton ||\n globalConfig?.admin?.components?.elements?.UnpublishButton\n\n if (CustomUnpublishButton) {\n components.UnpublishButton = RenderServerComponent({\n Component: CustomUnpublishButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies UnpublishButtonServerPropsOnly,\n })\n }\n\n const CustomSaveDraftButton =\n collectionConfig?.admin?.components?.edit?.SaveDraftButton ||\n globalConfig?.admin?.components?.elements?.SaveDraftButton\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n if ((draftsEnabled || unsavedDraftWithValidations) && CustomSaveDraftButton) {\n components.SaveDraftButton = RenderServerComponent({\n Component: CustomSaveDraftButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveDraftButtonServerPropsOnly,\n })\n }\n } else {\n const CustomSaveButton =\n collectionConfig?.admin?.components?.edit?.SaveButton ||\n globalConfig?.admin?.components?.elements?.SaveButton\n\n if (CustomSaveButton) {\n components.SaveButton = RenderServerComponent({\n Component: CustomSaveButton,\n importMap: req.payload.importMap,\n serverProps: serverProps satisfies SaveButtonServerPropsOnly,\n })\n }\n }\n }\n\n if (collectionConfig?.upload && collectionConfig?.admin?.components?.edit?.Upload) {\n components.Upload = RenderServerComponent({\n Component: collectionConfig.admin.components.edit.Upload,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n if (collectionConfig?.upload && collectionConfig.upload.admin?.components?.controls) {\n components.UploadControls = RenderServerComponent({\n Component: collectionConfig.upload.admin.components.controls,\n importMap: req.payload.importMap,\n serverProps,\n })\n }\n\n return components\n}\n\nexport const renderDocumentSlotsHandler: ServerFunction<{\n collectionSlug: string\n id?: number | string\n}> = async (args) => {\n const { id, collectionSlug, req } = args\n\n const collectionConfig = req.payload.collections[collectionSlug]?.config\n\n if (!collectionConfig) {\n throw new Error(req.t('error:incorrectCollection'))\n }\n\n const { docPermissions, hasSavePermission } = await getDocumentPermissions({\n collectionConfig,\n data: {},\n req,\n })\n\n return renderDocumentSlots({\n id,\n collectionConfig,\n hasSavePermission,\n permissions: docPermissions,\n req,\n })\n}\n"],"mappings":"AAoBA,SAASA,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,mBAAA,GAOUC,IAAA;EACrB,MAAM;IAAEC,EAAE;IAAEC,gBAAgB;IAAEC,YAAY;IAAEC,iBAAiB;IAAEC;EAAG,CAAE,GAAGL,IAAA;EAEvE,MAAMM,UAAA,GAA4B,CAAC;EAEnC,MAAMC,2BAAA,GAA8BC,SAAA;EAEpC,MAAMC,gBAAA,GAAmBP,gBAAA,EAAkBQ,KAAA,EAAOC,OAAA,IAAWR,YAAA,EAAcO,KAAA,EAAOC,OAAA;EAElF,MAAMC,WAAA,GAA2B;IAC/BX,EAAA;IACAY,IAAA,EAAMR,GAAA,CAAIQ,IAAI;IACdC,OAAA,EAAST,GAAA,CAAIS,OAAO;IACpBC,IAAA,EAAMV,GAAA,CAAIU;EAEZ;EAEA,MAAMC,sBAAA,GACJd,gBAAA,EAAkBQ,KAAA,EAAOJ,UAAA,EAAYW,IAAA,EAAMC,sBAAA,IAC3Cf,YAAA,EAAcO,KA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EAEpC,MAAME,gBAAA,GAAmBG,GAAA,CAAIS,OAAO,CAAC4C,WAAW,CAACrB,cAAA,CAAe,EAAEsB,MAAA;EAElE,IAAI,CAACzD,gBAAA,EAAkB;IACrB,MAAM,IAAI0D,KAAA,CAAMvD,GAAA,CAAI2B,CAAC,CAAC;EACxB;EAEA,MAAM;IAAE6B,cAAc;IAAEzD;EAAiB,CAAE,GAAG,MAAMN,sBAAA,CAAuB;IACzEI,gBAAA;IACA4D,IAAA,EAAM,CAAC;IACPzD;EACF;EAEA,OAAON,mBAAA,CAAoB;IACzBE,EAAA;IACAC,gBAAA;IACAE,iBAAA;IACA2D,WAAA,EAAaF,cAAA;IACbxD;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionPillLabel.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/VersionPillLabel/VersionPillLabel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAarB,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,yBAAyB,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB,GAAG,EAAE;QACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;QACtB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,EAAE;YACP,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;YACtB,OAAO,EAAE,OAAO,GAAG,WAAW,CAAA;YAC9B,SAAS,EAAE,MAAM,CAAA;SAClB,CAAA;KACF,CAAA;IACD;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { Pill, useConfig, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { Pill, useConfig, useLocale, useTranslation } from '@payloadcms/ui';
|
|
6
6
|
import { formatDate } from '@payloadcms/ui/shared';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { getVersionLabel } from './getVersionLabel.js';
|
|
@@ -15,7 +15,7 @@ const renderPill = (label, pillStyle) => {
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
export const VersionPillLabel = t0 => {
|
|
18
|
-
const $ = _c(
|
|
18
|
+
const $ = _c(14);
|
|
19
19
|
const {
|
|
20
20
|
currentlyPublishedVersion,
|
|
21
21
|
disableDate: t1,
|
|
@@ -43,12 +43,16 @@ export const VersionPillLabel = t0 => {
|
|
|
43
43
|
i18n,
|
|
44
44
|
t
|
|
45
45
|
} = useTranslation();
|
|
46
|
+
const {
|
|
47
|
+
code: currentLocale
|
|
48
|
+
} = useLocale();
|
|
46
49
|
let t6;
|
|
47
|
-
if ($[0] !==
|
|
50
|
+
if ($[0] !== currentLocale || $[1] !== currentlyPublishedVersion || $[2] !== dateFormat || $[3] !== disableDate || $[4] !== doc || $[5] !== i18n || $[6] !== labelFirst || $[7] !== labelOverride || $[8] !== labelStyle || $[9] !== labelSuffix || $[10] !== latestDraftVersion || $[11] !== localization || $[12] !== t) {
|
|
48
51
|
const {
|
|
49
52
|
label,
|
|
50
53
|
pillStyle
|
|
51
54
|
} = getVersionLabel({
|
|
55
|
+
currentLocale,
|
|
52
56
|
currentlyPublishedVersion,
|
|
53
57
|
latestDraftVersion,
|
|
54
58
|
t,
|
|
@@ -89,21 +93,22 @@ export const VersionPillLabel = t0 => {
|
|
|
89
93
|
children: localeLabel
|
|
90
94
|
})]
|
|
91
95
|
});
|
|
92
|
-
$[0] =
|
|
93
|
-
$[1] =
|
|
94
|
-
$[2] =
|
|
95
|
-
$[3] =
|
|
96
|
-
$[4] =
|
|
97
|
-
$[5] =
|
|
98
|
-
$[6] =
|
|
99
|
-
$[7] =
|
|
100
|
-
$[8] =
|
|
101
|
-
$[9] =
|
|
102
|
-
$[10] =
|
|
103
|
-
$[11] =
|
|
104
|
-
$[12] =
|
|
96
|
+
$[0] = currentLocale;
|
|
97
|
+
$[1] = currentlyPublishedVersion;
|
|
98
|
+
$[2] = dateFormat;
|
|
99
|
+
$[3] = disableDate;
|
|
100
|
+
$[4] = doc;
|
|
101
|
+
$[5] = i18n;
|
|
102
|
+
$[6] = labelFirst;
|
|
103
|
+
$[7] = labelOverride;
|
|
104
|
+
$[8] = labelStyle;
|
|
105
|
+
$[9] = labelSuffix;
|
|
106
|
+
$[10] = latestDraftVersion;
|
|
107
|
+
$[11] = localization;
|
|
108
|
+
$[12] = t;
|
|
109
|
+
$[13] = t6;
|
|
105
110
|
} else {
|
|
106
|
-
t6 = $[
|
|
111
|
+
t6 = $[13];
|
|
107
112
|
}
|
|
108
113
|
return t6;
|
|
109
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionPillLabel.js","names":["c","_c","Pill","useConfig","useTranslation","formatDate","React","getVersionLabel","baseClass","renderPill","label","pillStyle","_jsx","size","VersionPillLabel","t0","$","currentlyPublishedVersion","disableDate","t1","doc","labelFirst","t2","labelOverride","labelStyle","t3","labelSuffix","latestDraftVersion","undefined","config","t4","admin","t5","localization","dateFormat","i18n","t","t6","version","labelText","_jsxs","children","showDate","updatedAt","formattedDate","date","pattern","localeCode","Array","isArray","publishedLocale","locale","locales","find","loc","
|
|
1
|
+
{"version":3,"file":"VersionPillLabel.js","names":["c","_c","Pill","useConfig","useLocale","useTranslation","formatDate","React","getVersionLabel","baseClass","renderPill","label","pillStyle","_jsx","size","VersionPillLabel","t0","$","currentlyPublishedVersion","disableDate","t1","doc","labelFirst","t2","labelOverride","labelStyle","t3","labelSuffix","latestDraftVersion","undefined","config","t4","admin","t5","localization","dateFormat","i18n","t","code","currentLocale","t6","version","labelText","_jsxs","children","showDate","updatedAt","formattedDate","date","pattern","localeCode","Array","isArray","publishedLocale","locale","locales","find","loc","localeLabel","language","className","Fragment"],"sources":["../../../../src/views/Version/VersionPillLabel/VersionPillLabel.tsx"],"sourcesContent":["'use client'\n\nimport type { TypeWithVersion } from 'payload'\n\nimport { Pill, useConfig, useLocale, useTranslation } from '@payloadcms/ui'\nimport { formatDate } from '@payloadcms/ui/shared'\nimport React from 'react'\n\nimport './index.scss'\nimport { getVersionLabel } from './getVersionLabel.js'\n\nconst baseClass = 'version-pill-label'\n\nconst renderPill = (label: React.ReactNode, pillStyle: Parameters<typeof Pill>[0]['pillStyle']) => {\n return (\n <Pill pillStyle={pillStyle} size=\"small\">\n {label}\n </Pill>\n )\n}\n\nexport const VersionPillLabel: React.FC<{\n currentlyPublishedVersion?: TypeWithVersion<any>\n disableDate?: boolean\n\n doc: {\n [key: string]: unknown\n id: number | string\n publishedLocale?: string\n updatedAt?: string\n version: {\n [key: string]: unknown\n _status: 'draft' | 'published'\n updatedAt: string\n }\n }\n /**\n * By default, the date is displayed first, followed by the version label.\n * @default false\n */\n labelFirst?: boolean\n labelOverride?: React.ReactNode\n /**\n * @default 'pill'\n */\n labelStyle?: 'pill' | 'text'\n labelSuffix?: React.ReactNode\n latestDraftVersion?: TypeWithVersion<any>\n}> = ({\n currentlyPublishedVersion,\n disableDate = false,\n doc,\n labelFirst = false,\n labelOverride,\n labelStyle = 'pill',\n labelSuffix,\n latestDraftVersion,\n}) => {\n const {\n config: {\n admin: { dateFormat },\n localization,\n },\n } = useConfig()\n const { i18n, t } = useTranslation()\n const { code: currentLocale } = useLocale()\n\n const { label, pillStyle } = getVersionLabel({\n currentLocale,\n currentlyPublishedVersion,\n latestDraftVersion,\n t,\n version: doc,\n })\n const labelText: React.ReactNode = (\n <span>\n {labelOverride || label}\n {labelSuffix}\n </span>\n )\n\n const showDate = !disableDate && doc.updatedAt\n const formattedDate = showDate\n ? formatDate({ date: doc.updatedAt, i18n, pattern: dateFormat })\n : null\n\n const localeCode = Array.isArray(doc.publishedLocale)\n ? doc.publishedLocale[0]\n : doc.publishedLocale\n\n const locale =\n localization && localization?.locales\n ? localization.locales.find((loc) => loc.code === localeCode)\n : null\n const localeLabel = locale ? locale?.label?.[i18n?.language] || locale?.label : null\n\n return (\n <div className={baseClass}>\n {labelFirst ? (\n <React.Fragment>\n {labelStyle === 'pill' ? (\n renderPill(labelText, pillStyle)\n ) : (\n <span className={`${baseClass}-text`}>{labelText}</span>\n )}\n {showDate && <span className={`${baseClass}-date`}>{formattedDate}</span>}\n </React.Fragment>\n ) : (\n <React.Fragment>\n {showDate && <span className={`${baseClass}-date`}>{formattedDate}</span>}\n {labelStyle === 'pill' ? (\n renderPill(labelText, pillStyle)\n ) : (\n <span className={`${baseClass}-text`}>{labelText}</span>\n )}\n </React.Fragment>\n )}\n {localeLabel && <Pill size=\"small\">{localeLabel}</Pill>}\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,IAAI,EAAEC,SAAS,EAAEC,SAAS,EAAEC,cAAc,QAAQ;AAC3D,SAASC,UAAU,QAAQ;AAC3B,OAAOC,KAAA,MAAW;AAGlB,SAASC,eAAe,QAAQ;AAEhC,MAAMC,SAAA,GAAY;AAElB,MAAMC,UAAA,GAAaA,CAACC,KAAA,EAAwBC,SAAA;EAC1C,oBACEC,IAAA,CAACX,IAAA;IAAKU,SAAA,EAAWA,SAAA;IAAWE,IAAA,EAAK;cAC9BH;;AAGP;AAEA,OAAO,MAAMI,gBAAA,GA2BRC,EAAA;EAAA,MAAAC,CAAA,GAAAhB,EAAA;EAAC;IAAAiB,yBAAA;IAAAC,WAAA,EAAAC,EAAA;IAAAC,GAAA;IAAAC,UAAA,EAAAC,EAAA;IAAAC,aAAA;IAAAC,UAAA,EAAAC,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AAmC,QAAA,EAAGF;QAAA,C;UAI5CgB,WAAA,IAAe7C,IAAA,CAAAX,IAAA;QAAAY,IAAA,EAAW;QAAA8B,QAAA,EAASc;MAAA,C;;;;;;;;;;;;;;;;;;;SApBtClB,E;CAuBJ","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TFunction } from '@payloadcms/translations';
|
|
2
|
-
import {
|
|
2
|
+
import type { Pill } from '@payloadcms/ui';
|
|
3
3
|
type Args = {
|
|
4
|
+
currentLocale?: string;
|
|
4
5
|
currentlyPublishedVersion?: {
|
|
5
6
|
id: number | string;
|
|
6
7
|
publishedLocale?: string;
|
|
@@ -27,7 +28,7 @@ type Args = {
|
|
|
27
28
|
* Gets the appropriate version label and version pill styling
|
|
28
29
|
* given existing versions and the current version status.
|
|
29
30
|
*/
|
|
30
|
-
export declare function getVersionLabel({ currentlyPublishedVersion, latestDraftVersion, t, version, }: Args): {
|
|
31
|
+
export declare function getVersionLabel({ currentLocale, currentlyPublishedVersion, latestDraftVersion, t, version, }: Args): {
|
|
31
32
|
label: string;
|
|
32
33
|
name: 'currentDraft' | 'currentlyPublished' | 'draft' | 'previouslyPublished' | 'published';
|
|
33
34
|
pillStyle: Parameters<typeof Pill>[0]['pillStyle'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVersionLabel.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/VersionPillLabel/getVersionLabel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"getVersionLabel.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/VersionPillLabel/getVersionLabel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAE1C,KAAK,IAAI,GAAG;IACV,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,yBAAyB,CAAC,EAAE;QAC1B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE;YACP,SAAS,EAAE,MAAM,CAAA;SAClB,CAAA;KACF,CAAA;IACD,kBAAkB,CAAC,EAAE;QACnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,CAAC,EAAE,SAAS,CAAA;IACZ,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;QACnB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,OAAO,EAAE;YAAE,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAA;KAChE,CAAA;CACF,CAAA;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EAClB,CAAC,EACD,OAAO,GACR,EAAE,IAAI,GAAG;IACR,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,cAAc,GAAG,oBAAoB,GAAG,OAAO,GAAG,qBAAqB,GAAG,WAAW,CAAA;IAC3F,SAAS,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;CACnD,CA6CA"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { useLocale } from '@payloadcms/ui';
|
|
2
1
|
/**
|
|
3
2
|
* Gets the appropriate version label and version pill styling
|
|
4
3
|
* given existing versions and the current version status.
|
|
5
|
-
*/
|
|
6
|
-
|
|
4
|
+
*/export function getVersionLabel({
|
|
5
|
+
currentLocale,
|
|
7
6
|
currentlyPublishedVersion,
|
|
8
7
|
latestDraftVersion,
|
|
9
8
|
t,
|
|
10
9
|
version
|
|
11
10
|
}) {
|
|
12
|
-
const {
|
|
13
|
-
code: currentLocale
|
|
14
|
-
} = useLocale();
|
|
15
11
|
const status = version.version._status;
|
|
16
12
|
if (status === 'draft') {
|
|
17
13
|
const publishedNewerThanDraft = currentlyPublishedVersion?.updatedAt > latestDraftVersion?.updatedAt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVersionLabel.js","names":["
|
|
1
|
+
{"version":3,"file":"getVersionLabel.js","names":["getVersionLabel","currentLocale","currentlyPublishedVersion","latestDraftVersion","t","version","status","_status","publishedNewerThanDraft","updatedAt","name","label","pillStyle","isCurrentDraft","id","publishedInAnotherLocale","publishedLocale","isCurrentlyPublished"],"sources":["../../../../src/views/Version/VersionPillLabel/getVersionLabel.ts"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type { Pill } from '@payloadcms/ui'\n\ntype Args = {\n currentLocale?: string\n currentlyPublishedVersion?: {\n id: number | string\n publishedLocale?: string\n updatedAt: string\n version: {\n updatedAt: string\n }\n }\n latestDraftVersion?: {\n id: number | string\n updatedAt: string\n }\n t: TFunction\n version: {\n id: number | string\n publishedLocale?: string\n version: { _status?: 'draft' | 'published'; updatedAt: string }\n }\n}\n\n/**\n * Gets the appropriate version label and version pill styling\n * given existing versions and the current version status.\n */\nexport function getVersionLabel({\n currentLocale,\n currentlyPublishedVersion,\n latestDraftVersion,\n t,\n version,\n}: Args): {\n label: string\n name: 'currentDraft' | 'currentlyPublished' | 'draft' | 'previouslyPublished' | 'published'\n pillStyle: Parameters<typeof Pill>[0]['pillStyle']\n} {\n const status = version.version._status\n\n if (status === 'draft') {\n const publishedNewerThanDraft =\n currentlyPublishedVersion?.updatedAt > latestDraftVersion?.updatedAt\n\n if (publishedNewerThanDraft) {\n return {\n name: 'draft',\n label: t('version:draft'),\n pillStyle: 'light',\n }\n }\n\n const isCurrentDraft = version.id === latestDraftVersion?.id\n\n return {\n name: isCurrentDraft ? 'currentDraft' : 'draft',\n label: isCurrentDraft ? t('version:currentDraft') : t('version:draft'),\n pillStyle: 'light',\n }\n }\n\n const publishedInAnotherLocale =\n status === 'published' && version.publishedLocale && currentLocale !== version.publishedLocale\n\n if (publishedInAnotherLocale) {\n return {\n name: 'currentDraft',\n label: t('version:currentDraft'),\n pillStyle: 'light',\n }\n }\n\n const isCurrentlyPublished =\n currentlyPublishedVersion && version.id === currentlyPublishedVersion.id\n\n return {\n name: isCurrentlyPublished ? 'currentlyPublished' : 'previouslyPublished',\n label: isCurrentlyPublished\n ? t('version:currentlyPublished')\n : t('version:previouslyPublished'),\n pillStyle: isCurrentlyPublished ? 'success' : 'light',\n }\n}\n"],"mappings":"AAyBA;;;GAIA,OAAO,SAASA,gBAAgB;EAC9BC,aAAa;EACbC,yBAAyB;EACzBC,kBAAkB;EAClBC,CAAC;EACDC;AAAO,CACF;EAKL,MAAMC,MAAA,GAASD,OAAA,CAAQA,OAAO,CAACE,OAAO;EAEtC,IAAID,MAAA,KAAW,SAAS;IACtB,MAAME,uBAAA,GACJN,yBAAA,EAA2BO,SAAA,GAAYN,kBAAA,EAAoBM,SAAA;IAE7D,IAAID,uBAAA,EAAyB;MAC3B,OAAO;QACLE,IAAA,EAAM;QACNC,KAAA,EAAOP,CAAA,CAAE;QACTQ,SAAA,EAAW;MACb;IACF;IAEA,MAAMC,cAAA,GAAiBR,OAAA,CAAQS,EAAE,KAAKX,kBAAA,EAAoBW,EAAA;IAE1D,OAAO;MACLJ,IAAA,EAAMG,cAAA,GAAiB,iBAAiB;MACxCF,KAAA,EAAOE,cAAA,GAAiBT,CAAA,CAAE,0BAA0BA,CAAA,CAAE;MACtDQ,SAAA,EAAW;IACb;EACF;EAEA,MAAMG,wBAAA,GACJT,MAAA,KAAW,eAAeD,OAAA,CAAQW,eAAe,IAAIf,aAAA,KAAkBI,OAAA,CAAQW,eAAe;EAEhG,IAAID,wBAAA,EAA0B;IAC5B,OAAO;MACLL,IAAA,EAAM;MACNC,KAAA,EAAOP,CAAA,CAAE;MACTQ,SAAA,EAAW;IACb;EACF;EAEA,MAAMK,oBAAA,GACJf,yBAAA,IAA6BG,OAAA,CAAQS,EAAE,KAAKZ,yBAAA,CAA0BY,EAAE;EAE1E,OAAO;IACLJ,IAAA,EAAMO,oBAAA,GAAuB,uBAAuB;IACpDN,KAAA,EAAOM,oBAAA,GACHb,CAAA,CAAE,gCACFA,CAAA,CAAE;IACNQ,SAAA,EAAWK,oBAAA,GAAuB,YAAY;EAChD;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Version/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EAKxB,MAAM,SAAS,CAAA;AAQhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,wBAAsB,WAAW,CAAC,KAAK,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Version/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EAKxB,MAAM,SAAS,CAAA;AAQhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,wBAAsB,WAAW,CAAC,KAAK,EAAE,uBAAuB,8BAoa/D"}
|
|
@@ -40,6 +40,8 @@ export async function VersionView(props) {
|
|
|
40
40
|
const collectionSlug = collectionConfig?.slug;
|
|
41
41
|
const globalSlug = globalConfig?.slug;
|
|
42
42
|
const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig);
|
|
43
|
+
// Resolve user's current locale for version label comparison (not 'all')
|
|
44
|
+
const userLocale = searchParams.locale || (req.locale !== 'all' ? req.locale : localization && localization.defaultLocale);
|
|
43
45
|
const localeCodesFromParams = searchParams.localeCodes ? JSON.parse(searchParams.localeCodes) : null;
|
|
44
46
|
const versionFromIDFromParams = searchParams.versionFrom;
|
|
45
47
|
const modifiedOnly = searchParams.modifiedOnly === 'false' ? false : true;
|
|
@@ -309,6 +311,7 @@ export async function VersionView(props) {
|
|
|
309
311
|
const labelSuffix = otherOptionsWithSameID?.length ? /*#__PURE__*/_jsxs("span", {
|
|
310
312
|
children: [' (', otherOptionsWithSameID.map((optionWithSameID, index) => {
|
|
311
313
|
const label = optionWithSameID.labelOverride || getVersionLabel({
|
|
314
|
+
currentLocale: userLocale,
|
|
312
315
|
currentlyPublishedVersion,
|
|
313
316
|
latestDraftVersion,
|
|
314
317
|
t: i18n.t,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatDate","getClientConfig","getClientSchemaMap","getSchemaMap","notFound","hasDraftsEnabled","React","DefaultVersionView","fetchLatestVersion","fetchVersion","fetchVersions","RenderDiff","getVersionLabel","VersionPillLabel","VersionView","props","hasPublishedDoc","i18n","initPageResult","routeSegments","searchParams","collectionConfig","docID","id","globalConfig","permissions","req","payload","config","localization","user","versionToID","length","collectionSlug","slug","globalSlug","draftsEnabled","localeCodesFromParams","localeCodes","JSON","parse","versionFromIDFromParams","versionFrom","modifiedOnly","docPermissions","collections","globals","versionTo","depth","locale","overrideAccess","previousVersionResult","versionFromResult","currentlyPublishedVersion","latestDraftVersion","previousPublishedVersionResult","Promise","all","draft","limit","parentID","sort","where","and","updatedAt","less_than","resolve","status","equals","previousVersion","docs","previousPublishedVersion","selectedLocales","locales","code","find","push","filterAvailableLocales","map","schemaMap","clientSchemaMap","importMap","RenderedDiff","customDiffComponents","entitySlug","fields","fieldsPermissions","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","versionFromSiblingData","version","versionToSiblingData","versionToCreatedAtFormatted","date","Date","pattern","admin","dateFormat","formatPill","doc","labelOverride","labelStyle","labelSuffix","_jsx","labelFirst","versionFromOptions","t","value","publishedNewerThanDraft","some","option","a","b","getTime","versionToIsVersionFrom","versionFromComparisonOptions","isVersionTo","alreadyAdded","existingOption","otherOptionsWithSameID","filter","_jsxs","optionWithSameID","index","label","Fragment","undefined","canUpdate","update","versionFromCreatedAt","createdAt","versionFromID","versionToCreatedAt","VersionToCreatedAtLabel","versionToStatus","_status"],"sources":["../../../src/views/Version/index.tsx"],"sourcesContent":["import type {\n DocumentViewServerProps,\n Locale,\n SanitizedCollectionPermission,\n SanitizedGlobalPermission,\n TypeWithVersion,\n} from 'payload'\n\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { getClientSchemaMap } from '@payloadcms/ui/utilities/getClientSchemaMap'\nimport { getSchemaMap } from '@payloadcms/ui/utilities/getSchemaMap'\nimport { notFound } from 'next/navigation.js'\nimport { hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { CompareOption } from './Default/types.js'\n\nimport { DefaultVersionView } from './Default/index.js'\nimport { fetchLatestVersion, fetchVersion, fetchVersions } from './fetchVersions.js'\nimport { RenderDiff } from './RenderFieldsToDiff/index.js'\nimport { getVersionLabel } from './VersionPillLabel/getVersionLabel.js'\nimport { VersionPillLabel } from './VersionPillLabel/VersionPillLabel.js'\n\nexport async function VersionView(props: DocumentViewServerProps) {\n const { hasPublishedDoc, i18n, initPageResult, routeSegments, searchParams } = props\n\n const {\n collectionConfig,\n docID: id,\n globalConfig,\n permissions,\n req,\n req: { payload, payload: { config, config: { localization } } = {}, user } = {},\n } = initPageResult\n\n const versionToID = routeSegments[routeSegments.length - 1]\n\n const collectionSlug = collectionConfig?.slug\n const globalSlug = globalConfig?.slug\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n const localeCodesFromParams = searchParams.localeCodes\n ? JSON.parse(searchParams.localeCodes as string)\n : null\n\n const versionFromIDFromParams = searchParams.versionFrom as string\n\n const modifiedOnly: boolean = searchParams.modifiedOnly === 'false' ? false : true\n\n const docPermissions: SanitizedCollectionPermission | SanitizedGlobalPermission = collectionSlug\n ? permissions.collections[collectionSlug]\n : permissions.globals[globalSlug]\n\n const versionTo = await fetchVersion<{\n _status?: string\n }>({\n id: versionToID,\n collectionSlug,\n depth: 1,\n globalSlug,\n locale: 'all',\n overrideAccess: false,\n req,\n user,\n })\n\n if (!versionTo) {\n return notFound()\n }\n\n const [\n previousVersionResult,\n versionFromResult,\n currentlyPublishedVersion,\n latestDraftVersion,\n previousPublishedVersionResult,\n ] = await Promise.all([\n // Previous version (the one before the versionTo)\n fetchVersions({\n collectionSlug,\n // If versionFromIDFromParams is provided, the previous version is only used in the version comparison dropdown => depth 0 is enough.\n // If it's not provided, this is used as `versionFrom` in the comparison, which expects populated data => depth 1 is needed.\n depth: versionFromIDFromParams ? 0 : 1,\n draft: true,\n globalSlug,\n limit: 1,\n locale: 'all',\n overrideAccess: false,\n parentID: id,\n req,\n sort: '-updatedAt',\n user,\n where: {\n and: [\n {\n updatedAt: {\n less_than: versionTo.updatedAt,\n },\n },\n ],\n },\n }),\n // Version from ID from params\n (versionFromIDFromParams\n ? fetchVersion({\n id: versionFromIDFromParams,\n collectionSlug,\n depth: 1,\n globalSlug,\n locale: 'all',\n overrideAccess: false,\n req,\n user,\n })\n : Promise.resolve(null)) as Promise<null | TypeWithVersion<object>>,\n // Currently published version - do note: currently published != latest published, as an unpublished version can be the latest published\n hasPublishedDoc\n ? fetchLatestVersion({\n collectionSlug,\n depth: 0,\n globalSlug,\n locale: req.locale,\n overrideAccess: false,\n parentID: id,\n req,\n status: 'published',\n user,\n })\n : Promise.resolve(null),\n // Latest draft version\n draftsEnabled\n ? fetchLatestVersion({\n collectionSlug,\n depth: 0,\n globalSlug,\n locale: 'all',\n overrideAccess: false,\n parentID: id,\n req,\n status: 'draft',\n user,\n })\n : Promise.resolve(null),\n // Previous published version\n // Only query for published versions if drafts are enabled (since _status field only exists with drafts)\n draftsEnabled\n ? fetchVersions({\n collectionSlug,\n depth: 0,\n draft: true,\n globalSlug,\n limit: 1,\n locale: 'all',\n overrideAccess: false,\n parentID: id,\n req,\n sort: '-updatedAt',\n user,\n where: {\n and: [\n {\n updatedAt: {\n less_than: versionTo.updatedAt,\n },\n },\n {\n 'version._status': {\n equals: 'published',\n },\n },\n ],\n },\n })\n : Promise.resolve(null),\n ])\n\n const previousVersion: null | TypeWithVersion<object> = previousVersionResult?.docs?.[0] ?? null\n\n const versionFrom =\n versionFromResult ||\n // By default, we'll compare the previous version. => versionFrom = version previous to versionTo\n previousVersion\n\n // Previous published version before the versionTo\n const previousPublishedVersion = previousPublishedVersionResult?.docs?.[0] ?? null\n\n let selectedLocales: string[] = []\n if (localization) {\n let locales: Locale[] = []\n if (localeCodesFromParams) {\n for (const code of localeCodesFromParams) {\n const locale = localization.locales.find((locale) => locale.code === code)\n if (!locale) {\n continue\n }\n locales.push(locale)\n }\n } else {\n locales = localization.locales\n }\n\n if (localization.filterAvailableLocales) {\n locales = (await localization.filterAvailableLocales({ locales, req })) || []\n }\n\n selectedLocales = locales.map((locale) => locale.code)\n }\n\n const schemaMap = getSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const clientSchemaMap = getClientSchemaMap({\n collectionSlug,\n config: getClientConfig({\n config: payload.config,\n i18n,\n importMap: payload.importMap,\n user,\n }),\n globalSlug,\n i18n,\n payload,\n schemaMap,\n })\n const RenderedDiff = RenderDiff({\n clientSchemaMap,\n customDiffComponents: {},\n entitySlug: collectionSlug || globalSlug,\n fields: (collectionConfig || globalConfig)?.fields,\n fieldsPermissions: docPermissions?.fields,\n i18n,\n modifiedOnly,\n parentIndexPath: '',\n parentIsLocalized: false,\n parentPath: '',\n parentSchemaPath: '',\n req,\n selectedLocales,\n versionFromSiblingData: {\n ...versionFrom?.version,\n updatedAt: versionFrom?.updatedAt,\n },\n versionToSiblingData: {\n ...versionTo.version,\n updatedAt: versionTo.updatedAt,\n },\n })\n\n const versionToCreatedAtFormatted = versionTo.updatedAt\n ? formatDate({\n date:\n typeof versionTo.updatedAt === 'string'\n ? new Date(versionTo.updatedAt)\n : (versionTo.updatedAt as Date),\n i18n,\n pattern: config.admin.dateFormat,\n })\n : ''\n\n const formatPill = ({\n doc,\n labelOverride,\n labelStyle,\n labelSuffix,\n }: {\n doc: TypeWithVersion<any>\n labelOverride?: string\n labelStyle?: 'pill' | 'text'\n labelSuffix?: React.ReactNode\n }): React.ReactNode => {\n return (\n <VersionPillLabel\n currentlyPublishedVersion={currentlyPublishedVersion}\n doc={doc}\n key={doc.id}\n labelFirst={true}\n labelOverride={labelOverride}\n labelStyle={labelStyle ?? 'text'}\n labelSuffix={labelSuffix}\n latestDraftVersion={latestDraftVersion}\n />\n )\n }\n\n // SelectComparison Options:\n //\n // Previous version: always, unless doesn't exist. Can be the same as previously published\n // Latest draft: only if no newer published exists (latestDraftVersion)\n // Currently published: always, if exists\n // Previously published: if there is a prior published version older than versionTo\n // Specific Version: only if not already present under other label (= versionFrom)\n\n let versionFromOptions: {\n doc: TypeWithVersion<any>\n labelOverride?: string\n updatedAt: Date\n value: string\n }[] = []\n\n // Previous version\n if (previousVersion?.id) {\n versionFromOptions.push({\n doc: previousVersion,\n labelOverride: i18n.t('version:previousVersion'),\n updatedAt: new Date(previousVersion.updatedAt),\n value: previousVersion.id,\n })\n }\n\n // Latest Draft\n const publishedNewerThanDraft =\n currentlyPublishedVersion?.updatedAt > latestDraftVersion?.updatedAt\n if (latestDraftVersion && !publishedNewerThanDraft) {\n versionFromOptions.push({\n doc: latestDraftVersion,\n updatedAt: new Date(latestDraftVersion.updatedAt),\n value: latestDraftVersion.id,\n })\n }\n\n // Currently Published\n if (currentlyPublishedVersion) {\n versionFromOptions.push({\n doc: currentlyPublishedVersion,\n updatedAt: new Date(currentlyPublishedVersion.updatedAt),\n value: currentlyPublishedVersion.id,\n })\n }\n\n // Previous Published\n if (previousPublishedVersion && currentlyPublishedVersion?.id !== previousPublishedVersion.id) {\n versionFromOptions.push({\n doc: previousPublishedVersion,\n labelOverride: i18n.t('version:previouslyPublished'),\n updatedAt: new Date(previousPublishedVersion.updatedAt),\n value: previousPublishedVersion.id,\n })\n }\n\n // Specific Version\n if (versionFrom?.id && !versionFromOptions.some((option) => option.value === versionFrom.id)) {\n // Only add \"specific version\" if it is not already in the options\n versionFromOptions.push({\n doc: versionFrom,\n labelOverride: i18n.t('version:specificVersion'),\n updatedAt: new Date(versionFrom.updatedAt),\n value: versionFrom.id,\n })\n }\n\n versionFromOptions = versionFromOptions.sort((a, b) => {\n // Sort by updatedAt, newest first\n if (a && b) {\n return b.updatedAt.getTime() - a.updatedAt.getTime()\n }\n return 0\n })\n\n const versionToIsVersionFrom = versionFrom?.id === versionTo.id\n\n const versionFromComparisonOptions: CompareOption[] = []\n\n for (const option of versionFromOptions) {\n const isVersionTo = option.value === versionTo.id\n\n if (isVersionTo && !versionToIsVersionFrom) {\n // Don't offer selecting a versionFrom that is the same as versionTo, unless it's already selected\n continue\n }\n\n const alreadyAdded = versionFromComparisonOptions.some(\n (existingOption) => existingOption.value === option.value,\n )\n if (alreadyAdded) {\n continue\n }\n\n const otherOptionsWithSameID = versionFromOptions.filter(\n (existingOption) => existingOption.value === option.value && existingOption !== option,\n )\n\n // Merge options with same ID to the same option\n const labelSuffix = otherOptionsWithSameID?.length ? (\n <span key={`${option.value}-suffix`}>\n {' ('}\n {otherOptionsWithSameID.map((optionWithSameID, index) => {\n const label =\n optionWithSameID.labelOverride ||\n getVersionLabel({\n currentlyPublishedVersion,\n latestDraftVersion,\n t: i18n.t,\n version: optionWithSameID.doc,\n }).label\n\n return (\n <React.Fragment key={`${optionWithSameID.value}-${index}`}>\n {index > 0 ? ', ' : ''}\n {label}\n </React.Fragment>\n )\n })}\n {')'}\n </span>\n ) : undefined\n\n versionFromComparisonOptions.push({\n label: formatPill({\n doc: option.doc,\n labelOverride: option.labelOverride,\n labelSuffix,\n }),\n value: option.value,\n })\n }\n\n return (\n <DefaultVersionView\n canUpdate={docPermissions?.update}\n modifiedOnly={modifiedOnly}\n RenderedDiff={RenderedDiff}\n selectedLocales={selectedLocales}\n versionFromCreatedAt={versionFrom?.createdAt}\n versionFromID={versionFrom?.id}\n versionFromOptions={versionFromComparisonOptions}\n versionToCreatedAt={versionTo.createdAt}\n versionToCreatedAtFormatted={versionToCreatedAtFormatted}\n VersionToCreatedAtLabel={formatPill({ doc: versionTo, labelStyle: 'pill' })}\n versionToID={versionTo.id}\n versionToStatus={versionTo.version?._status}\n />\n )\n}\n"],"mappings":";AAQA,SAASA,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,SAASC,QAAQ,QAAQ;AACzB,SAASC,gBAAgB,QAAQ;AACjC,OAAOC,KAAA,MAAW;AAIlB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,EAAEC,YAAY,EAAEC,aAAa,QAAQ;AAChE,SAASC,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,eAAeC,YAAYC,KAA8B;EAC9D,MAAM;IAAEC,eAAe;IAAEC,IAAI;IAAEC,cAAc;IAAEC,aAAa;IAAEC;EAAY,CAAE,GAAGL,KAAA;EAE/E,MAAM;IACJM,gBAAgB;IAChBC,KAAA,EAAOC,EAAE;IACTC,YAAY;IACZC,WAAW;IACXC,GAAG;IACHA,GAAA,EAAK;MAAEC,OAAO;MAAEA,OAAA,EAAS;QAAEC,MAAM;QAAEA,MAAA,EAAQ;UAAEC;QAAY;MAAE,CAAE,GAAG,CAAC,CAAC;MAAEC;IAAI,CAAE,GAAG,CAAC;EAAC,CAChF,GAAGZ,cAAA;EAEJ,MAAMa,WAAA,GAAcZ,aAAa,CAACA,aAAA,CAAca,MAAM,GAAG,EAAE;EAE3D,MAAMC,cAAA,GAAiBZ,gBAAA,EAAkBa,IAAA;EACzC,MAAMC,UAAA,GAAaX,YAAA,EAAcU,IAAA;EAEjC,MAAME,aAAA,GAAgB/B,gBAAA,CAAiBgB,gBAAA,IAAoBG,YAAA;EAE3D,MAAMa,qBAAA,GAAwBjB,YAAA,CAAakB,WAAW,GAClDC,IAAA,CAAKC,KAAK,CAACp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Bf,KAAK,IAAIgB,KAAA,EAAO;MAK7D,IACC;OAnBQ,GAAGb,MAAA,CAAOH,KAAK,SAAS,IAqBjCmB,SAAA;IAEJX,4BAAA,CAA6BzC,IAAI,CAAC;MAChCkD,KAAA,EAAO1B,UAAA,CAAW;QAChBC,GAAA,EAAKW,MAAA,CAAOX,GAAG;QACfC,aAAA,EAAeU,MAAA,CAAOV,aAAa;QACnCE;MACF;MACAK,KAAA,EAAOG,MAAA,CAAOH;IAChB;EACF;EAEA,oBACEJ,IAAA,CAAClG,kBAAA;IACC0H,SAAA,EAAWrF,cAAA,EAAgBsF,MAAA;IAC3BvF,YAAA,EAAcA,YAAA;IACduC,YAAA,EAAcA,YAAA;IACdV,eAAA,EAAiBA,eAAA;IACjB2D,oBAAA,EAAsBzF,WAAA,EAAa0F,SAAA;IACnCC,aAAA,EAAe3F,WAAA,EAAanB,EAAA;IAC5BoF,kBAAA,EAAoBU,4BAAA;IACpBiB,kBAAA,EAAoBvF,SAAA,CAAUqF,SAAS;IACvCtC,2BAAA,EAA6BA,2BAAA;IAC7ByC,uBAAA,EAAyBnC,UAAA,CAAW;MAAEC,GAAA,EAAKtD,SAAA;MAAWwD,UAAA,EAAY;IAAO;IACzExE,WAAA,EAAagB,SAAA,CAAUxB,EAAE;IACzBiH,eAAA,EAAiBzF,SAAA,CAAU6C,OAAO,EAAE6C;;AAG1C","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatDate","getClientConfig","getClientSchemaMap","getSchemaMap","notFound","hasDraftsEnabled","React","DefaultVersionView","fetchLatestVersion","fetchVersion","fetchVersions","RenderDiff","getVersionLabel","VersionPillLabel","VersionView","props","hasPublishedDoc","i18n","initPageResult","routeSegments","searchParams","collectionConfig","docID","id","globalConfig","permissions","req","payload","config","localization","user","versionToID","length","collectionSlug","slug","globalSlug","draftsEnabled","userLocale","locale","defaultLocale","localeCodesFromParams","localeCodes","JSON","parse","versionFromIDFromParams","versionFrom","modifiedOnly","docPermissions","collections","globals","versionTo","depth","overrideAccess","previousVersionResult","versionFromResult","currentlyPublishedVersion","latestDraftVersion","previousPublishedVersionResult","Promise","all","draft","limit","parentID","sort","where","and","updatedAt","less_than","resolve","status","equals","previousVersion","docs","previousPublishedVersion","selectedLocales","locales","code","find","push","filterAvailableLocales","map","schemaMap","clientSchemaMap","importMap","RenderedDiff","customDiffComponents","entitySlug","fields","fieldsPermissions","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","versionFromSiblingData","version","versionToSiblingData","versionToCreatedAtFormatted","date","Date","pattern","admin","dateFormat","formatPill","doc","labelOverride","labelStyle","labelSuffix","_jsx","labelFirst","versionFromOptions","t","value","publishedNewerThanDraft","some","option","a","b","getTime","versionToIsVersionFrom","versionFromComparisonOptions","isVersionTo","alreadyAdded","existingOption","otherOptionsWithSameID","filter","_jsxs","optionWithSameID","index","label","currentLocale","Fragment","undefined","canUpdate","update","versionFromCreatedAt","createdAt","versionFromID","versionToCreatedAt","VersionToCreatedAtLabel","versionToStatus","_status"],"sources":["../../../src/views/Version/index.tsx"],"sourcesContent":["import type {\n DocumentViewServerProps,\n Locale,\n SanitizedCollectionPermission,\n SanitizedGlobalPermission,\n TypeWithVersion,\n} from 'payload'\n\nimport { formatDate } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { getClientSchemaMap } from '@payloadcms/ui/utilities/getClientSchemaMap'\nimport { getSchemaMap } from '@payloadcms/ui/utilities/getSchemaMap'\nimport { notFound } from 'next/navigation.js'\nimport { hasDraftsEnabled } from 'payload/shared'\nimport React from 'react'\n\nimport type { CompareOption } from './Default/types.js'\n\nimport { DefaultVersionView } from './Default/index.js'\nimport { fetchLatestVersion, fetchVersion, fetchVersions } from './fetchVersions.js'\nimport { RenderDiff } from './RenderFieldsToDiff/index.js'\nimport { getVersionLabel } from './VersionPillLabel/getVersionLabel.js'\nimport { VersionPillLabel } from './VersionPillLabel/VersionPillLabel.js'\n\nexport async function VersionView(props: DocumentViewServerProps) {\n const { hasPublishedDoc, i18n, initPageResult, routeSegments, searchParams } = props\n\n const {\n collectionConfig,\n docID: id,\n globalConfig,\n permissions,\n req,\n req: { payload, payload: { config, config: { localization } } = {}, user } = {},\n } = initPageResult\n\n const versionToID = routeSegments[routeSegments.length - 1]\n\n const collectionSlug = collectionConfig?.slug\n const globalSlug = globalConfig?.slug\n\n const draftsEnabled = hasDraftsEnabled(collectionConfig || globalConfig)\n\n // Resolve user's current locale for version label comparison (not 'all')\n const userLocale =\n (searchParams.locale as string) ||\n (req.locale !== 'all' ? req.locale : localization && localization.defaultLocale)\n\n const localeCodesFromParams = searchParams.localeCodes\n ? JSON.parse(searchParams.localeCodes as string)\n : null\n\n const versionFromIDFromParams = searchParams.versionFrom as string\n\n const modifiedOnly: boolean = searchParams.modifiedOnly === 'false' ? false : true\n\n const docPermissions: SanitizedCollectionPermission | SanitizedGlobalPermission = collectionSlug\n ? permissions.collections[collectionSlug]\n : permissions.globals[globalSlug]\n\n const versionTo = await fetchVersion<{\n _status?: string\n }>({\n id: versionToID,\n collectionSlug,\n depth: 1,\n globalSlug,\n locale: 'all',\n overrideAccess: false,\n req,\n user,\n })\n\n if (!versionTo) {\n return notFound()\n }\n\n const [\n previousVersionResult,\n versionFromResult,\n currentlyPublishedVersion,\n latestDraftVersion,\n previousPublishedVersionResult,\n ] = await Promise.all([\n // Previous version (the one before the versionTo)\n fetchVersions({\n collectionSlug,\n // If versionFromIDFromParams is provided, the previous version is only used in the version comparison dropdown => depth 0 is enough.\n // If it's not provided, this is used as `versionFrom` in the comparison, which expects populated data => depth 1 is needed.\n depth: versionFromIDFromParams ? 0 : 1,\n draft: true,\n globalSlug,\n limit: 1,\n locale: 'all',\n overrideAccess: false,\n parentID: id,\n req,\n sort: '-updatedAt',\n user,\n where: {\n and: [\n {\n updatedAt: {\n less_than: versionTo.updatedAt,\n },\n },\n ],\n },\n }),\n // Version from ID from params\n (versionFromIDFromParams\n ? fetchVersion({\n id: versionFromIDFromParams,\n collectionSlug,\n depth: 1,\n globalSlug,\n locale: 'all',\n overrideAccess: false,\n req,\n user,\n })\n : Promise.resolve(null)) as Promise<null | TypeWithVersion<object>>,\n // Currently published version - do note: currently published != latest published, as an unpublished version can be the latest published\n hasPublishedDoc\n ? fetchLatestVersion({\n collectionSlug,\n depth: 0,\n globalSlug,\n locale: req.locale,\n overrideAccess: false,\n parentID: id,\n req,\n status: 'published',\n user,\n })\n : Promise.resolve(null),\n // Latest draft version\n draftsEnabled\n ? fetchLatestVersion({\n collectionSlug,\n depth: 0,\n globalSlug,\n locale: 'all',\n overrideAccess: false,\n parentID: id,\n req,\n status: 'draft',\n user,\n })\n : Promise.resolve(null),\n // Previous published version\n // Only query for published versions if drafts are enabled (since _status field only exists with drafts)\n draftsEnabled\n ? fetchVersions({\n collectionSlug,\n depth: 0,\n draft: true,\n globalSlug,\n limit: 1,\n locale: 'all',\n overrideAccess: false,\n parentID: id,\n req,\n sort: '-updatedAt',\n user,\n where: {\n and: [\n {\n updatedAt: {\n less_than: versionTo.updatedAt,\n },\n },\n {\n 'version._status': {\n equals: 'published',\n },\n },\n ],\n },\n })\n : Promise.resolve(null),\n ])\n\n const previousVersion: null | TypeWithVersion<object> = previousVersionResult?.docs?.[0] ?? null\n\n const versionFrom =\n versionFromResult ||\n // By default, we'll compare the previous version. => versionFrom = version previous to versionTo\n previousVersion\n\n // Previous published version before the versionTo\n const previousPublishedVersion = previousPublishedVersionResult?.docs?.[0] ?? null\n\n let selectedLocales: string[] = []\n if (localization) {\n let locales: Locale[] = []\n if (localeCodesFromParams) {\n for (const code of localeCodesFromParams) {\n const locale = localization.locales.find((locale) => locale.code === code)\n if (!locale) {\n continue\n }\n locales.push(locale)\n }\n } else {\n locales = localization.locales\n }\n\n if (localization.filterAvailableLocales) {\n locales = (await localization.filterAvailableLocales({ locales, req })) || []\n }\n\n selectedLocales = locales.map((locale) => locale.code)\n }\n\n const schemaMap = getSchemaMap({\n collectionSlug,\n config,\n globalSlug,\n i18n,\n })\n\n const clientSchemaMap = getClientSchemaMap({\n collectionSlug,\n config: getClientConfig({\n config: payload.config,\n i18n,\n importMap: payload.importMap,\n user,\n }),\n globalSlug,\n i18n,\n payload,\n schemaMap,\n })\n const RenderedDiff = RenderDiff({\n clientSchemaMap,\n customDiffComponents: {},\n entitySlug: collectionSlug || globalSlug,\n fields: (collectionConfig || globalConfig)?.fields,\n fieldsPermissions: docPermissions?.fields,\n i18n,\n modifiedOnly,\n parentIndexPath: '',\n parentIsLocalized: false,\n parentPath: '',\n parentSchemaPath: '',\n req,\n selectedLocales,\n versionFromSiblingData: {\n ...versionFrom?.version,\n updatedAt: versionFrom?.updatedAt,\n },\n versionToSiblingData: {\n ...versionTo.version,\n updatedAt: versionTo.updatedAt,\n },\n })\n\n const versionToCreatedAtFormatted = versionTo.updatedAt\n ? formatDate({\n date:\n typeof versionTo.updatedAt === 'string'\n ? new Date(versionTo.updatedAt)\n : (versionTo.updatedAt as Date),\n i18n,\n pattern: config.admin.dateFormat,\n })\n : ''\n\n const formatPill = ({\n doc,\n labelOverride,\n labelStyle,\n labelSuffix,\n }: {\n doc: TypeWithVersion<any>\n labelOverride?: string\n labelStyle?: 'pill' | 'text'\n labelSuffix?: React.ReactNode\n }): React.ReactNode => {\n return (\n <VersionPillLabel\n currentlyPublishedVersion={currentlyPublishedVersion}\n doc={doc}\n key={doc.id}\n labelFirst={true}\n labelOverride={labelOverride}\n labelStyle={labelStyle ?? 'text'}\n labelSuffix={labelSuffix}\n latestDraftVersion={latestDraftVersion}\n />\n )\n }\n\n // SelectComparison Options:\n //\n // Previous version: always, unless doesn't exist. Can be the same as previously published\n // Latest draft: only if no newer published exists (latestDraftVersion)\n // Currently published: always, if exists\n // Previously published: if there is a prior published version older than versionTo\n // Specific Version: only if not already present under other label (= versionFrom)\n\n let versionFromOptions: {\n doc: TypeWithVersion<any>\n labelOverride?: string\n updatedAt: Date\n value: string\n }[] = []\n\n // Previous version\n if (previousVersion?.id) {\n versionFromOptions.push({\n doc: previousVersion,\n labelOverride: i18n.t('version:previousVersion'),\n updatedAt: new Date(previousVersion.updatedAt),\n value: previousVersion.id,\n })\n }\n\n // Latest Draft\n const publishedNewerThanDraft =\n currentlyPublishedVersion?.updatedAt > latestDraftVersion?.updatedAt\n if (latestDraftVersion && !publishedNewerThanDraft) {\n versionFromOptions.push({\n doc: latestDraftVersion,\n updatedAt: new Date(latestDraftVersion.updatedAt),\n value: latestDraftVersion.id,\n })\n }\n\n // Currently Published\n if (currentlyPublishedVersion) {\n versionFromOptions.push({\n doc: currentlyPublishedVersion,\n updatedAt: new Date(currentlyPublishedVersion.updatedAt),\n value: currentlyPublishedVersion.id,\n })\n }\n\n // Previous Published\n if (previousPublishedVersion && currentlyPublishedVersion?.id !== previousPublishedVersion.id) {\n versionFromOptions.push({\n doc: previousPublishedVersion,\n labelOverride: i18n.t('version:previouslyPublished'),\n updatedAt: new Date(previousPublishedVersion.updatedAt),\n value: previousPublishedVersion.id,\n })\n }\n\n // Specific Version\n if (versionFrom?.id && !versionFromOptions.some((option) => option.value === versionFrom.id)) {\n // Only add \"specific version\" if it is not already in the options\n versionFromOptions.push({\n doc: versionFrom,\n labelOverride: i18n.t('version:specificVersion'),\n updatedAt: new Date(versionFrom.updatedAt),\n value: versionFrom.id,\n })\n }\n\n versionFromOptions = versionFromOptions.sort((a, b) => {\n // Sort by updatedAt, newest first\n if (a && b) {\n return b.updatedAt.getTime() - a.updatedAt.getTime()\n }\n return 0\n })\n\n const versionToIsVersionFrom = versionFrom?.id === versionTo.id\n\n const versionFromComparisonOptions: CompareOption[] = []\n\n for (const option of versionFromOptions) {\n const isVersionTo = option.value === versionTo.id\n\n if (isVersionTo && !versionToIsVersionFrom) {\n // Don't offer selecting a versionFrom that is the same as versionTo, unless it's already selected\n continue\n }\n\n const alreadyAdded = versionFromComparisonOptions.some(\n (existingOption) => existingOption.value === option.value,\n )\n if (alreadyAdded) {\n continue\n }\n\n const otherOptionsWithSameID = versionFromOptions.filter(\n (existingOption) => existingOption.value === option.value && existingOption !== option,\n )\n\n // Merge options with same ID to the same option\n const labelSuffix = otherOptionsWithSameID?.length ? (\n <span key={`${option.value}-suffix`}>\n {' ('}\n {otherOptionsWithSameID.map((optionWithSameID, index) => {\n const label =\n optionWithSameID.labelOverride ||\n getVersionLabel({\n currentLocale: userLocale,\n currentlyPublishedVersion,\n latestDraftVersion,\n t: i18n.t,\n version: optionWithSameID.doc,\n }).label\n\n return (\n <React.Fragment key={`${optionWithSameID.value}-${index}`}>\n {index > 0 ? ', ' : ''}\n {label}\n </React.Fragment>\n )\n })}\n {')'}\n </span>\n ) : undefined\n\n versionFromComparisonOptions.push({\n label: formatPill({\n doc: option.doc,\n labelOverride: option.labelOverride,\n labelSuffix,\n }),\n value: option.value,\n })\n }\n\n return (\n <DefaultVersionView\n canUpdate={docPermissions?.update}\n modifiedOnly={modifiedOnly}\n RenderedDiff={RenderedDiff}\n selectedLocales={selectedLocales}\n versionFromCreatedAt={versionFrom?.createdAt}\n versionFromID={versionFrom?.id}\n versionFromOptions={versionFromComparisonOptions}\n versionToCreatedAt={versionTo.createdAt}\n versionToCreatedAtFormatted={versionToCreatedAtFormatted}\n VersionToCreatedAtLabel={formatPill({ doc: versionTo, labelStyle: 'pill' })}\n versionToID={versionTo.id}\n versionToStatus={versionTo.version?._status}\n />\n )\n}\n"],"mappings":";AAQA,SAASA,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,YAAY,QAAQ;AAC7B,SAASC,QAAQ,QAAQ;AACzB,SAASC,gBAAgB,QAAQ;AACjC,OAAOC,KAAA,MAAW;AAIlB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,EAAEC,YAAY,EAAEC,aAAa,QAAQ;AAChE,SAASC,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AAEjC,OAAO,eAAeC,YAAYC,KAA8B;E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IACC6H,SAAA,EAAWrF,cAAA,EAAgBsF,MAAA;IAC3BvF,YAAA,EAAcA,YAAA;IACdsC,YAAA,EAAcA,YAAA;IACdV,eAAA,EAAiBA,eAAA;IACjB4D,oBAAA,EAAsBzF,WAAA,EAAa0F,SAAA;IACnCC,aAAA,EAAe3F,WAAA,EAAatB,EAAA;IAC5BsF,kBAAA,EAAoBU,4BAAA;IACpBkB,kBAAA,EAAoBvF,SAAA,CAAUqF,SAAS;IACvCvC,2BAAA,EAA6BA,2BAAA;IAC7B0C,uBAAA,EAAyBpC,UAAA,CAAW;MAAEC,GAAA,EAAKrD,SAAA;MAAWuD,UAAA,EAAY;IAAO;IACzE1E,WAAA,EAAamB,SAAA,CAAU3B,EAAE;IACzBoH,eAAA,EAAiBzF,SAAA,CAAU4C,OAAO,EAAE8C;;AAG1C","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.74.0-
|
|
3
|
+
"version": "3.74.0-internal.03ca72a",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"qs-esm": "7.0.2",
|
|
100
100
|
"sass": "1.77.4",
|
|
101
101
|
"uuid": "10.0.0",
|
|
102
|
-
"@payloadcms/graphql": "3.74.0-
|
|
103
|
-
"@payloadcms/translations": "3.74.0-
|
|
104
|
-
"@payloadcms/ui": "3.74.0-
|
|
102
|
+
"@payloadcms/graphql": "3.74.0-internal.03ca72a",
|
|
103
|
+
"@payloadcms/translations": "3.74.0-internal.03ca72a",
|
|
104
|
+
"@payloadcms/ui": "3.74.0-internal.03ca72a"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@babel/cli": "7.27.2",
|
|
@@ -119,12 +119,12 @@
|
|
|
119
119
|
"esbuild-sass-plugin": "3.3.1",
|
|
120
120
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
121
121
|
"@payloadcms/eslint-config": "3.28.0",
|
|
122
|
-
"payload": "3.74.0-
|
|
122
|
+
"payload": "3.74.0-internal.03ca72a"
|
|
123
123
|
},
|
|
124
124
|
"peerDependencies": {
|
|
125
125
|
"graphql": "^16.8.1",
|
|
126
126
|
"next": "^15.4.10 || >=16.1.1-canary.35 <16.2.0 || ^16.2.0",
|
|
127
|
-
"payload": "3.74.0-
|
|
127
|
+
"payload": "3.74.0-internal.03ca72a"
|
|
128
128
|
},
|
|
129
129
|
"engines": {
|
|
130
130
|
"node": "^18.20.2 || >=20.9.0"
|