@payloadcms/ui 4.0.0-canary.32 → 4.0.0-canary.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/APIKeyInput/index.d.ts +2 -0
- package/dist/elements/APIKeyInput/index.d.ts.map +1 -1
- package/dist/elements/APIKeyInput/index.js +27 -29
- package/dist/elements/APIKeyInput/index.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/createFormData.d.ts +1 -1
- package/dist/elements/BulkUpload/FormsManager/createFormData.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/createFormData.js +7 -3
- package/dist/elements/BulkUpload/FormsManager/createFormData.js.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
- package/dist/elements/BulkUpload/FormsManager/index.js +4 -2
- package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts +1 -0
- package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js +3 -2
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.d.ts +1 -0
- package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.js +5 -3
- package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/index.d.ts +1 -0
- package/dist/elements/DocumentHeader/index.d.ts.map +1 -1
- package/dist/elements/DocumentHeader/index.js +4 -2
- package/dist/elements/DocumentHeader/index.js.map +1 -1
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js +3 -2
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js.map +1 -1
- package/dist/elements/QueryPresets/QueryPresetBar/index.d.ts.map +1 -1
- package/dist/elements/QueryPresets/QueryPresetBar/index.js +14 -1
- package/dist/elements/QueryPresets/QueryPresetBar/index.js.map +1 -1
- package/dist/forms/Form/context.d.ts +3 -1
- package/dist/forms/Form/context.d.ts.map +1 -1
- package/dist/forms/Form/context.js +3 -1
- package/dist/forms/Form/context.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +13 -4
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +3 -2
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/serverFunctions/mergeAllowedFieldOverrides.d.ts +12 -0
- package/dist/forms/fieldSchemasToFormState/serverFunctions/mergeAllowedFieldOverrides.d.ts.map +1 -0
- package/dist/forms/fieldSchemasToFormState/serverFunctions/mergeAllowedFieldOverrides.js +42 -0
- package/dist/forms/fieldSchemasToFormState/serverFunctions/mergeAllowedFieldOverrides.js.map +1 -0
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.d.ts +8 -6
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js +22 -9
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.spec.js +150 -0
- package/dist/forms/fieldSchemasToFormState/serverFunctions/renderFieldServerFn.spec.js.map +1 -0
- package/dist/forms/fieldSchemasToFormState/types.d.ts +1 -0
- package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.js.map +1 -1
- package/dist/layouts/Root/index.js +6 -5
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/providers/LivePreview/index.d.ts.map +1 -1
- package/dist/providers/LivePreview/index.js +13 -6
- package/dist/providers/LivePreview/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +6 -2
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/formatAbsoluteURL.d.ts +1 -1
- package/dist/utilities/formatAbsoluteURL.d.ts.map +1 -1
- package/dist/utilities/formatAbsoluteURL.js +18 -8
- package/dist/utilities/formatAbsoluteURL.js.map +1 -1
- package/dist/utilities/formatAbsoluteURL.spec.js +27 -0
- package/dist/utilities/formatAbsoluteURL.spec.js.map +1 -0
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +4 -2
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/initReq.d.ts.map +1 -1
- package/dist/utilities/initReq.js +40 -5
- package/dist/utilities/initReq.js.map +1 -1
- package/dist/utilities/initReq.spec.js +226 -0
- package/dist/utilities/initReq.spec.js.map +1 -0
- package/dist/utilities/isAbsoluteURL.d.ts +3 -0
- package/dist/utilities/isAbsoluteURL.d.ts.map +1 -0
- package/dist/utilities/isAbsoluteURL.js +15 -0
- package/dist/utilities/isAbsoluteURL.js.map +1 -0
- package/dist/utilities/isAbsoluteURL.spec.js +11 -0
- package/dist/utilities/isAbsoluteURL.spec.js.map +1 -0
- package/dist/utilities/isHttpURL.d.ts +3 -0
- package/dist/utilities/isHttpURL.d.ts.map +1 -0
- package/dist/utilities/isHttpURL.js +12 -0
- package/dist/utilities/isHttpURL.js.map +1 -0
- package/dist/utilities/isHttpURL.spec.js +25 -0
- package/dist/utilities/isHttpURL.spec.js.map +1 -0
- package/dist/utilities/isPublicAdminRoute.d.ts.map +1 -1
- package/dist/utilities/isPublicAdminRoute.js +9 -6
- package/dist/utilities/isPublicAdminRoute.js.map +1 -1
- package/dist/utilities/isPublicAdminRoute.spec.js +34 -0
- package/dist/utilities/isPublicAdminRoute.spec.js.map +1 -0
- package/dist/utilities/schedulePublishHandler.d.ts.map +1 -1
- package/dist/utilities/schedulePublishHandler.js +4 -1
- package/dist/utilities/schedulePublishHandler.js.map +1 -1
- package/dist/views/Account/index.d.ts +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +8 -5
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.js +1 -0
- package/dist/views/Dashboard/Default/ModularDashboard/index.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js +3 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +2 -0
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/Dashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/index.js +2 -3
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Document/handleServerFunction.d.ts.map +1 -1
- package/dist/views/Document/handleServerFunction.js +2 -0
- package/dist/views/Document/handleServerFunction.js.map +1 -1
- package/dist/views/Document/index.d.ts +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +9 -4
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Document/renderDocumentSlots.d.ts +1 -0
- package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -1
- package/dist/views/Document/renderDocumentSlots.js +7 -4
- package/dist/views/Document/renderDocumentSlots.js.map +1 -1
- package/dist/views/Edit/Auth/APIKey.d.ts +1 -1
- package/dist/views/Edit/Auth/APIKey.d.ts.map +1 -1
- package/dist/views/Edit/Auth/APIKey.js +233 -59
- package/dist/views/Edit/Auth/APIKey.js.map +1 -1
- package/dist/views/Edit/Auth/APIKeyGenerationModal.d.ts +12 -0
- package/dist/views/Edit/Auth/APIKeyGenerationModal.d.ts.map +1 -0
- package/dist/views/Edit/Auth/APIKeyGenerationModal.js +117 -0
- package/dist/views/Edit/Auth/APIKeyGenerationModal.js.map +1 -0
- package/dist/views/Edit/Auth/index.css +91 -0
- package/dist/views/Edit/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Auth/index.js +10 -28
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/dist/views/Edit/Auth/types.d.ts +3 -1
- package/dist/views/Edit/Auth/types.d.ts.map +1 -1
- package/dist/views/Edit/Auth/types.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.css +14 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +209 -161
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +2 -11
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/handleServerFunction.d.ts.map +1 -1
- package/dist/views/List/handleServerFunction.js +3 -1
- package/dist/views/List/handleServerFunction.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +2 -1
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/NotFound/page.d.ts.map +1 -1
- package/dist/views/NotFound/page.js +4 -3
- package/dist/views/NotFound/page.js.map +1 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +5 -3
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Verify/index.d.ts +1 -1
- package/dist/views/Verify/index.d.ts.map +1 -1
- package/dist/views/Verify/index.js +4 -4
- package/dist/views/Verify/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initReq.spec.js","names":["beforeEach","describe","expect","it","vi","mocks","hoisted","accessContexts","accessUser","applyUserReadAccess","fn","cacheStores","Map","executeAuthStrategies","user","collection","id","role","mock","initI18n","fallbackLanguage","language","t","key","translations","createLocalReq","options","payload","request","req","context","headers","Headers","locale","pathname","urlSuffix","query","responseHeaders","config","admin","getAccessResults","push","name","getPayload","collections","users","auth","depth","slug","i18n","supportedLanguages","en","logger","error","getRequestLanguage","parseCookies","getRequestLocale","code","selectiveCache","namespace","get","factory","args","entries","set","cached","find","entry","length","every","arg","i","value","initReq","mockReset","mockImplementation","clear","mockResolvedValue","first","configPromise","importMap","overrides","serverAdapter","getHeaders","second","toHaveBeenCalledOnce","toHaveBeenCalledTimes","toHaveProperty","toMatchObject","not","toEqual","mockRejectedValue","Error","result","toBeNull","toBe","toHaveBeenCalled"],"sources":["../../src/utilities/initReq.spec.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { beforeEach, describe, expect, it, vi } from 'vitest'\n\nconst mocks = vi.hoisted(() => ({\n accessContexts: [] as unknown[],\n accessUser: null as PayloadRequest['user'],\n applyUserReadAccess: vi.fn(),\n cacheStores: new Map<string, Array<{ args: unknown[]; value: object }>>(),\n executeAuthStrategies: vi.fn(),\n user: {\n collection: 'users',\n id: 'user-id',\n role: 'admin',\n } as PayloadRequest['user'],\n}))\n\nvi.mock('@payloadcms/translations', () => ({\n initI18n: vi.fn(async () => ({\n fallbackLanguage: 'en',\n language: 'en',\n t: (key: string) => key,\n translations: {},\n })),\n}))\n\nvi.mock('payload', () => ({\n createLocalReq: vi.fn(async (options, payload) => {\n const request = options.req ?? {}\n const user = options.user ?? request.user ?? null\n\n return {\n ...request,\n context: options.context ?? request.context ?? {},\n headers: request.headers ?? new Headers(),\n locale: options.locale ?? request.locale ?? 'en',\n pathname: options.urlSuffix,\n payload,\n query: request.query ?? {},\n responseHeaders: request.responseHeaders ?? new Headers(),\n user: user && !user.collection ? { ...user, collection: payload.config.admin.user } : user,\n }\n }),\n executeAuthStrategies: mocks.executeAuthStrategies,\n getAccessResults: vi.fn(async ({ req }: { req: PayloadRequest }) => {\n mocks.accessContexts.push(req.context.name)\n mocks.accessUser = req.user\n return {}\n }),\n getPayload: vi.fn(async () => ({\n collections: {\n users: {\n config: {\n auth: { depth: 1 },\n slug: 'users',\n },\n },\n },\n config: {\n admin: { user: 'users' },\n i18n: {\n fallbackLanguage: 'en',\n supportedLanguages: { en: {} },\n translations: {},\n },\n },\n logger: { error: vi.fn() },\n })),\n getRequestLanguage: vi.fn(() => 'en'),\n parseCookies: vi.fn(() => new Map()),\n}))\n\nvi.mock('payload/internal', () => ({\n applyUserReadAccess: mocks.applyUserReadAccess,\n}))\n\nvi.mock('./getRequestLocale.js', () => ({\n getRequestLocale: vi.fn(async ({ req }: { req: PayloadRequest }) => ({\n code: req.locale,\n })),\n}))\n\nvi.mock('./selectiveCache.js', () => ({\n selectiveCache: (namespace: string) => ({\n get: async (factory: () => Promise<object>, ...args: unknown[]) => {\n let entries = mocks.cacheStores.get(namespace)\n\n if (!entries) {\n entries = []\n mocks.cacheStores.set(namespace, entries)\n }\n\n const cached = entries.find(\n (entry) =>\n entry.args.length === args.length && entry.args.every((arg, i) => arg === args[i]),\n )\n\n if (cached) {\n return cached.value\n }\n\n const value = await factory()\n entries.push({ args, value })\n\n return value\n },\n }),\n}))\n\nimport { initReq } from './initReq.js'\n\ndescribe('initReq', () => {\n beforeEach(() => {\n mocks.accessContexts = []\n mocks.accessUser = null\n mocks.applyUserReadAccess.mockReset()\n mocks.applyUserReadAccess.mockImplementation(async ({ req, user }) => ({\n collection: user.collection,\n id: user.id,\n name: req.context.name,\n }))\n mocks.cacheStores.clear()\n mocks.executeAuthStrategies.mockReset()\n mocks.executeAuthStrategies.mockResolvedValue({ user: mocks.user })\n })\n\n it('should keep the complete req.user and filter the user for each response', async () => {\n const first = await initReq({\n configPromise: {} as never,\n importMap: {},\n key: 'response',\n overrides: { context: { name: 'First' } },\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n const second = await initReq({\n configPromise: {} as never,\n importMap: {},\n key: 'response',\n overrides: { context: { name: 'Second' } },\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n\n expect(mocks.executeAuthStrategies).toHaveBeenCalledOnce()\n expect(mocks.applyUserReadAccess).toHaveBeenCalledTimes(2)\n expect(first.req.user).toHaveProperty('role', 'admin')\n expect(second.req.user).toHaveProperty('role', 'admin')\n expect(first.user).toMatchObject({ name: 'First' })\n expect(second.user).toMatchObject({ name: 'Second' })\n expect(first.user).not.toHaveProperty('role')\n expect(mocks.accessUser).toHaveProperty('role', 'admin')\n expect(mocks.accessContexts).toEqual(['First', 'Second'])\n })\n\n it('should use anonymous access when user read access fails', async () => {\n mocks.applyUserReadAccess.mockRejectedValue(new Error('read access failed'))\n\n const result = await initReq({\n configPromise: {} as never,\n importMap: {},\n key: 'failure',\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n\n expect(result.req.user).toBeNull()\n expect(result.user).toBeNull()\n expect(mocks.accessUser).toBeNull()\n })\n\n it('should preserve an explicit req.user override', async () => {\n const user = { id: 'override-user' }\n\n const result = await initReq({\n configPromise: {} as never,\n importMap: {},\n key: 'override',\n overrides: { req: { user } as never },\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n\n expect(result.req.user).toMatchObject({ collection: 'users', id: 'override-user' })\n expect(result.user).toBe(result.req.user)\n expect(mocks.applyUserReadAccess).not.toHaveBeenCalled()\n })\n\n it('should preserve an explicit null user override', async () => {\n const result = await initReq({\n configPromise: {} as never,\n importMap: {},\n key: 'anonymous',\n overrides: { user: null } as never,\n serverAdapter: { getHeaders: async () => new Headers() } as never,\n })\n\n expect(result.req.user).toBeNull()\n expect(result.user).toBeNull()\n expect(mocks.applyUserReadAccess).not.toHaveBeenCalled()\n })\n})\n"],"mappings":"AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ;AAErD,MA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I,CAACF,MAAA,CAAOhE,GAAG,CAACf,IAAI;IACxCZ,MAAA,CAAOG,KAAA,CAAMI,mBAAmB,EAAEgF,GAAG,CAACO,gBAAgB;EACxD;EAEA7F,EAAA,CAAG,kDAAkD;IACnD,MAAM0F,MAAA,GAAS,MAAMpB,OAAA,CAAQ;MAC3BM,aAAA,EAAe,CAAC;MAChBC,SAAA,EAAW,CAAC;MACZzD,GAAA,EAAK;MACL0D,SAAA,EAAW;QAAEnE,IAAA,EAAM;MAAK;MACxBoE,aAAA,EAAe;QAAEC,UAAA,EAAY,MAAAA,CAAA,KAAY,IAAInD,OAAA;MAAU;IACzD;IAEA9B,MAAA,CAAO2F,MAAA,CAAOhE,GAAG,CAACf,IAAI,EAAEgF,QAAQ;IAChC5F,MAAA,CAAO2F,MAAA,CAAO/E,IAAI,EAAEgF,QAAQ;IAC5B5F,MAAA,CAAOG,KAAA,CAAMI,mBAAmB,EAAEgF,GAAG,CAACO,gBAAgB;EACxD;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAbsoluteURL.d.ts","sourceRoot":"","sources":["../../src/utilities/isAbsoluteURL.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,aAAa,iBAAkB,MAAM,GAAG,GAAG,KAAG,OAe1D,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Checks whether a URL is absolute or relative. */export const isAbsoluteURL = incomingURL => {
|
|
2
|
+
if (!incomingURL) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (incomingURL instanceof URL) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
new URL(incomingURL);
|
|
10
|
+
return true;
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=isAbsoluteURL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAbsoluteURL.js","names":["isAbsoluteURL","incomingURL","URL"],"sources":["../../src/utilities/isAbsoluteURL.ts"],"sourcesContent":["/** Checks whether a URL is absolute or relative. */\nexport const isAbsoluteURL = (incomingURL?: string | URL): boolean => {\n if (!incomingURL) {\n return false\n }\n\n if (incomingURL instanceof URL) {\n return true\n }\n\n try {\n new URL(incomingURL)\n return true\n } catch {\n return false\n }\n}\n"],"mappings":"AAAA,oDACA,OAAO,MAAMA,aAAA,GAAiBC,WAAA;EAC5B,IAAI,CAACA,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAIA,WAAA,YAAuBC,GAAA,EAAK;IAC9B,OAAO;EACT;EAEA,IAAI;IACF,IAAIA,GAAA,CAAID,WAAA;IACR,OAAO;EACT,EAAE,MAAM;IACN,OAAO;EACT;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { isAbsoluteURL } from './isAbsoluteURL.js';
|
|
3
|
+
describe('isAbsoluteURL', () => {
|
|
4
|
+
it.each(['http://example.com', 'https://example.com/preview', 'mailto:editor@example.com', 'file:///preview.html', new URL('https://example.com/preview')])('should accept absolute URL %s', input => {
|
|
5
|
+
expect(isAbsoluteURL(input)).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
it.each([undefined, '', '/preview', '../preview', 'preview?draft=true', '?draft=true', '#preview', '//example.com/preview', 'https://', 'https://[invalid'])('should reject relative, absent, or invalid URL %s', input => {
|
|
8
|
+
expect(isAbsoluteURL(input)).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=isAbsoluteURL.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAbsoluteURL.spec.js","names":["describe","expect","it","isAbsoluteURL","each","URL","input","toBe","undefined"],"sources":["../../src/utilities/isAbsoluteURL.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { isAbsoluteURL } from './isAbsoluteURL.js'\n\ndescribe('isAbsoluteURL', () => {\n it.each([\n 'http://example.com',\n 'https://example.com/preview',\n 'mailto:editor@example.com',\n 'file:///preview.html',\n new URL('https://example.com/preview'),\n ])('should accept absolute URL %s', (input) => {\n expect(isAbsoluteURL(input)).toBe(true)\n })\n\n it.each([\n undefined,\n '',\n '/preview',\n '../preview',\n 'preview?draft=true',\n '?draft=true',\n '#preview',\n '//example.com/preview',\n 'https://',\n 'https://[invalid',\n ])('should reject relative, absent, or invalid URL %s', (input) => {\n expect(isAbsoluteURL(input)).toBe(false)\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,aAAa,QAAQ;AAE9BH,QAAA,CAAS,iBAAiB;EACxBE,EAAA,CAAGE,IAAI,CAAC,CACN,sBACA,+BACA,6BACA,wBACA,IAAIC,GAAA,CAAI,+BACT,EAAE,iCAAkCC,KAAA;IACnCL,MAAA,CAAOE,aAAA,CAAcG,KAAA,GAAQC,IAAI,CAAC;EACpC;EAEAL,EAAA,CAAGE,IAAI,CAAC,CACNI,SAAA,EACA,IACA,YACA,cACA,sBACA,eACA,YACA,yBACA,YACA,mBACD,EAAE,qDAAsDF,KAAA;IACvDL,MAAA,CAAOE,aAAA,CAAcG,KAAA,GAAQC,IAAI,CAAC;EACpC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isHttpURL.d.ts","sourceRoot":"","sources":["../../src/utilities/isHttpURL.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,eAAO,MAAM,SAAS,iBAAkB,MAAM,GAAG,GAAG,KAAG,OAatD,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Allows only HTTP(S) URLs, e.g. `http://` or `https://`. */export const isHttpURL = incomingURL => {
|
|
2
|
+
if (!incomingURL) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
const url = typeof incomingURL === 'string' ? new URL(incomingURL, window.location.origin) : incomingURL;
|
|
7
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=isHttpURL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isHttpURL.js","names":["isHttpURL","incomingURL","url","URL","window","location","origin","protocol"],"sources":["../../src/utilities/isHttpURL.ts"],"sourcesContent":["/** Allows only HTTP(S) URLs, e.g. `http://` or `https://`. */\nexport const isHttpURL = (incomingURL?: string | URL): boolean => {\n if (!incomingURL) {\n return false\n }\n\n try {\n const url =\n typeof incomingURL === 'string' ? new URL(incomingURL, window.location.origin) : incomingURL\n\n return url.protocol === 'http:' || url.protocol === 'https:'\n } catch {\n return false\n }\n}\n"],"mappings":"AAAA,8DACA,OAAO,MAAMA,SAAA,GAAaC,WAAA;EACxB,IAAI,CAACA,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAI;IACF,MAAMC,GAAA,GACJ,OAAOD,WAAA,KAAgB,WAAW,IAAIE,GAAA,CAAIF,WAAA,EAAaG,MAAA,CAAOC,QAAQ,CAACC,MAAM,IAAIL,WAAA;IAEnF,OAAOC,GAAA,CAAIK,QAAQ,KAAK,WAAWL,GAAA,CAAIK,QAAQ,KAAK;EACtD,EAAE,MAAM;IACN,OAAO;EACT;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { isHttpURL } from './isHttpURL.js';
|
|
3
|
+
describe('isHttpURL', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
vi.stubGlobal('window', {
|
|
6
|
+
location: {
|
|
7
|
+
origin: 'https://admin.example.com'
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
vi.unstubAllGlobals();
|
|
13
|
+
});
|
|
14
|
+
it.each([['https://preview.example.com', true], ['mailto:editor@example.com', false]])('should validate parsed URL %s without the client environment', (input, expected) => {
|
|
15
|
+
vi.stubGlobal('window', undefined);
|
|
16
|
+
expect(isHttpURL(new URL(input))).toBe(expected);
|
|
17
|
+
});
|
|
18
|
+
it.each(['http://preview.example.com', 'https://preview.example.com', '/preview', 'preview?draft=true', '../preview', '?draft=true', '#preview', '//preview.example.com/page'])('should accept HTTP(S) or relative URL %s', input => {
|
|
19
|
+
expect(isHttpURL(input)).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
it.each([undefined, '', 'mailto:editor@example.com', 'file:///preview.html', 'https://[invalid', 'http://'])('should reject absent, unsupported, or invalid URL %s', input => {
|
|
22
|
+
expect(isHttpURL(input)).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=isHttpURL.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isHttpURL.spec.js","names":["afterEach","beforeEach","describe","expect","it","vi","isHttpURL","stubGlobal","location","origin","unstubAllGlobals","each","input","expected","undefined","URL","toBe"],"sources":["../../src/utilities/isHttpURL.spec.ts"],"sourcesContent":["import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'\n\nimport { isHttpURL } from './isHttpURL.js'\n\ndescribe('isHttpURL', () => {\n beforeEach(() => {\n vi.stubGlobal('window', {\n location: { origin: 'https://admin.example.com' },\n })\n })\n\n afterEach(() => {\n vi.unstubAllGlobals()\n })\n\n it.each([\n ['https://preview.example.com', true],\n ['mailto:editor@example.com', false],\n ] as const)('should validate parsed URL %s without the client environment', (input, expected) => {\n vi.stubGlobal('window', undefined)\n\n expect(isHttpURL(new URL(input))).toBe(expected)\n })\n\n it.each([\n 'http://preview.example.com',\n 'https://preview.example.com',\n '/preview',\n 'preview?draft=true',\n '../preview',\n '?draft=true',\n '#preview',\n '//preview.example.com/page',\n ])('should accept HTTP(S) or relative URL %s', (input) => {\n expect(isHttpURL(input)).toBe(true)\n })\n\n it.each([\n undefined,\n '',\n 'mailto:editor@example.com',\n 'file:///preview.html',\n 'https://[invalid',\n 'http://',\n ])('should reject absent, unsupported, or invalid URL %s', (input) => {\n expect(isHttpURL(input)).toBe(false)\n })\n})\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ;AAEhE,SAASC,SAAS,QAAQ;AAE1BJ,QAAA,CAAS,aAAa;EACpBD,UAAA,CAAW;IACTI,EAAA,CAAGE,UAAU,CAAC,UAAU;MACtBC,QAAA,EAAU;QAAEC,MAAA,EAAQ;MAA4B;IAClD;EACF;EAEAT,SAAA,CAAU;IACRK,EAAA,CAAGK,gBAAgB;EACrB;EAEAN,EAAA,CAAGO,IAAI,CAAC,CACN,CAAC,+BAA+B,KAAK,EACrC,CAAC,6BAA6B,MAAM,CACrC,EAAW,gEAAgE,CAACC,KAAA,EAAOC,QAAA;IAClFR,EAAA,CAAGE,UAAU,CAAC,UAAUO,SAAA;IAExBX,MAAA,CAAOG,SAAA,CAAU,IAAIS,GAAA,CAAIH,KAAA,IAASI,IAAI,CAACH,QAAA;EACzC;EAEAT,EAAA,CAAGO,IAAI,CAAC,CACN,8BACA,+BACA,YACA,sBACA,cACA,eACA,YACA,6BACD,EAAE,4CAA6CC,KAAA;IAC9CT,MAAA,CAAOG,SAAA,CAAUM,KAAA,GAAQI,IAAI,CAAC;EAChC;EAEAZ,EAAA,CAAGO,IAAI,CAAC,CACNG,SAAA,EACA,IACA,6BACA,wBACA,oBACA,UACD,EAAE,wDAAyDF,KAAA;IAC1DT,MAAA,CAAOG,SAAA,CAAUM,KAAA,GAAQI,IAAI,CAAC;EAChC;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPublicAdminRoute.d.ts","sourceRoot":"","sources":["../../src/utilities/isPublicAdminRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAmB9C,eAAO,MAAM,kBAAkB,mCAI5B;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;CACd,KAAG,
|
|
1
|
+
{"version":3,"file":"isPublicAdminRoute.d.ts","sourceRoot":"","sources":["../../src/utilities/isPublicAdminRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAmB9C,eAAO,MAAM,kBAAkB,mCAI5B;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;CACd,KAAG,OAuBH,CAAA"}
|
|
@@ -6,16 +6,19 @@ export const isPublicAdminRoute = ({
|
|
|
6
6
|
config,
|
|
7
7
|
route
|
|
8
8
|
}) => {
|
|
9
|
+
const routeWithoutAdmin = getRouteWithoutAdmin({
|
|
10
|
+
adminRoute,
|
|
11
|
+
route
|
|
12
|
+
});
|
|
13
|
+
const routeSegments = routeWithoutAdmin.split('/').filter(Boolean);
|
|
14
|
+
const isVerifyRoute = routeSegments.length === 3 && routeSegments[1] === 'verify' && config.collections.some(collection => collection.slug === routeSegments[0] && Boolean(collection.auth));
|
|
15
|
+
if (isVerifyRoute) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
9
18
|
return publicAdminRoutes.some(routeSegment => {
|
|
10
19
|
const segment = config.admin?.routes?.[routeSegment] || routeSegment;
|
|
11
|
-
const routeWithoutAdmin = getRouteWithoutAdmin({
|
|
12
|
-
adminRoute,
|
|
13
|
-
route
|
|
14
|
-
});
|
|
15
20
|
if (routeWithoutAdmin.startsWith(segment)) {
|
|
16
21
|
return true;
|
|
17
|
-
} else if (routeWithoutAdmin.includes('/verify/')) {
|
|
18
|
-
return true;
|
|
19
22
|
} else {
|
|
20
23
|
return false;
|
|
21
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPublicAdminRoute.js","names":["getRouteWithoutAdmin","publicAdminRoutes","isPublicAdminRoute","adminRoute","config","route","some","
|
|
1
|
+
{"version":3,"file":"isPublicAdminRoute.js","names":["getRouteWithoutAdmin","publicAdminRoutes","isPublicAdminRoute","adminRoute","config","route","routeWithoutAdmin","routeSegments","split","filter","Boolean","isVerifyRoute","length","collections","some","collection","slug","auth","routeSegment","segment","admin","routes","startsWith"],"sources":["../../src/utilities/isPublicAdminRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { getRouteWithoutAdmin } from './getRouteWithoutAdmin.js'\n\n// Routes that are accessible without admin authentication\nconst publicAdminRoutes: (keyof Pick<\n SanitizedConfig['admin']['routes'],\n 'createFirstUser' | 'forgot' | 'inactivity' | 'login' | 'logout' | 'reset' | 'unauthorized'\n>)[] = [\n 'createFirstUser',\n 'forgot',\n 'login',\n 'logout',\n 'forgot',\n 'inactivity',\n 'unauthorized',\n 'reset',\n]\n\nexport const isPublicAdminRoute = ({\n adminRoute,\n config,\n route,\n}: {\n adminRoute: string\n config: SanitizedConfig\n route: string\n}): boolean => {\n const routeWithoutAdmin = getRouteWithoutAdmin({ adminRoute, route })\n const routeSegments = routeWithoutAdmin.split('/').filter(Boolean)\n const isVerifyRoute =\n routeSegments.length === 3 &&\n routeSegments[1] === 'verify' &&\n config.collections.some(\n (collection) => collection.slug === routeSegments[0] && Boolean(collection.auth),\n )\n\n if (isVerifyRoute) {\n return true\n }\n\n return publicAdminRoutes.some((routeSegment) => {\n const segment = config.admin?.routes?.[routeSegment] || routeSegment\n\n if (routeWithoutAdmin.startsWith(segment)) {\n return true\n } else {\n return false\n }\n })\n}\n"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ;AAErC;AACA,MAAMC,iBAAA,GAGC,CACL,mBACA,UACA,SACA,UACA,UACA,cACA,gBACA,QACD;AAED,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EACjCC,UAAU;EACVC,MAAM;EACNC;AAAK,CAKN;EACC,MAAMC,iBAAA,GAAoBN,oBAAA,CAAqB;IAAEG,UAAA;IAAYE;EAAM;EACnE,MAAME,aAAA,GAAgBD,iBAAA,CAAkBE,KAAK,CAAC,KAAKC,MAAM,CAACC,OAAA;EAC1D,MAAMC,aAAA,GACJJ,aAAA,CAAcK,MAAM,KAAK,KACzBL,aAAa,CAAC,EAAE,KAAK,YACrBH,MAAA,CAAOS,WAAW,CAACC,IAAI,CACpBC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKT,aAAa,CAAC,EAAE,IAAIG,OAAA,CAAQK,UAAA,CAAWE,IAAI;EAGnF,IAAIN,aAAA,EAAe;IACjB,OAAO;EACT;EAEA,OAAOV,iBAAA,CAAkBa,IAAI,CAAEI,YAAA;IAC7B,MAAMC,OAAA,GAAUf,MAAA,CAAOgB,KAAK,EAAEC,MAAA,GAASH,YAAA,CAAa,IAAIA,YAAA;IAExD,IAAIZ,iBAAA,CAAkBgB,UAAU,CAACH,OAAA,GAAU;MACzC,OAAO;IACT,OAAO;MACL,OAAO;IACT;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { isPublicAdminRoute } from './isPublicAdminRoute.js';
|
|
3
|
+
describe('isPublicAdminRoute', () => {
|
|
4
|
+
const config = {
|
|
5
|
+
collections: [{
|
|
6
|
+
auth: true,
|
|
7
|
+
slug: 'users'
|
|
8
|
+
}, {
|
|
9
|
+
slug: 'pages'
|
|
10
|
+
}]
|
|
11
|
+
};
|
|
12
|
+
it('should allow collection verification routes', () => {
|
|
13
|
+
expect(isPublicAdminRoute({
|
|
14
|
+
adminRoute: '/admin',
|
|
15
|
+
config,
|
|
16
|
+
route: '/admin/users/verify/token'
|
|
17
|
+
})).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
it('should not allow verification routes for collections without auth', () => {
|
|
20
|
+
expect(isPublicAdminRoute({
|
|
21
|
+
adminRoute: '/admin',
|
|
22
|
+
config,
|
|
23
|
+
route: '/admin/pages/verify/token'
|
|
24
|
+
})).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
it('should not allow unrelated routes containing the verification segment', () => {
|
|
27
|
+
expect(isPublicAdminRoute({
|
|
28
|
+
adminRoute: '/admin',
|
|
29
|
+
config,
|
|
30
|
+
route: '/admin/custom/verify/dashboard'
|
|
31
|
+
})).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=isPublicAdminRoute.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPublicAdminRoute.spec.js","names":["describe","expect","it","isPublicAdminRoute","config","collections","auth","slug","adminRoute","route","toBe"],"sources":["../../src/utilities/isPublicAdminRoute.spec.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { isPublicAdminRoute } from './isPublicAdminRoute.js'\n\ndescribe('isPublicAdminRoute', () => {\n const config = {\n collections: [{ auth: true, slug: 'users' }, { slug: 'pages' }],\n } as unknown as SanitizedConfig\n\n it('should allow collection verification routes', () => {\n expect(\n isPublicAdminRoute({\n adminRoute: '/admin',\n config,\n route: '/admin/users/verify/token',\n }),\n ).toBe(true)\n })\n\n it('should not allow verification routes for collections without auth', () => {\n expect(\n isPublicAdminRoute({\n adminRoute: '/admin',\n config,\n route: '/admin/pages/verify/token',\n }),\n ).toBe(false)\n })\n\n it('should not allow unrelated routes containing the verification segment', () => {\n expect(\n isPublicAdminRoute({\n adminRoute: '/admin',\n config,\n route: '/admin/custom/verify/dashboard',\n }),\n ).toBe(false)\n })\n})\n"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,kBAAkB,QAAQ;AAEnCH,QAAA,CAAS,sBAAsB;EAC7B,MAAMI,MAAA,GAAS;IACbC,WAAA,EAAa,CAAC;MAAEC,IAAA,EAAM;MAAMC,IAAA,EAAM;IAAQ,GAAG;MAAEA,IAAA,EAAM;IAAQ;EAC/D;EAEAL,EAAA,CAAG,+CAA+C;IAChDD,MAAA,CACEE,kBAAA,CAAmB;MACjBK,UAAA,EAAY;MACZJ,MAAA;MACAK,KAAA,EAAO;IACT,IACAC,IAAI,CAAC;EACT;EAEAR,EAAA,CAAG,qEAAqE;IACtED,MAAA,CACEE,kBAAA,CAAmB;MACjBK,UAAA,EAAY;MACZJ,MAAA;MACAK,KAAA,EAAO;IACT,IACAC,IAAI,CAAC;EACT;EAEAR,EAAA,CAAG,yEAAyE;IAC1ED,MAAA,CACEE,kBAAA,CAAmB;MACjBK,UAAA,EAAY;MACZJ,MAAA;MACAK,KAAA,EAAO;IACT,IACAC,IAAI,CAAC;EACT;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedulePublishHandler.d.ts","sourceRoot":"","sources":["../../src/utilities/schedulePublishHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAA;AAKtF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,IAAI,CAAC,wBAAwB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAA;AAE7D,MAAM,MAAM,sCAAsC,GAAG;IACnD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kCAAkC,EAAE,cAAc,CAC7D,sCAAsC,EACtC,OAAO,CAAC,aAAa,EAAE,CAAC,CAiDzB,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,0BAA0B,
|
|
1
|
+
{"version":3,"file":"schedulePublishHandler.d.ts","sourceRoot":"","sources":["../../src/utilities/schedulePublishHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAA;AAKtF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,IAAI,CAAC,wBAAwB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC,CAAA;AAE7D,MAAM,MAAM,sCAAsC,GAAG;IACnD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kCAAkC,EAAE,cAAc,CAC7D,sCAAsC,EACtC,OAAO,CAAC,aAAa,EAAE,CAAC,CAiDzB,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,0BAA0B,CA+D7E,CAAA"}
|
|
@@ -100,7 +100,10 @@ export const schedulePublishHandler = async ({
|
|
|
100
100
|
global,
|
|
101
101
|
locale: localeToPublish,
|
|
102
102
|
timezone,
|
|
103
|
-
user: user.
|
|
103
|
+
user: user && user.collection ? {
|
|
104
|
+
relationTo: user.collection,
|
|
105
|
+
value: user.id
|
|
106
|
+
} : undefined
|
|
104
107
|
},
|
|
105
108
|
task: 'schedulePublish',
|
|
106
109
|
waitUntil: date
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedulePublishHandler.js","names":["canAccessAdmin","Forbidden","hasScheduledPublishEnabled","buildUpcomingScheduleWhere","getDocumentPermissions","getUpcomingScheduledPublishHandler","id","collectionSlug","globalSlug","req","payload","collectionConfig","collections","config","undefined","globalConfig","globals","find","slug","entityConfig","hasValidTarget","Boolean","t","hasPublishPermission","data","docs","db","collection","limit","sort","where","map","job","input","type","locale","timezone","waitUntil","schedulePublishHandler","date","deleteID","doc","global","localeToPublish","i18n","user","delete","and","equals","taskSlug","jobs","queue","
|
|
1
|
+
{"version":3,"file":"schedulePublishHandler.js","names":["canAccessAdmin","Forbidden","hasScheduledPublishEnabled","buildUpcomingScheduleWhere","getDocumentPermissions","getUpcomingScheduledPublishHandler","id","collectionSlug","globalSlug","req","payload","collectionConfig","collections","config","undefined","globalConfig","globals","find","slug","entityConfig","hasValidTarget","Boolean","t","hasPublishPermission","data","docs","db","collection","limit","sort","where","map","job","input","type","locale","timezone","waitUntil","schedulePublishHandler","date","deleteID","doc","global","localeToPublish","i18n","user","delete","and","equals","taskSlug","jobs","queue","relationTo","value","task","err","error","logger","message"],"sources":["../../src/utilities/schedulePublishHandler.ts"],"sourcesContent":["import type { SchedulePublishTaskInput, ServerFunction } from 'payload'\n\nimport { canAccessAdmin, Forbidden } from 'payload'\nimport { hasScheduledPublishEnabled } from 'payload/shared'\n\nimport type { UpcomingEvent } from '../elements/PublishButton/ScheduleDrawer/types.js'\n\nimport { buildUpcomingScheduleWhere } from '../elements/PublishButton/ScheduleDrawer/buildUpcomingScheduleWhere.js'\nimport { getDocumentPermissions } from './getDocumentPermissions.js'\n\nexport type SchedulePublishHandlerArgs = {\n date?: Date\n /**\n * The job id to delete to remove a scheduled publish event\n */\n deleteID?: number | string\n localeToPublish?: string\n timezone?: string\n} & Pick<SchedulePublishTaskInput, 'doc' | 'global' | 'type'>\n\nexport type GetUpcomingScheduledPublishHandlerArgs = {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}\n\nexport const getUpcomingScheduledPublishHandler: ServerFunction<\n GetUpcomingScheduledPublishHandlerArgs,\n Promise<UpcomingEvent[]>\n> = async ({ id, collectionSlug, globalSlug, req }) => {\n const { payload } = req\n\n await canAccessAdmin({ req })\n\n const collectionConfig = collectionSlug ? payload.collections[collectionSlug]?.config : undefined\n const globalConfig = globalSlug\n ? payload.config.globals.find(({ slug }) => slug === globalSlug)\n : undefined\n const entityConfig = collectionConfig || globalConfig\n const hasValidTarget = Boolean(\n entityConfig &&\n hasScheduledPublishEnabled(entityConfig) &&\n ((collectionConfig && id !== undefined && !globalSlug) || (globalConfig && !collectionSlug)),\n )\n\n if (!hasValidTarget) {\n throw new Forbidden(req.t)\n }\n\n const { hasPublishPermission } = await getDocumentPermissions({\n id,\n collectionConfig,\n data: {},\n globalConfig,\n req,\n })\n\n if (!hasPublishPermission) {\n throw new Forbidden(req.t)\n }\n\n const { docs } = await payload.db.find<UpcomingEvent>({\n collection: 'payload-jobs',\n limit: 0,\n sort: 'waitUntil',\n where: buildUpcomingScheduleWhere({ id, collectionSlug, globalSlug }),\n })\n\n return docs.map((job) => ({\n id: job.id,\n input: {\n type: job.input?.type === 'unpublish' ? 'unpublish' : 'publish',\n locale: job.input?.locale,\n timezone: job.input?.timezone,\n },\n waitUntil: job.waitUntil,\n }))\n}\n\nexport const schedulePublishHandler: ServerFunction<SchedulePublishHandlerArgs> = async ({\n type,\n date,\n deleteID,\n doc,\n global,\n localeToPublish,\n req,\n timezone,\n}) => {\n const { i18n, payload, user } = req\n\n await canAccessAdmin({ req })\n\n try {\n if (deleteID) {\n await payload.delete({\n collection: 'payload-jobs',\n req,\n where: {\n and: [{ id: { equals: deleteID } }, { taskSlug: { equals: 'schedulePublish' } }],\n },\n })\n }\n\n await payload.jobs.queue({\n input: {\n type,\n doc,\n global,\n locale: localeToPublish,\n timezone,\n user:\n user && user.collection\n ? {\n relationTo: user.collection,\n value: user.id,\n }\n : undefined,\n },\n task: 'schedulePublish',\n waitUntil: date,\n })\n } catch (err) {\n let error\n\n if (deleteID) {\n error = `Error deleting scheduled publish event with ID ${deleteID}`\n } else {\n error = `Error scheduling ${type} for `\n if (doc) {\n error += `document with ID ${doc.value} in collection ${doc.relationTo}`\n }\n }\n\n payload.logger.error({ err }, error)\n\n return {\n error,\n }\n }\n\n return { message: i18n.t('general:success') }\n}\n"],"mappings":"AAEA,SAASA,cAAc,EAAEC,SAAS,QAAQ;AAC1C,SAASC,0BAA0B,QAAQ;AAI3C,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,sBAAsB,QAAQ;AAkBvC,OAAO,MAAMC,kCAAA,GAGT,MAAAA,CAAO;EAAEC,EAAE;EAAEC,cAAc;EAAEC,UAAU;EAAEC;AAAG,CAAE;EAChD,MAAM;IAAEC;EAAO,CAAE,GAAGD,GAAA;EAEpB,MAAMT,cAAA,CAAe;IAAES;EAAI;EAE3B,MAAME,gBAAA,GAAmBJ,cAAA,GAAiBG,OAAA,CAAQE,WAAW,CAACL,cAAA,CAAe,EAAEM,MAAA,GAASC,SAAA;EACxF,MAAMC,YAAA,GAAeP,UAAA,GACjBE,OAAA,CAAQG,MAAM,CAACG,OAAO,CAACC,IAAI,CAAC,CAAC;IAAEC;EAAI,CAAE,KAAKA,IAAA,KAASV,UAAA,IACnDM,SAAA;EACJ,MAAMK,YAAA,GAAeR,gBAAA,IAAoBI,YAAA;EACzC,MAAMK,cAAA,GAAiBC,OAAA,CACrBF,YAAA,IACEjB,0BAAA,CAA2BiB,YAAA,MAC1BR,gBAAC,IAAoBL,EAAA,KAAOQ,SAAA,IAAa,CAACN,UAAA,IAAgBO,YAAA,IAAgB,CAACR,cAAc;EAG9F,IAAI,CAACa,cAAA,EAAgB;IACnB,MAAM,IAAInB,SAAA,CAAUQ,GAAA,CAAIa,CAA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,EAAI;cAAE0C,MAAA,EAAQR;YAAS;UAAE,GAAG;YAAES,QAAA,EAAU;cAAED,MAAA,EAAQ;YAAkB;UAAE;QAChF;MACF;IACF;IAEA,MAAMtC,OAAA,CAAQwC,IAAI,CAACC,KAAK,CAAC;MACvBlB,KAAA,EAAO;QACLC,IAAA;QACAO,GAAA;QACAC,MAAA;QACAP,MAAA,EAAQQ,eAAA;QACRP,QAAA;QACAS,IAAA,EACEA,IAAA,IAAQA,IAAA,CAAKlB,UAAU,GACnB;UACEyB,UAAA,EAAYP,IAAA,CAAKlB,UAAU;UAC3B0B,KAAA,EAAOR,IAAA,CAAKvC;QACd,IACAQ;MACR;MACAwC,IAAA,EAAM;MACNjB,SAAA,EAAWE;IACb;EACF,EAAE,OAAOgB,GAAA,EAAK;IACZ,IAAIC,KAAA;IAEJ,IAAIhB,QAAA,EAAU;MACZgB,KAAA,GAAQ,kDAAkDhB,QAAA,EAAU;IACtE,OAAO;MACLgB,KAAA,GAAQ,oBAAoBtB,IAAA,OAAW;MACvC,IAAIO,GAAA,EAAK;QACPe,KAAA,IAAS,oBAAoBf,GAAA,CAAIY,KAAK,kBAAkBZ,GAAA,CAAIW,UAAU,EAAE;MAC1E;IACF;IAEA1C,OAAA,CAAQ+C,MAAM,CAACD,KAAK,CAAC;MAAED;IAAI,GAAGC,KAAA;IAE9B,OAAO;MACLA;IACF;EACF;EAEA,OAAO;IAAEE,OAAA,EAASd,IAAA,CAAKtB,CAAC,CAAC;EAAmB;AAC9C","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AdminViewServerProps } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare function AccountView({ initPageResult, params, searchParams }: AdminViewServerProps): Promise<React.JSX.Element>;
|
|
3
|
+
export declare function AccountView({ initPageResult, params, searchParams, user: userWithReadAccess, }: AdminViewServerProps): Promise<React.JSX.Element>;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,SAAS,CAAA;AAGhF,OAAO,KAAK,MAAM,OAAO,CAAA;AAqBzB,wBAAsB,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Account/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,SAAS,CAAA;AAGhF,OAAO,KAAK,MAAM,OAAO,CAAA;AAqBzB,wBAAsB,WAAW,CAAC,EAChC,cAAc,EACd,MAAM,EACN,YAAY,EACZ,IAAI,EAAE,kBAAkB,GACzB,EAAE,oBAAoB,8BAkKtB"}
|
|
@@ -16,7 +16,8 @@ import { Settings } from './Settings/index.js';
|
|
|
16
16
|
export async function AccountView({
|
|
17
17
|
initPageResult,
|
|
18
18
|
params,
|
|
19
|
-
searchParams
|
|
19
|
+
searchParams,
|
|
20
|
+
user: userWithReadAccess
|
|
20
21
|
}) {
|
|
21
22
|
const {
|
|
22
23
|
languageOptions,
|
|
@@ -89,7 +90,8 @@ export async function AccountView({
|
|
|
89
90
|
renderAllFields: true,
|
|
90
91
|
req,
|
|
91
92
|
schemaPath: collectionConfig.slug,
|
|
92
|
-
skipValidation: true
|
|
93
|
+
skipValidation: true,
|
|
94
|
+
user: userWithReadAccess
|
|
93
95
|
});
|
|
94
96
|
// Fetch document lock state
|
|
95
97
|
const {
|
|
@@ -123,7 +125,7 @@ export async function AccountView({
|
|
|
123
125
|
languageOptions: languageOptions,
|
|
124
126
|
payload: payload,
|
|
125
127
|
theme: theme,
|
|
126
|
-
user:
|
|
128
|
+
user: userWithReadAccess
|
|
127
129
|
}),
|
|
128
130
|
apiURL: formatAdminURL({
|
|
129
131
|
apiRoute: api,
|
|
@@ -151,7 +153,8 @@ export async function AccountView({
|
|
|
151
153
|
collectionConfig: collectionConfig,
|
|
152
154
|
hideTabs: true,
|
|
153
155
|
permissions: permissions,
|
|
154
|
-
req: req
|
|
156
|
+
req: req,
|
|
157
|
+
user: userWithReadAccess
|
|
155
158
|
}), /*#__PURE__*/_jsx(HydrateAuthProvider, {
|
|
156
159
|
permissions: permissions
|
|
157
160
|
}), RenderServerComponent({
|
|
@@ -170,7 +173,7 @@ export async function AccountView({
|
|
|
170
173
|
routeSegments: [],
|
|
171
174
|
searchParams,
|
|
172
175
|
server: req.server,
|
|
173
|
-
user
|
|
176
|
+
user: userWithReadAccess
|
|
174
177
|
}
|
|
175
178
|
}), /*#__PURE__*/_jsx(AccountClient, {})]
|
|
176
179
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatAdminURL","React","DocumentHeader","RenderServerComponent","AccountClient","DefaultEditView","DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","buildFormState","getDocPreferences","getDocumentData","getDocumentPermissions","getIsLocked","getVersions","Settings","AccountView","initPageResult","params","searchParams","languageOptions","locale","permissions","req","i18n","payload","config","user","admin","theme","userSlug","routes","api","collectionConfig","collections","id","data","collectionSlug","slug","Error","docPreferences","docPermissions","hasDeletePermission","hasPublishPermission","hasSavePermission","hasTrashPermission","state","formState","code","operation","renderAllFields","schemaPath","skipValidation","currentEditor","isLocked","lastUpdateTime","isEditing","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","doc","_jsx","AfterFields","apiURL","apiRoute","path","initialData","initialState","_jsxs","hideTabs","Component","components","views","account","Fallback","importMap","serverProps","routeSegments","server","notFound"],"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewServerProps, DocumentViewServerPropsOnly } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n/* eslint-disable payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds */\nimport {\n AccountClient,\n DefaultEditView,\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n} from '../../exports/client/index.js'\n/* eslint-enable payload/no-imports-from-exports-dir */\nimport { buildFormState } from '../../utilities/buildFormState.js'\nimport { getDocPreferences } from '../../utilities/getDocPreferences.js'\nimport { getDocumentData } from '../../utilities/getDocumentData.js'\nimport { getDocumentPermissions } from '../../utilities/getDocumentPermissions.js'\nimport { getIsLocked } from '../../utilities/getIsLocked.js'\nimport { getVersions } from '../../utilities/getVersions.js'\nimport { Settings } from './Settings/index.js'\n\nexport async function AccountView({ initPageResult, params, searchParams }: AdminViewServerProps) {\n const {\n languageOptions,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: { theme, user: userSlug },\n routes: { api },\n } = config\n\n const collectionConfig = payload?.collections?.[userSlug]?.config\n\n if (collectionConfig && user?.id) {\n // Fetch the data required for the view\n const data = await getDocumentData({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n locale,\n payload,\n req,\n user,\n })\n\n if (!data) {\n throw new Error('not-found')\n }\n\n // Get document preferences\n const docPreferences = await getDocPreferences({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n payload,\n user,\n })\n\n // Get permissions\n const {\n docPermissions,\n hasDeletePermission,\n hasPublishPermission,\n hasSavePermission,\n hasTrashPermission,\n } = await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data,\n req,\n })\n\n // Build initial form state from data\n const { state: formState } = await buildFormState({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n data,\n docPermissions,\n docPreferences,\n locale: locale?.code,\n operation: 'update',\n renderAllFields: true,\n req,\n schemaPath: collectionConfig.slug,\n skipValidation: true,\n })\n\n // Fetch document lock state\n const { currentEditor, isLocked, lastUpdateTime } = await getIsLocked({\n id: user.id,\n collectionConfig,\n isEditing: true,\n req,\n })\n\n // Get all versions required for UI\n const { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount } =\n await getVersions({\n id: user.id,\n collectionConfig,\n doc: data,\n docPermissions,\n locale: locale?.code,\n payload,\n user,\n })\n\n return (\n <DocumentInfoProvider\n AfterFields={\n <Settings\n i18n={i18n}\n languageOptions={languageOptions}\n payload={payload}\n theme={theme}\n user={user}\n />\n }\n apiURL={formatAdminURL({\n apiRoute: api,\n path: `/${userSlug}${user?.id ? `/${user.id}` : ''}`,\n })}\n collectionSlug={userSlug}\n currentEditor={currentEditor}\n docPermissions={docPermissions}\n hasDeletePermission={hasDeletePermission}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n hasTrashPermission={hasTrashPermission}\n id={user?.id}\n initialData={data}\n initialState={formState}\n isEditing\n isLocked={isLocked}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <EditDepthProvider>\n <DocumentHeader\n collectionConfig={collectionConfig}\n hideTabs\n permissions={permissions}\n req={req}\n />\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n Component: config.admin?.components?.views?.account?.Component,\n Fallback: DefaultEditView,\n importMap: payload.importMap,\n serverProps: {\n doc: data,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: [],\n searchParams,\n server: req.server,\n user,\n } satisfies DocumentViewServerPropsOnly,\n })}\n <AccountClient />\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n }\n\n return req.server.notFound()\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC;AACA,SACEC,aAAa,EACbC,eAAe,EACfC,oBAAoB,EACpBC,iBAAiB,EACjBC,mB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GAAA,CAAIwD,MAAM,CAACC,QAAQ;AAC5B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["formatAdminURL","React","DocumentHeader","RenderServerComponent","AccountClient","DefaultEditView","DocumentInfoProvider","EditDepthProvider","HydrateAuthProvider","buildFormState","getDocPreferences","getDocumentData","getDocumentPermissions","getIsLocked","getVersions","Settings","AccountView","initPageResult","params","searchParams","user","userWithReadAccess","languageOptions","locale","permissions","req","i18n","payload","config","admin","theme","userSlug","routes","api","collectionConfig","collections","id","data","collectionSlug","slug","Error","docPreferences","docPermissions","hasDeletePermission","hasPublishPermission","hasSavePermission","hasTrashPermission","state","formState","code","operation","renderAllFields","schemaPath","skipValidation","currentEditor","isLocked","lastUpdateTime","isEditing","hasPublishedDoc","mostRecentVersionIsAutosaved","unpublishedVersionCount","versionCount","doc","_jsx","AfterFields","apiURL","apiRoute","path","initialData","initialState","_jsxs","hideTabs","Component","components","views","account","Fallback","importMap","serverProps","routeSegments","server","notFound"],"sources":["../../../src/views/Account/index.tsx"],"sourcesContent":["import type { AdminViewServerProps, DocumentViewServerPropsOnly } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport { DocumentHeader } from '../../elements/DocumentHeader/index.js'\nimport { RenderServerComponent } from '../../elements/RenderServerComponent/index.js'\n/* eslint-disable payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds */\nimport {\n AccountClient,\n DefaultEditView,\n DocumentInfoProvider,\n EditDepthProvider,\n HydrateAuthProvider,\n} from '../../exports/client/index.js'\n/* eslint-enable payload/no-imports-from-exports-dir */\nimport { buildFormState } from '../../utilities/buildFormState.js'\nimport { getDocPreferences } from '../../utilities/getDocPreferences.js'\nimport { getDocumentData } from '../../utilities/getDocumentData.js'\nimport { getDocumentPermissions } from '../../utilities/getDocumentPermissions.js'\nimport { getIsLocked } from '../../utilities/getIsLocked.js'\nimport { getVersions } from '../../utilities/getVersions.js'\nimport { Settings } from './Settings/index.js'\n\nexport async function AccountView({\n initPageResult,\n params,\n searchParams,\n user: userWithReadAccess,\n}: AdminViewServerProps) {\n const {\n languageOptions,\n locale,\n permissions,\n req,\n req: {\n i18n,\n payload,\n payload: { config },\n user,\n },\n } = initPageResult\n\n const {\n admin: { theme, user: userSlug },\n routes: { api },\n } = config\n\n const collectionConfig = payload?.collections?.[userSlug]?.config\n\n if (collectionConfig && user?.id) {\n // Fetch the data required for the view\n const data = await getDocumentData({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n locale,\n payload,\n req,\n user,\n })\n\n if (!data) {\n throw new Error('not-found')\n }\n\n // Get document preferences\n const docPreferences = await getDocPreferences({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n payload,\n user,\n })\n\n // Get permissions\n const {\n docPermissions,\n hasDeletePermission,\n hasPublishPermission,\n hasSavePermission,\n hasTrashPermission,\n } = await getDocumentPermissions({\n id: user.id,\n collectionConfig,\n data,\n req,\n })\n\n // Build initial form state from data\n const { state: formState } = await buildFormState({\n id: user.id,\n collectionSlug: collectionConfig.slug,\n data,\n docPermissions,\n docPreferences,\n locale: locale?.code,\n operation: 'update',\n renderAllFields: true,\n req,\n schemaPath: collectionConfig.slug,\n skipValidation: true,\n user: userWithReadAccess,\n })\n\n // Fetch document lock state\n const { currentEditor, isLocked, lastUpdateTime } = await getIsLocked({\n id: user.id,\n collectionConfig,\n isEditing: true,\n req,\n })\n\n // Get all versions required for UI\n const { hasPublishedDoc, mostRecentVersionIsAutosaved, unpublishedVersionCount, versionCount } =\n await getVersions({\n id: user.id,\n collectionConfig,\n doc: data,\n docPermissions,\n locale: locale?.code,\n payload,\n user,\n })\n\n return (\n <DocumentInfoProvider\n AfterFields={\n <Settings\n i18n={i18n}\n languageOptions={languageOptions}\n payload={payload}\n theme={theme}\n user={userWithReadAccess}\n />\n }\n apiURL={formatAdminURL({\n apiRoute: api,\n path: `/${userSlug}${user?.id ? `/${user.id}` : ''}`,\n })}\n collectionSlug={userSlug}\n currentEditor={currentEditor}\n docPermissions={docPermissions}\n hasDeletePermission={hasDeletePermission}\n hasPublishedDoc={hasPublishedDoc}\n hasPublishPermission={hasPublishPermission}\n hasSavePermission={hasSavePermission}\n hasTrashPermission={hasTrashPermission}\n id={user?.id}\n initialData={data}\n initialState={formState}\n isEditing\n isLocked={isLocked}\n lastUpdateTime={lastUpdateTime}\n mostRecentVersionIsAutosaved={mostRecentVersionIsAutosaved}\n unpublishedVersionCount={unpublishedVersionCount}\n versionCount={versionCount}\n >\n <EditDepthProvider>\n <DocumentHeader\n collectionConfig={collectionConfig}\n hideTabs\n permissions={permissions}\n req={req}\n user={userWithReadAccess}\n />\n <HydrateAuthProvider permissions={permissions} />\n {RenderServerComponent({\n Component: config.admin?.components?.views?.account?.Component,\n Fallback: DefaultEditView,\n importMap: payload.importMap,\n serverProps: {\n doc: data,\n hasPublishedDoc,\n i18n,\n initPageResult,\n locale,\n params,\n payload,\n permissions,\n routeSegments: [],\n searchParams,\n server: req.server,\n user: userWithReadAccess,\n } satisfies DocumentViewServerPropsOnly,\n })}\n <AccountClient />\n </EditDepthProvider>\n </DocumentInfoProvider>\n )\n }\n\n return req.server.notFound()\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC;AACA,SACEC,aAAa,EACbC,eAAe,EACfC,oBAAoB,EACpBC,iBAAiB,EACjBC,mBAAmB,QACd;AACP;AACA,SAASC,cAAc,QAAQ;AAC/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,eAAe,QAAQ;AAChC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,WAAW,QAAQ;AAC5B,SAASC,WAAW,QAAQ;AAC5B,SAASC,QAAQ,QAAQ;AAEzB,OAAO,eAAeC,YAAY;EAChCC,cAAc;EACdC,MAAM;EACNC,YAAY;EACZC,IAAA,EAAMC;AAAkB,CACH;EACrB,MAAM;IACJC,e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A,iBAAA;MACnBC,kBAAA,EAAoBA,kBAAA;MACpBV,EAAA,EAAIhB,IAAA,EAAMgB,EAAA;MACVgC,WAAA,EAAa/B,IAAA;MACbgC,YAAA,EAAcrB,SAAA;MACdS,SAAS;MACTF,QAAA,EAAUA,QAAA;MACVC,cAAA,EAAgBA,cAAA;MAChBG,4BAAA,EAA8BA,4BAAA;MAC9BC,uBAAA,EAAyBA,uBAAA;MACzBC,YAAA,EAAcA,YAAA;gBAEd,aAAAS,KAAA,CAAC/D,iBAAA;gCACCwD,IAAA,CAAC7D,cAAA;UACCgC,gBAAA,EAAkBA,gBAAA;UAClBqC,QAAQ;UACR/C,WAAA,EAAaA,WAAA;UACbC,GAAA,EAAKA,GAAA;UACLL,IAAA,EAAMC;yBAER0C,IAAA,CAACvD,mBAAA;UAAoBgB,WAAA,EAAaA;YACjCrB,qBAAA,CAAsB;UACrBqE,SAAA,EAAW5C,MAAA,CAAOC,KAAK,EAAE4C,UAAA,EAAYC,KAAA,EAAOC,OAAA,EAASH,SAAA;UACrDI,QAAA,EAAUvE,eAAA;UACVwE,SAAA,EAAWlD,OAAA,CAAQkD,SAAS;UAC5BC,WAAA,EAAa;YACXhB,GAAA,EAAKzB,IAAA;YACLqB,eAAA;YACAhC,IAAA;YACAT,cAAA;YACAM,MAAA;YACAL,MAAA;YACAS,OAAA;YACAH,WAAA;YACAuD,aAAA,EAAe,EAAE;YACjB5D,YAAA;YACA6D,MAAA,EAAQvD,GAAA,CAAIuD,MAAM;YAClB5D,IAAA,EAAMC;UACR;QACF,I,aACA0C,IAAA,CAAC3D,aAAA;;;EAIT;EAEA,OAAOqB,GAAA,CAAIuD,MAAM,CAACC,QAAQ;AAC5B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAS3D,OAAO,aAAa,CAAA;AAIpB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAS3D,OAAO,aAAa,CAAA;AAIpB,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,8BAkDrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","RenderServerComponent","ModularDashboardClient","getItemsFromConfig","getItemsFromPreferences","extractLocaleData","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","cookies","locale","permissions","req","initPageResult","i18n","layout","serverLayout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","widgetConfig","find","widget","slug","widgetData","fields","length","data","component","Component","serverProps","item","clientWidgets","_","__","label","rest","t","_jsx","clientLayout"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type { ClientWidget, Field, WidgetServerProps } from 'payload'\n\nimport React from 'react'\n\nimport type { DashboardViewServerProps } from '../index.js'\nimport type { WidgetInstanceClient } from './index.client.js'\n\nimport { RenderServerComponent } from '../../../../elements/RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds\nimport { ModularDashboardClient } from '../../../../exports/client/index.js'\nimport { getItemsFromConfig } from './utils/getItemsFromConfig.js'\nimport { getItemsFromPreferences } from './utils/getItemsFromPreferences.js'\nimport { extractLocaleData } from './utils/localeUtils.js'\nimport './index.css'\n\ntype ServerLayout = WidgetInstanceClient[]\n\nexport async function ModularDashboard(props: DashboardViewServerProps) {\n const { defaultLayout = [], widgets = [] } = props.payload.config.admin.dashboard || {}\n const { importMap } = props.payload\n const { user } = props\n const { cookies, locale, permissions, req } = props.initPageResult\n const { i18n } = req\n\n const layout =\n (await getItemsFromPreferences(props.payload, user)) ??\n (await getItemsFromConfig(defaultLayout, req, widgets))\n\n const serverLayout: ServerLayout = layout.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n const widgetData = widgetConfig?.fields?.length\n ? extractLocaleData(layoutItem.data || {}, req.locale || 'en', widgetConfig.fields)\n : layoutItem.data || {}\n\n return {\n component: RenderServerComponent({\n Component: widgetConfig?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n widgetData,\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n // Resolve function labels to static labels for client components\n const clientWidgets: ClientWidget[] = widgets.map((widget) => {\n const { Component: _, fields: __, label, ...rest } = widget\n return {\n ...rest,\n label: typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n })\n\n return (\n <div>\n <ModularDashboardClient clientLayout={serverLayout} widgets={clientWidgets} />\n </div>\n )\n}\n"],"mappings":";AAGA,OAAOA,KAAA,MAAW;AAKlB,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,sBAAsB,QAAQ;AACvC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,iBAAiB,QAAQ;AAClC,OAAO;AAIP,OAAO,eAAeC,iBAAiBC,KAA+B;EACpE,MAAM;IAAEC,aAAA,GAAgB,EAAE;IAAEC,OAAA,GAAU;EAAE,CAAE,GAAGF,KAAA,CAAMG,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EACtF,MAAM;IAAEC;EAAS,CAAE,GAAGP,KAAA,CAAMG,OAAO;EACnC,MAAM;IAAEK;EAAI,CAAE,GAAGR,KAAA;EACjB,MAAM;IAAES,OAAO;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGZ,KAAA,CAAMa,cAAc;EAClE,MAAM;IAAEC;EAAI,CAAE,GAAGF,GAAA;EAEjB,MAAMG,MAAA,GACJ,OAAOlB,uBAAA,CAAwBG,KAAA,CAAMG,OAAO,EAAEK,IAAA,OAC7C,MAAMZ,kBAAA,CAAmBK,aAAA,EAAeW,GAAA,EAAKV,OAAA;EAEhD,MAAMc,YAAA,GAA6BD,MAAA,CAAOE,GAAG,CAAEC,UAAA;IAC7C,MAAMC,UAAA,GAAaD,UAAA,CAAWE,EAAE,CAACC,KAAK,CAAC,GAAGH,UAAA,CAAWE,EAAE,CAACE,WAAW,CAAC;IACpE,MAAMC,YAAA,GAAerB,OAAA,CAAQsB,IAAI,CAAEC,MAAA,IAAWA,MAAA,CAAOC,IAAI,KAAKP,UAAA;IAC9D,MAAMQ,UAAA,GAAaJ,YAAA,EAAcK,MAAA,EAAQC,MAAA,GACrC/B,iBAAA,CAAkBoB,UAAA,CAAWY,IAAI,IAAI,CAAC,GAAGlB,GAAA,CAAIF,MAAM,IAAI,MAAMa,YAAA,CAAaK,MAAM,IAChFV,UAAA,CAAWY,IAAI,IAAI,CAAC;IAExB,OAAO;MACLC,SAAA,EAAWrC,qBAAA,CAAsB;QAC/BsC,SAAA,EAAWT,YAAA,EAAcS,SAAA;QACzBzB,SAAA;QACA0B,WAAA,EAAa;UACXxB,OAAA;UACAC,MAAA;UACAC,WAAA;UACAC,GAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","RenderServerComponent","ModularDashboardClient","getItemsFromConfig","getItemsFromPreferences","extractLocaleData","ModularDashboard","props","defaultLayout","widgets","payload","config","admin","dashboard","importMap","user","cookies","locale","permissions","req","initPageResult","i18n","layout","serverLayout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","widgetConfig","find","widget","slug","widgetData","fields","length","data","component","Component","serverProps","item","clientWidgets","_","__","label","rest","t","_jsx","clientLayout"],"sources":["../../../../../src/views/Dashboard/Default/ModularDashboard/index.tsx"],"sourcesContent":["import type { TFunction } from '@payloadcms/translations'\nimport type { ClientWidget, Field, WidgetServerProps } from 'payload'\n\nimport React from 'react'\n\nimport type { DashboardViewServerProps } from '../index.js'\nimport type { WidgetInstanceClient } from './index.client.js'\n\nimport { RenderServerComponent } from '../../../../elements/RenderServerComponent/index.js'\n// eslint-disable-next-line payload/no-imports-from-exports-dir -- Server component must reference exports/client bundle for proper client boundary in prod builds\nimport { ModularDashboardClient } from '../../../../exports/client/index.js'\nimport { getItemsFromConfig } from './utils/getItemsFromConfig.js'\nimport { getItemsFromPreferences } from './utils/getItemsFromPreferences.js'\nimport { extractLocaleData } from './utils/localeUtils.js'\nimport './index.css'\n\ntype ServerLayout = WidgetInstanceClient[]\n\nexport async function ModularDashboard(props: DashboardViewServerProps) {\n const { defaultLayout = [], widgets = [] } = props.payload.config.admin.dashboard || {}\n const { importMap } = props.payload\n const { user } = props\n const { cookies, locale, permissions, req } = props.initPageResult\n const { i18n } = req\n\n const layout =\n (await getItemsFromPreferences(props.payload, user)) ??\n (await getItemsFromConfig(defaultLayout, req, widgets))\n\n const serverLayout: ServerLayout = layout.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n const widgetData = widgetConfig?.fields?.length\n ? extractLocaleData(layoutItem.data || {}, req.locale || 'en', widgetConfig.fields)\n : layoutItem.data || {}\n\n return {\n component: RenderServerComponent({\n Component: widgetConfig?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n user,\n widgetData,\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n // Resolve function labels to static labels for client components\n const clientWidgets: ClientWidget[] = widgets.map((widget) => {\n const { Component: _, fields: __, label, ...rest } = widget\n return {\n ...rest,\n label: typeof label === 'function' ? label({ i18n, t: i18n.t as TFunction }) : label,\n }\n })\n\n return (\n <div>\n <ModularDashboardClient clientLayout={serverLayout} widgets={clientWidgets} />\n </div>\n )\n}\n"],"mappings":";AAGA,OAAOA,KAAA,MAAW;AAKlB,SAASC,qBAAqB,QAAQ;AACtC;AACA,SAASC,sBAAsB,QAAQ;AACvC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,uBAAuB,QAAQ;AACxC,SAASC,iBAAiB,QAAQ;AAClC,OAAO;AAIP,OAAO,eAAeC,iBAAiBC,KAA+B;EACpE,MAAM;IAAEC,aAAA,GAAgB,EAAE;IAAEC,OAAA,GAAU;EAAE,CAAE,GAAGF,KAAA,CAAMG,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS,IAAI,CAAC;EACtF,MAAM;IAAEC;EAAS,CAAE,GAAGP,KAAA,CAAMG,OAAO;EACnC,MAAM;IAAEK;EAAI,CAAE,GAAGR,KAAA;EACjB,MAAM;IAAES,OAAO;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGZ,KAAA,CAAMa,cAAc;EAClE,MAAM;IAAEC;EAAI,CAAE,GAAGF,GAAA;EAEjB,MAAMG,MAAA,GACJ,OAAOlB,uBAAA,CAAwBG,KAAA,CAAMG,OAAO,EAAEK,IAAA,OAC7C,MAAMZ,kBAAA,CAAmBK,aAAA,EAAeW,GAAA,EAAKV,OAAA;EAEhD,MAAMc,YAAA,GAA6BD,MAAA,CAAOE,GAAG,CAAEC,UAAA;IAC7C,MAAMC,UAAA,GAAaD,UAAA,CAAWE,EAAE,CAACC,KAAK,CAAC,GAAGH,UAAA,CAAWE,EAAE,CAACE,WAAW,CAAC;IACpE,MAAMC,YAAA,GAAerB,OAAA,CAAQsB,IAAI,CAAEC,MAAA,IAAWA,MAAA,CAAOC,IAAI,KAAKP,UAAA;IAC9D,MAAMQ,UAAA,GAAaJ,YAAA,EAAcK,MAAA,EAAQC,MAAA,GACrC/B,iBAAA,CAAkBoB,UAAA,CAAWY,IAAI,IAAI,CAAC,GAAGlB,GAAA,CAAIF,MAAM,IAAI,MAAMa,YAAA,CAAaK,MAAM,IAChFV,UAAA,CAAWY,IAAI,IAAI,CAAC;IAExB,OAAO;MACLC,SAAA,EAAWrC,qBAAA,CAAsB;QAC/BsC,SAAA,EAAWT,YAAA,EAAcS,SAAA;QACzBzB,SAAA;QACA0B,WAAA,EAAa;UACXxB,OAAA;UACAC,MAAA;UACAC,WAAA;UACAC,GAAA;UACAJ,IAAA;UACAmB,UAAA;UACAR;QACF;MACF;MACAe,IAAA,EAAMhB;IACR;EACF;EAEA;EACA,MAAMiB,aAAA,GAAgCjC,OAAA,CAAQe,GAAG,CAAEQ,MAAA;IACjD,MAAM;MAAEO,SAAA,EAAWI,CAAC;MAAER,MAAA,EAAQS,EAAE;MAAEC,KAAK;MAAE,GAAGC;IAAA,CAAM,GAAGd,MAAA;IACrD,OAAO;MACL,GAAGc,IAAI;MACPD,KAAA,EAAO,OAAOA,KAAA,KAAU,aAAaA,KAAA,CAAM;QAAExB,IAAA;QAAM0B,CAAA,EAAG1B,IAAA,CAAK0B;MAAe,KAAKF;IACjF;EACF;EAEA,oBACEG,IAAA,CAAC;cACC,aAAAA,IAAA,CAAC9C,sBAAA;MAAuB+C,YAAA,EAAc1B,YAAA;MAAcd,OAAA,EAASiC;;;AAGnE","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAI1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EAGf,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,oBAAoB,CAAA;AAI1E,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAEhE,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,oBAAoB,EAAE,CAAA;CAC/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAClD,4BAA4B,EAC5B,OAAO,CAAC,kCAAkC,CAAC,CAgC5C,CAAA"}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js
CHANGED
|
@@ -7,7 +7,8 @@ export const getDefaultLayoutHandler = async ({
|
|
|
7
7
|
cookies,
|
|
8
8
|
locale,
|
|
9
9
|
permissions,
|
|
10
|
-
req
|
|
10
|
+
req,
|
|
11
|
+
user
|
|
11
12
|
}) => {
|
|
12
13
|
if (!req.user) {
|
|
13
14
|
throw new Error('Unauthorized');
|
|
@@ -31,6 +32,7 @@ export const getDefaultLayoutHandler = async ({
|
|
|
31
32
|
locale,
|
|
32
33
|
permissions,
|
|
33
34
|
req,
|
|
35
|
+
user,
|
|
34
36
|
widgetData: layoutItem.data || {},
|
|
35
37
|
widgetSlug
|
|
36
38
|
}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","cookies","locale","permissions","req","user","Error","defaultLayout","widgets","payload","config","admin","dashboard","importMap","layoutItems","getItemsFromConfig","layout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","serverProps","widgetData","data","item","widgetInstances","widgetInstance","index","w","maxWidth","minWidth","width"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"sourcesContent":["import type {\n DashboardConfig,\n PayloadRequest,\n ServerFunction,\n Widget,\n WidgetServerProps,\n} from 'payload'\n\nimport type { WidgetInstanceClient, WidgetItem } from '../index.client.js'\n\nimport { RenderServerComponent } from '../../../../../elements/RenderServerComponent/index.js'\n\nexport type GetDefaultLayoutServerFnArgs = Record<string, never>\n\nexport type GetDefaultLayoutServerFnReturnType = {\n layout: WidgetInstanceClient[]\n}\n\n/**\n * Server function to get the default dashboard layout on-demand.\n * Used when resetting the dashboard to its default configuration.\n */\nexport const getDefaultLayoutHandler: ServerFunction<\n GetDefaultLayoutServerFnArgs,\n Promise<GetDefaultLayoutServerFnReturnType>\n> = async ({ cookies, locale, permissions, req }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { defaultLayout = [], widgets = [] } = req.payload.config.admin.dashboard || {}\n const { importMap } = req.payload\n\n const layoutItems = await getItemsFromConfig(defaultLayout, req, widgets)\n\n const layout: WidgetInstanceClient[] = layoutItems.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n widgetData: layoutItem.data || {},\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n return { layout }\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Pick<Widget, 'maxWidth' | 'minWidth' | 'slug'>[],\n): Promise<WidgetItem[]> {\n let widgetInstances\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((w) => w.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n data: widgetInstance.data,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":"AAUA,SAASA,qBAAqB,QAAQ;AAQtC;;;;AAIA,OAAO,MAAMC,uBAAA,GAGT,MAAAA,CAAO;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC;
|
|
1
|
+
{"version":3,"file":"getDefaultLayoutServerFn.js","names":["RenderServerComponent","getDefaultLayoutHandler","cookies","locale","permissions","req","user","Error","defaultLayout","widgets","payload","config","admin","dashboard","importMap","layoutItems","getItemsFromConfig","layout","map","layoutItem","widgetSlug","id","slice","lastIndexOf","component","Component","find","widget","slug","serverProps","widgetData","data","item","widgetInstances","widgetInstance","index","w","maxWidth","minWidth","width"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/getDefaultLayoutServerFn.ts"],"sourcesContent":["import type {\n DashboardConfig,\n PayloadRequest,\n ServerFunction,\n Widget,\n WidgetServerProps,\n} from 'payload'\n\nimport type { WidgetInstanceClient, WidgetItem } from '../index.client.js'\n\nimport { RenderServerComponent } from '../../../../../elements/RenderServerComponent/index.js'\n\nexport type GetDefaultLayoutServerFnArgs = Record<string, never>\n\nexport type GetDefaultLayoutServerFnReturnType = {\n layout: WidgetInstanceClient[]\n}\n\n/**\n * Server function to get the default dashboard layout on-demand.\n * Used when resetting the dashboard to its default configuration.\n */\nexport const getDefaultLayoutHandler: ServerFunction<\n GetDefaultLayoutServerFnArgs,\n Promise<GetDefaultLayoutServerFnReturnType>\n> = async ({ cookies, locale, permissions, req, user }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { defaultLayout = [], widgets = [] } = req.payload.config.admin.dashboard || {}\n const { importMap } = req.payload\n\n const layoutItems = await getItemsFromConfig(defaultLayout, req, widgets)\n\n const layout: WidgetInstanceClient[] = layoutItems.map((layoutItem) => {\n const widgetSlug = layoutItem.id.slice(0, layoutItem.id.lastIndexOf('-'))\n return {\n component: RenderServerComponent({\n Component: widgets.find((widget) => widget.slug === widgetSlug)?.Component,\n importMap,\n serverProps: {\n cookies,\n locale,\n permissions,\n req,\n user,\n widgetData: layoutItem.data || {},\n widgetSlug,\n } satisfies WidgetServerProps,\n }),\n item: layoutItem,\n }\n })\n\n return { layout }\n}\n\nasync function getItemsFromConfig(\n defaultLayout: NonNullable<DashboardConfig['defaultLayout']>,\n req: PayloadRequest,\n widgets: Pick<Widget, 'maxWidth' | 'minWidth' | 'slug'>[],\n): Promise<WidgetItem[]> {\n let widgetInstances\n if (typeof defaultLayout === 'function') {\n widgetInstances = await defaultLayout({ req })\n } else {\n widgetInstances = defaultLayout\n }\n\n return widgetInstances.map((widgetInstance, index) => {\n const widget = widgets.find((w) => w.slug === widgetInstance.widgetSlug)\n return {\n id: `${widgetInstance.widgetSlug}-${index}`,\n data: widgetInstance.data,\n maxWidth: widget?.maxWidth ?? 'full',\n minWidth: widget?.minWidth ?? 'x-small',\n width: widgetInstance.width || 'x-small',\n }\n })\n}\n"],"mappings":"AAUA,SAASA,qBAAqB,QAAQ;AAQtC;;;;AAIA,OAAO,MAAMC,uBAAA,GAGT,MAAAA,CAAO;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC,GAAG;EAAEC;AAAI,CAAE;EACpD,IAAI,CAACD,GAAA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AAEU,CAAA,IAAMA,CAAA,CAAER,IAAI,KAAKM,cAAA,CAAed,UAAU;IACvE,OAAO;MACLC,EAAA,EAAI,GAAGa,cAAA,CAAed,UAAU,IAAIe,KAAA,EAAO;MAC3CJ,IAAA,EAAMG,cAAA,CAAeH,IAAI;MACzBM,QAAA,EAAUV,MAAA,EAAQU,QAAA,IAAY;MAC9BC,QAAA,EAAUX,MAAA,EAAQW,QAAA,IAAY;MAC9BC,KAAA,EAAOL,cAAA,CAAeK,KAAK,IAAI;IACjC;EACF;AACF","ignoreList":[]}
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,cAAc,EAAqB,MAAM,SAAS,CAAA;AAEvE,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.d.ts","sourceRoot":"","sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,cAAc,EAAqB,MAAM,SAAS,CAAA;AAEvE,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,cAAc,CAC9C,wBAAwB,EACxB,8BAA8B,CA+E/B,CAAA"}
|
|
@@ -10,6 +10,7 @@ export const renderWidgetHandler = ({
|
|
|
10
10
|
locale,
|
|
11
11
|
permissions,
|
|
12
12
|
req,
|
|
13
|
+
user,
|
|
13
14
|
widgetData,
|
|
14
15
|
widgetSlug
|
|
15
16
|
}) => {
|
|
@@ -45,6 +46,7 @@ export const renderWidgetHandler = ({
|
|
|
45
46
|
locale,
|
|
46
47
|
permissions,
|
|
47
48
|
req,
|
|
49
|
+
user,
|
|
48
50
|
widgetData: localeFilteredData,
|
|
49
51
|
widgetSlug
|
|
50
52
|
};
|
package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderWidgetServerFn.js","names":["React","RenderServerComponent","extractLocaleData","renderWidgetHandler","cookies","locale","permissions","req","
|
|
1
|
+
{"version":3,"file":"renderWidgetServerFn.js","names":["React","RenderServerComponent","extractLocaleData","renderWidgetHandler","cookies","locale","permissions","req","user","widgetData","widgetSlug","Error","widgets","payload","config","admin","dashboard","importMap","widgetConfig","find","widget","slug","component","createElement","style","background","border","borderRadius","color","padding","textAlign","localeFilteredData","fields","length","serverProps","Component","error","errorMessage","message","String","logger","err","msg"],"sources":["../../../../../../src/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.ts"],"sourcesContent":["import type { Field, ServerFunction, WidgetServerProps } from 'payload'\n\nimport React from 'react'\n\nimport { RenderServerComponent } from '../../../../../elements/RenderServerComponent/index.js'\nimport { extractLocaleData } from '../utils/localeUtils.js'\n\nexport type RenderWidgetServerFnArgs = {\n /**\n * Instance-specific data for this widget\n */\n widgetData?: Record<string, unknown>\n /**\n * The slug of the widget to render\n */\n widgetSlug: string\n}\n\nexport type RenderWidgetServerFnReturnType = {\n component: React.ReactNode\n}\n\n/**\n * Server function to render a widget on-demand.\n * Similar to render-field but specifically for dashboard widgets.\n */\nexport const renderWidgetHandler: ServerFunction<\n RenderWidgetServerFnArgs,\n RenderWidgetServerFnReturnType\n> = ({ cookies, locale, permissions, req, user, widgetData, widgetSlug }) => {\n if (!req.user) {\n throw new Error('Unauthorized')\n }\n\n const { widgets } = req.payload.config.admin.dashboard\n const { importMap } = req.payload\n\n // Find the widget configuration\n const widgetConfig = widgets.find((widget) => widget.slug === widgetSlug)\n\n if (!widgetConfig) {\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--color-bg-secondary)',\n border: 'var(--stroke-width-small) solid var(--color-border)',\n borderRadius: 'var(--radius-medium)',\n color: 'var(--color-text)',\n padding: 'var(--spacer-3)',\n textAlign: 'center',\n },\n },\n `Widget \"${widgetSlug}\" not found`,\n ),\n }\n }\n\n try {\n const localeFilteredData = widgetConfig.fields?.length\n ? extractLocaleData(widgetData || {}, req.locale || 'en', widgetConfig.fields)\n : widgetData || {}\n\n const serverProps: WidgetServerProps = {\n cookies,\n locale,\n permissions,\n req,\n user,\n widgetData: localeFilteredData,\n widgetSlug,\n }\n\n // Render the widget server component\n const component = RenderServerComponent({\n Component: widgetConfig.Component,\n importMap,\n serverProps,\n })\n\n return { component }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n\n req.payload.logger.error({\n err: error,\n msg: `Error rendering widget \"${widgetSlug}\": ${errorMessage}`,\n })\n\n return {\n component: React.createElement(\n 'div',\n {\n style: {\n background: 'var(--color-bg-danger-tertiary)',\n border: 'var(--stroke-width-small) solid var(--color-border-danger)',\n borderRadius: 'var(--radius-medium)',\n color: 'var(--color-text-danger)',\n padding: 'var(--spacer-3)',\n textAlign: 'center',\n },\n },\n 'Error loading widget',\n ),\n }\n }\n}\n"],"mappings":"AAEA,OAAOA,KAAA,MAAW;AAElB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,QAAQ;AAiBlC;;;;AAIA,OAAO,MAAMC,mBAAA,GAGTA,CAAC;EAAEC,OAAO;EAAEC,MAAM;EAAEC,WAAW;EAAEC,GAAG;EAAEC,IAAI;EAAEC,UAAU;EAAEC;AAAU,CAAE;EACtE,IAAI,CAACH,GAAA,CAAIC,IAAI,EAAE;IACb,MAAM,IAAIG,KAAA,CAAM;EAClB;EAEA,MAAM;IAAEC;EAAO,CAAE,GAAGL,GAAA,CAAIM,OAAO,CAACC,MAAM,CAACC,KAAK,CAACC,SAAS;EACtD,MAAM;IAAEC;EAAS,CAAE,GAAGV,GAAA,CAAIM,OAAO;EAEjC;EACA,MAAMK,YAAA,GAAeN,OAAA,CAAQO,IAAI,CAAEC,MAAA,IAAWA,MAAA,CAAOC,IAAI,KAAKX,UAAA;EAE9D,IAAI,CAACQ,YAAA,EAAc;IACjB,OAAO;MACLI,SAAA,EAAWtB,KAAA,CAAMuB,aAAa,CAC5B,OACA;QACEC,KAAA,EAAO;UACLC,UAAA,EAAY;UACZC,MAAA,EAAQ;UACRC,YAAA,EAAc;UACdC,KAAA,EAAO;UACPC,OAAA,EAAS;UACTC,SAAA,EAAW;QACb;MACF,GACA,WAAWpB,UAAA,aAAuB;IAEtC;EACF;EAEA,IAAI;IACF,MAAMqB,kBAAA,GAAqBb,YAAA,CAAac,MAAM,EAAEC,MAAA,GAC5C/B,iBAAA,CAAkBO,UAAA,IAAc,CAAC,GAAGF,GAAA,CAAIF,MAAM,IAAI,MAAMa,YAAA,CAAac,MAAM,IAC3EvB,UAAA,IAAc,CAAC;IAEnB,MAAMyB,WAAA,GAAiC;MACrC9B,OAAA;MACAC,MAAA;MACAC,WAAA;MACAC,GAAA;MACAC,IAAA;MACAC,UAAA,EAAYsB,kBAAA;MACZrB;IACF;IAEA;IACA,MAAMY,SAAA,GAAYrB,qBAAA,CAAsB;MACtCkC,SAAA,EAAWjB,YAAA,CAAaiB,SAAS;MACjClB,SAAA;MACAiB;IACF;IAEA,OAAO;MAAEZ;IAAU;EACrB,EAAE,OAAOc,KAAA,EAAO;IACd,MAAMC,YAAA,GAAeD,KAAA,YAAiBzB,KAAA,GAAQyB,KAAA,CAAME,OAAO,GAAGC,MAAA,CAAOH,KAAA;IAErE7B,GAAA,CAAIM,OAAO,CAAC2B,MAAM,CAACJ,KAAK,CAAC;MACvBK,GAAA,EAAKL,KAAA;MACLM,GAAA,EAAK,2BAA2BhC,UAAA,MAAgB2B,YAAA;IAClD;IAEA,OAAO;MACLf,SAAA,EAAWtB,KAAA,CAAMuB,aAAa,CAC5B,OACA;QACEC,KAAA,EAAO;UACLC,UAAA,EAAY;UACZC,MAAA,EAAQ;UACRC,YAAA,EAAc;UACdC,KAAA,EAAO;UACPC,OAAA,EAAS;UACTC,SAAA,EAAW;QACb;MACF,GACA;IAEJ;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Dashboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAYvC,wBAAsB,aAAa,CAAC,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Dashboard/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EACV,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,KAAmB,MAAM,OAAO,CAAA;AAYvC,wBAAsB,aAAa,CAAC,KAAK,EAAE,oBAAoB,8BA0C9D"}
|
|
@@ -17,8 +17,7 @@ export async function DashboardView(props) {
|
|
|
17
17
|
payload: {
|
|
18
18
|
config
|
|
19
19
|
},
|
|
20
|
-
payload
|
|
21
|
-
user
|
|
20
|
+
payload
|
|
22
21
|
},
|
|
23
22
|
req,
|
|
24
23
|
visibleEntities
|
|
@@ -46,7 +45,7 @@ export async function DashboardView(props) {
|
|
|
46
45
|
payload,
|
|
47
46
|
permissions,
|
|
48
47
|
server: req.server,
|
|
49
|
-
user,
|
|
48
|
+
user: props.user,
|
|
50
49
|
visibleEntities
|
|
51
50
|
}
|
|
52
51
|
})]
|