payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
24.74k stars 1.57k forks source link

No longer possible to put custom views under `/collections/<slug>` #8664

Open tyteen4a03 opened 2 weeks ago

tyteen4a03 commented 2 weeks ago

Link to reproduction

No response

Environment Info

Node.js v22.7.0

Binaries: Node: 22.7.0 npm: 10.8.2 Yarn: N/A pnpm: 9.12.1 Relevant Packages: payload: 3.0.0-beta.113 Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10

Describe the Bug

Custom views in v3 no longer support routing views under /collection/<slug>, which used to be possible in v2.

I'm not sure if this is a bug or if this is intended. Either way, clarification would be good.

Reproduction Steps

Add a custom with a config like this:

                JobSheetDocument: {
                    Component: "@/modules/transport/components/JobSheetDocument/JobSheetDocument",
                    path: "/collections/jobs/:id/job-sheet",
                    exact: true,
                },

(the easiest way to check this is by modifying customParamViewPath to /collections/users/:id/view (https://github.com/payloadcms/payload/blob/a526c7becdf0309cf6069923c8d2ccd1f7a66a9f/test/admin/shared.ts#L11)

Adapters and Plugins

No response

JarrodMFlesch commented 1 week ago

I think we could totally support this. We just need to put together a hard-coded list of slugs that could appear in the "/collections/:collectionSlug/:id/:pageSlug" pageSlug slot.

If we had all of those then we should be able to adjust the code here: https://github.com/payloadcms/payload/blob/beta/packages/next/src/views/Root/getViewFromConfig.ts#L180-L192