Skip to content

Commit

Permalink
remove other types
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpopus committed Oct 15, 2024
1 parent e6dec93 commit 3754e9b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 56 deletions.
8 changes: 2 additions & 6 deletions packages/payload/src/admin/fields/Tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import type { MarkOptional } from 'ts-essentials'
import type {
ClientField,
NamedTab,
NamedTabWithCondition,
TabsField,
TabsFieldClient,
UnnamedTab,
UnnamedTabWithCondition,
} from '../../fields/config/types.js'
import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../forms/Error.js'
import type {
Expand All @@ -24,10 +22,8 @@ import type {
} from '../types.js'

export type ClientTab =
| ({ fields: ClientField[] } & Omit<NamedTab, 'fields'>)
| ({ fields: ClientField[] } & Omit<UnnamedTab, 'fields'>)
| ({ fields: ClientField[]; passesCondition: boolean } & Omit<NamedTabWithCondition, 'fields'>)
| ({ fields: ClientField[]; passesCondition: boolean } & Omit<UnnamedTabWithCondition, 'fields'>)
| ({ fields: ClientField[]; passesCondition?: boolean } & Omit<NamedTab, 'fields'>)
| ({ fields: ClientField[]; passesCondition?: boolean } & Omit<UnnamedTab, 'fields'>)

type TabsFieldClientWithoutType = MarkOptional<TabsFieldClient, 'type'>

Expand Down
3 changes: 0 additions & 3 deletions packages/payload/src/config/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { sanitizeGlobals } from '../globals/config/sanitize.js'
import { getLockedDocumentsCollection } from '../lockedDocuments/lockedDocumentsCollection.js'
import getPreferencesCollection from '../preferences/preferencesCollection.js'
import checkDuplicateCollections from '../utilities/checkDuplicateCollections.js'
import checkDuplicateTabsIds from '../utilities/checkDuplicateTabsIds.js'
import { defaults } from './defaults.js'

const sanitizeAdminConfig = (configToSanitize: Config): Partial<SanitizedConfig> => {
Expand Down Expand Up @@ -201,8 +200,6 @@ export const sanitizeConfig = async (incomingConfig: Config): Promise<SanitizedC
}
}

checkDuplicateTabsIds(config.collections)

const promises: Promise<void>[] = []
for (const sanitizeFunction of richTextSanitizationPromises) {
promises.push(sanitizeFunction(config as SanitizedConfig))
Expand Down
25 changes: 10 additions & 15 deletions packages/payload/src/fields/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,9 @@ export type CollapsibleFieldClient = {
Pick<CollapsibleField, 'type'>

type TabBase = {
admin?: {
condition?: Pick<Admin, 'condition'>
}
description?: Description
fields: Field[]
interfaceName?: string
Expand All @@ -782,10 +785,6 @@ export type NamedTab = {
interfaceName?: string
} & TabBase

export type NamedTabWithCondition = {
admin?: Pick<Admin, 'condition'>
} & NamedTab

export type UnnamedTab = {
interfaceName?: never
/**
Expand All @@ -802,30 +801,26 @@ export type UnnamedTab = {
localized?: never
} & Omit<TabBase, 'name' | 'virtual'>

export type UnnamedTabWithCondition = {
admin?: Pick<Admin, 'condition'>
} & UnnamedTab

export type TabWithoutCondition = NamedTab | UnnamedTab
export type TabWithCondition = NamedTabWithCondition | UnnamedTabWithCondition
export type Tab = TabWithCondition | TabWithoutCondition
export type Tab = NamedTab | UnnamedTab

export type TabsField = {
admin?: Omit<Admin, 'description'>
type: 'tabs'
} & ({ id: string; tabs: TabWithCondition[] } | { id?: never; tabs: TabWithoutCondition[] }) &
Omit<FieldBase, 'admin' | 'localized' | 'name' | 'saveToJWT' | 'virtual'>
} & { id: string; tabs: Tab[] } & Omit<
FieldBase,
'admin' | 'localized' | 'name' | 'saveToJWT' | 'virtual'
>

export type TabsFieldClient = {
admin?: Omit<AdminClient, 'description'>
tabs: ClientTab[]
} & Omit<FieldBaseClient, 'admin' | 'localized' | 'name' | 'saveToJWT'> &
Pick<TabsField, 'id' | 'type'>
Pick<TabsField, 'type'>

export type TabAsField = {
name?: string
type: 'tab'
} & TabWithCondition
} & Tab

export type TabAsFieldClient = ClientTab & Pick<TabAsField, 'name' | 'type'>

Expand Down
2 changes: 0 additions & 2 deletions packages/payload/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,6 @@ export type {
Labels,
LabelsClient,
NamedTab,
NamedTabWithCondition,
NonPresentationalField,
NonPresentationalFieldClient,
NumberField,
Expand Down Expand Up @@ -942,7 +941,6 @@ export type {
UIField,
UIFieldClient,
UnnamedTab,
UnnamedTabWithCondition,
UploadField,
UploadFieldClient,
Validate,
Expand Down
30 changes: 0 additions & 30 deletions packages/payload/src/utilities/checkDuplicateTabsIds.ts

This file was deleted.

0 comments on commit 3754e9b

Please sign in to comment.