SoftwareBrothers / adminjs

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

[Feature]: Set or change resources and pages after login #1591

Closed mattrochon closed 4 months ago

mattrochon commented 7 months ago

Description

I'd like to be able to set, or change the list of resources and pages for a user once they log in to the app. This would allow me to customize the experience for different user roles.

Alternatively, if there was 'isAccessible' functionality associated with pages, that would work too.

Suggested Solution

either a way to update the resources/pages list per user, after they log in

or

pages support isAccessible functionality

Alternatives

I could handle this int he page handler, but the link would still exist in the nav and thats not a great UX

Additional Context

No response

dziraf commented 7 months ago

For resources you can define isAccessible in list action to hide them from the sidebar.

For pages, you can override SidebarPages component and filter out pages based on currentAdmin (const [currentAdmin] = useCurrentAdmin()): https://github.com/SoftwareBrothers/adminjs/blob/master/src/frontend/components/app/sidebar/sidebar-pages.tsx

I agree that isAccessible for pages would be ideal. There had been a pull request that was supposed to introduce it but it wasn't ready to merge and it's author eventually stopped working on it:

https://github.com/SoftwareBrothers/adminjs/pull/1262

mattrochon commented 7 months ago

Yea I overrode sidebar to make my custom left nav menu, just thought that isAccessible would be alot more consistent witht he adminjs pattern. Thanks for the response!