feat(admin): add permission-based filtering to admin navigation
- add optional `permission` field to nav items in registry - filter nav items by user permissions in `buildNavigationSections` - auto-hide sections when all their items are filtered out - fetch user permissions in `AdminLayout.server.js` and pass to navigation builder - update docs and README to document `permission` param and new signature
This commit is contained in:
+1
-1
@@ -88,7 +88,7 @@ registerWidgetFetcher('orders', async () => ({ total: await countOrders() }));
|
||||
registerWidget({ id: 'orders', Component: OrdersWidget, order: 20 });
|
||||
|
||||
registerNavSection({ id: 'commerce', title: 'Commerce', icon: 'ShoppingBag03Icon', order: 30 });
|
||||
registerNavItem({ id: 'orders', label: 'Commandes', icon: 'ShoppingBag03Icon', href: '/admin/orders', sectionId: 'commerce' });
|
||||
registerNavItem({ id: 'orders', label: 'Commandes', icon: 'ShoppingBag03Icon', href: '/admin/orders', sectionId: 'commerce', permission: 'orders.view' });
|
||||
|
||||
registerPage({ slug: 'orders', Component: OrdersPage, title: 'Commandes' });
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user