File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -946,7 +946,8 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
946946 if ( menuItem . label ) {
947947 translateRoutines . push (
948948 ( async ( ) => {
949- menuItem . label = await tr ( menuItem . label , `menu.${ menuItem . itemId } ` ) ;
949+ const rawLabel = typeof menuItem . label === 'function' ? await menuItem . label ( adminUser , this . adminforth ) : menuItem . label ;
950+ menuItem . label = await tr ( rawLabel , `menu.${ menuItem . itemId } ` ) ;
950951 } ) ( )
951952 ) ;
952953 }
Original file line number Diff line number Diff line change @@ -1104,8 +1104,16 @@ export interface AdminForthConfigMenuItem {
11041104
11051105 /**
11061106 * Label for menu item which will be displayed in the admin panel.
1107+ * Can be a static string or a callback which receives the current admin user
1108+ * and returns the label dynamically.
1109+ *
1110+ * Example:
1111+ *
1112+ * ```ts
1113+ * label: (adminUser) => adminUser.dbUser.role === 'superadmin' ? 'Dashboard (CRS)' : 'Dashboard',
1114+ * ```
11071115 */
1108- label ?: string ,
1116+ label ?: string | ( ( user : AdminUser , adminForth : IAdminForth ) => Promise < string > | string ) ,
11091117
11101118 /**
11111119 * Icon for menu item which will be displayed in the admin panel.
You can’t perform that action at this time.
0 commit comments