Skip to content

Commit 8a2b712

Browse files
feat(ui): adds admin.components.listMenuItems option (#11230)
### What? Adds new option `admin.components.listMenuItems` to allow custom components to be injected after the existing list controls in the collection list view. ### Why? Needed to facilitate import/export plugin. #### Testing Use `pnpm dev admin` to see example component and see test added to `test/admin/e2e/list-view`. ## Update since feature was reverted The custom list controls and now rendered with no surrounding padding or border radius. <img width="596" alt="Screenshot 2025-02-17 at 5 06 44 PM" src="https://github.com/user-attachments/assets/57209367-5433-4a4c-8797-0f9671da15c8" /> --------- Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
1 parent 117949b commit 8a2b712

File tree

49 files changed

+161
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+161
-10
lines changed

docs/configuration/collections.mdx

Lines changed: 10 additions & 9 deletions

packages/next/src/views/List/renderListViewSlots.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ export const renderListViewSlots = ({
4444
})
4545
}
4646

47+
const listMenuItems = collectionConfig.admin.components?.listMenuItems
48+
if (Array.isArray(listMenuItems)) {
49+
result.listMenuItems = [
50+
RenderServerComponent({
51+
clientProps,
52+
Component: listMenuItems,
53+
importMap: payload.importMap,
54+
serverProps,
55+
}),
56+
]
57+
}
58+
4759
if (collectionConfig.admin.components?.afterListTable) {
4860
result.AfterListTable = RenderServerComponent({
4961
clientProps: clientProps satisfies AfterListTableClientProps,

packages/payload/src/admin/views/list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type ListViewSlots = {
1414
BeforeList?: React.ReactNode
1515
BeforeListTable?: React.ReactNode
1616
Description?: React.ReactNode
17+
listMenuItems?: React.ReactNode[]
1718
Table: React.ReactNode
1819
}
1920

packages/payload/src/bin/generateImportMap/iterateCollections.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export function iterateCollections({
3030
})
3131

3232
addToImportMap(collection.admin?.components?.afterList)
33+
addToImportMap(collection.admin?.components?.listMenuItems)
3334
addToImportMap(collection.admin?.components?.afterListTable)
3435
addToImportMap(collection.admin?.components?.beforeList)
3536
addToImportMap(collection.admin?.components?.beforeListTable)

packages/payload/src/collections/config/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export type CollectionAdminOptions = {
304304
*/
305305
Upload?: CustomUpload
306306
}
307+
listMenuItems?: CustomComponent[]
307308
views?: {
308309
/**
309310
* Set to a React component to replace the entire Edit View, including all nested routes.

packages/translations/src/clientKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ export const clientTranslationKeys = createClientTranslationKeys([
209209
'general:loading',
210210
'general:locale',
211211
'general:menu',
212+
'general:moreOptions',
212213
'general:moveDown',
213214
'general:moveUp',
214215
'general:next',

packages/translations/src/languages/ar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ export const arTranslations: DefaultTranslationsObject = {
266266
locale: 'اللّغة',
267267
locales: 'اللّغات',
268268
menu: 'قائمة',
269+
moreOptions: 'خيارات أكثر',
269270
moveDown: 'التّحريك إلى الأسفل',
270271
moveUp: 'التّحريك إلى الأعلى',
271272
newPassword: 'كلمة مرور جديدة',

packages/translations/src/languages/az.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export const azTranslations: DefaultTranslationsObject = {
270270
locale: 'Lokal',
271271
locales: 'Dillər',
272272
menu: 'Menyu',
273+
moreOptions: 'Daha çox seçimlər',
273274
moveDown: 'Aşağı hərəkət et',
274275
moveUp: 'Yuxarı hərəkət et',
275276
newPassword: 'Yeni şifrə',

packages/translations/src/languages/bg.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ export const bgTranslations: DefaultTranslationsObject = {
269269
locale: 'Локализация',
270270
locales: 'Локализации',
271271
menu: 'Меню',
272+
moreOptions: 'Повече опции',
272273
moveDown: 'Надолу',
273274
moveUp: 'Нагоре',
274275
newPassword: 'Нова парола',

packages/translations/src/languages/ca.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export const caTranslations: DefaultTranslationsObject = {
270270
locale: 'Idioma',
271271
locales: 'Idiomes',
272272
menu: 'Menu',
273+
moreOptions: 'Més opcions',
273274
moveDown: 'Mou avall',
274275
moveUp: 'Move amunt',
275276
newPassword: 'Nova contrasenya',

0 commit comments

Comments
 (0)