Compare commits

...

1 Commits

Author SHA1 Message Date
Paul Popus
2e80b38ab6 fix(ui): issue with tab labels not changing based on language when its a function 2024-09-25 21:53:30 -06:00
4 changed files with 16 additions and 10 deletions

View File

@@ -42,6 +42,12 @@ export type DocumentTabConfig = {
readonly Pill?: PayloadComponent
}
export type ClientDocumentTabConfig = {
condition?: never
isActive?: boolean
label?: string
} & DocumentTabConfig
export type DocumentTabComponent = PayloadComponent<{
path: string
}>

View File

@@ -11,6 +11,7 @@ export type { CustomPublishButton } from './elements/PublishButton.js'
export type { CustomSaveButton } from './elements/SaveButton.js'
export type { CustomSaveDraftButton } from './elements/SaveDraftButton.js'
export type {
ClientDocumentTabConfig,
DocumentTabComponent,
DocumentTabCondition,
DocumentTabConfig,

View File

@@ -8,7 +8,7 @@ import type { Locale, MetaConfig, PayloadComponent } from '../../config/types.js
import type { SanitizedGlobalConfig } from '../../globals/config/types.js'
import type { PayloadRequest } from '../../types/index.js'
import type { LanguageOptions } from '../LanguageOptions.js'
import type { MappedComponent } from '../types.js'
import type { ClientDocumentTabConfig, MappedComponent } from '../types.js'
export type AdminViewConfig = {
Component: AdminViewComponent
@@ -23,6 +23,7 @@ export type AdminViewConfig = {
export type MappedView = {
actions?: MappedComponent[]
Component: MappedComponent
tab?: ClientDocumentTabConfig
}
export type AdminViewProps = {

View File

@@ -250,15 +250,6 @@ 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)
@@ -315,6 +306,13 @@ export const createClientCollectionConfig = ({
)
}
// Ensure that the label in a tab in an Edit view is a string, translate it if it's a function
if ('tab' in view && 'label' in view.tab && typeof view.tab.label === 'function') {
clientCollection.admin.components.views.edit[key].tab.label = view.tab.label({
t: i18n.t,
})
}
if ('actions' in view && view.actions?.length) {
clientCollection.admin.components.views.edit[key].actions = view.actions.map((Component) =>
createMappedComponent(