fix(ui): client side error when passing labels as functions for custom view tabs (#8339)

This commit is contained in:
Paul
2024-09-20 11:32:46 -06:00
committed by GitHub
parent afb8805a9b
commit 1f7d47a361

View File

@@ -250,6 +250,15 @@ export const createClientCollectionConfig = ({
)
}
// Ensure that the label in Edit view is a string, translate it if it's a function
if (collection?.admin?.components?.views?.edit) {
Object.entries(collection?.admin?.components?.views?.edit).forEach(([key, view]) => {
if ('tab' in view && 'label' in view.tab && typeof view.tab.label === 'function') {
collection.admin.components.views.edit[key].tab.label = view.tab.label({ t: i18n.t })
}
})
}
clientCollection.admin.components.views = (
collection?.admin?.components?.views
? deepCopyObjectSimple(collection?.admin?.components?.views)