adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

[Bug]: Can't add labels for custom pages

Open effectivetom opened this issue 2 years ago • 1 comments

What happened?

I was hoping to add labels for my custom pages to replace the default link text, which seems to use the property name passed to AdminJSOptions.pages.

Unfortunately the documented example for the pages property in AdminJSOptions cannot be implemented because AdminPage lacks a label property.

Bug prevalence

Whenever I add a custom page

AdminJS dependencies version

"@adminjs/express": "^5.1.0",
"@adminjs/prisma": "^3.0.1",
"adminjs": "^6.8.3",
"tslib": "^2.5.0"

Relevant code that's giving you issues

const options: AdminJSOptions = {
  // ...
  pages: {
    MyCustomPage: {
      component: Components.MyCustomPage,
      label: 'My custom page', // TS error: 'label' does not exist in type 'AdminPage'
    },
  },
  // ...
}

effectivetom avatar Feb 06 '23 03:02 effectivetom

I also encountered the same issue.
It appears to function with options.locale.translations.

new AdminJS({
    // ...
    locale: {
        language: "en",
        availableLanguages: ["en"],
        translations: {
            en: {
                pages: {
                    samplePage: "This is Sample Page",
                },
            },
        },
    },
    // ...
});

ys319 avatar Sep 27 '23 06:09 ys319