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
25.74k stars 1.64k forks source link

Can't use label function for document view tab #8314

Closed amun1620 closed 1 month ago

amun1620 commented 2 months ago

Link to reproduction

No response

Environment Info

Node: 20.17.0
Payload: 3.0.0-beta.107
Next: 15.0.0-canary.104

Describe the Bug

Using a function to set the tab label on a custom document view throws this error:

 ⨯ Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.
  {label: function label, href: ...}
          ^^^^^^^^^^^^^^
    at stringify (<anonymous>)
    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)

Reproduction Steps

  admin: {
    components: {
      views: {
        edit: {
          customView: {
            Component: "/src/components/custom-view#CustomView",
            path: "/custom-view",
            tab: {
              label: ({ t }) => t("myCollection:customViewLabel"),
              href: "/custom-view",
            },
          },
        },
      },
    },
  },

Adapters and Plugins

No response

paulpopus commented 1 month ago

Fixed in https://github.com/payloadcms/payload/pull/8339

github-actions[bot] commented 1 month ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.