SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.15k stars 659 forks source link

[Bug]: AdminPages type is different from the example provided #1686

Closed ESnark closed 1 month ago

ESnark commented 1 month ago

Contact Details

No response

What happened?

@example

pages: {
  customPage: {
    label: "Custom page",
    handler: async (request, response, context) => {
      return {
        text: 'I am fetched from the backend',
      }
    },
    component: 'CustomPage',
  },
  anotherPage: {
    label: "TypeScript page",
    component: 'TestComponent',
  },
},

According to the example, It's possible to label pages, but label property is not included in AdminPages type.

Is this an unintended typing error, or is the example not updated?

Bug prevalence

-

AdminJS dependencies version

What browsers do you see the problem on?

No response

Relevant log output

No response

Relevant code that's giving you issues

No response

dziraf commented 1 month ago

The example seems to be outdated although I don't think label has ever been usable 🤔

To label/translate pages you should use pages in locale:

{
  language: 'en',
  debug: false,
  availableLanguages: ['en'],
  translations: {
    en: {
      pages: {
        customPage: 'My custom page'
      }
    }
  }
}
ESnark commented 1 month ago

Thank you for clarifying this. It will be helpful for future contributions.