Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tyteen4a03 opened this issue Oct 12, 2024 · 2 comments
Closed

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

tyteen4a03 opened this issue Oct 12, 2024 · 2 comments

Comments

@tyteen4a03
Copy link
Contributor

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 (

export const customParamViewPath = `${customParamViewPathBase}/:id`
)

Adapters and Plugins

No response

@tyteen4a03 tyteen4a03 added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Oct 12, 2024
@JarrodMFlesch
Copy link
Contributor

JarrodMFlesch commented Oct 14, 2024

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

@jessrynkar
Copy link
Member

Hi @tyteen4a03 - v3.37.0 does support this structure of view routing, however it would need to be added from within the collection config.

E.g., to setup your example route of /collections/jobs/:id/job-sheet, you would need to do:

export const Jobs: CollectionConfig = {
  slug: jobsSlug,
  admin: {
    components: {
      views: {
        edit: {
          jobs: {
            path: '/job-sheet',
            Component: '/your-custom-view-path',
          },
        },
      },
    },
  },
}

This route would get injected after /collections/jobs/:id allowing you to access /collections/jobs/:id/job-sheet.

Side note, I see you have another issue related to root-level routes which I will check out shortly.

@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants