File tree Expand file tree Collapse file tree
payload-authjs/src/payload/collection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -178,6 +178,7 @@ export interface User {
178178 id ?: string | null ;
179179 } [ ]
180180 | null ;
181+ sidebarField ?: string | null ;
181182 updatedAt : string ;
182183 createdAt : string ;
183184 enableAPIKey ?: boolean | null ;
@@ -330,6 +331,7 @@ export interface UsersSelect<T extends boolean = true> {
330331 credentialDeviceType ?: T ;
331332 id ?: T ;
332333 } ;
334+ sidebarField ?: T ;
333335 updatedAt ?: T ;
334336 createdAt ?: T ;
335337 enableAPIKey ?: T ;
Original file line number Diff line number Diff line change @@ -176,6 +176,13 @@ const Users: CollectionConfig<"users"> = {
176176 } ) ,
177177 ] ,
178178 } ,
179+ {
180+ name : "sidebarField" ,
181+ type : "text" ,
182+ admin : {
183+ position : "sidebar" ,
184+ } ,
185+ } ,
179186 /* {
180187 name: "examples",
181188 type: "join",
Original file line number Diff line number Diff line change 1- import type { CollectionConfig , TabsField } from "payload" ;
1+ import type { CollectionConfig , Field , TabsField } from "payload" ;
22import {
33 isEmailProviderAvailable ,
44 isSessionStrategyDatabase ,
@@ -93,8 +93,21 @@ export const generateUsersCollection = (
9393 ] ,
9494 patchFields : collection . fields , // User defined fields
9595 } ) ;
96+ const { topLevelFields, restTabFields } = restFields . reduce (
97+ ( acc , field ) => {
98+ // Sidebar fields must put at the top level
99+ if ( field . admin ?. position === "sidebar" ) {
100+ acc . topLevelFields . push ( field ) ;
101+ } else {
102+ acc . restTabFields . push ( field ) ;
103+ }
104+ return acc ;
105+ } ,
106+ { topLevelFields : [ ] as Field [ ] , restTabFields : [ ] as Field [ ] } ,
107+ ) ;
96108 collection . fields = mergedFields ;
97- ( collection . fields [ 1 ] as TabsField ) . tabs [ 0 ] . fields . push ( ...restFields ) ; // Add the rest fields to the general tab
109+ collection . fields . push ( ...topLevelFields ) ; // Add top-level fields
110+ ( collection . fields [ 1 ] as TabsField ) . tabs [ 0 ] . fields . push ( ...restTabFields ) ; // Add the rest fields to the general tab
98111
99112 // Override the access control
100113 collection . access = {
You can’t perform that action at this time.
0 commit comments