refactor(next): simplify document tab rendering logic (#12795)

Simplifies the rendering logic around document tabs in the following
ways:

- Merges default tabs with custom tabs in a more predictable way, now
there is only a single array of tabs to iterate over, no more concept of
"custom" tabs vs "default" tabs, there's now just "tabs"
- Deduplicates rendering conditions for all tabs, now any changes to
default tabs would also apply to custom tabs with half the code
- Removes unnecessary `getCustomViews` function, this is a relic of the
past
- Removes unnecessary `getViewConfig` function, this is a relic of the
past
- Removes unused `references`, `relationships`, and `version` key
placeholders, these are relics of the past
- Prevents tab conditions from running twice unnecessarily
- Other misc. cleanup like unnecessarily casting the tab conditions
result to a boolean, etc.
This commit is contained in:
Jacob Fletcher
2025-06-13 07:12:28 -04:00
committed by GitHub
parent 729b676e98
commit 53835f2620
7 changed files with 188 additions and 294 deletions

View File

@@ -90,6 +90,7 @@ export interface Config {
with300documents: With300Document;
'with-list-drawer': WithListDrawer;
placeholder: Placeholder;
'use-as-title-group-field': UseAsTitleGroupField;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
@@ -119,6 +120,7 @@ export interface Config {
with300documents: With300DocumentsSelect<false> | With300DocumentsSelect<true>;
'with-list-drawer': WithListDrawerSelect<false> | WithListDrawerSelect<true>;
placeholder: PlaceholderSelect<false> | PlaceholderSelect<true>;
'use-as-title-group-field': UseAsTitleGroupFieldSelect<false> | UseAsTitleGroupFieldSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
@@ -523,6 +525,16 @@ export interface Placeholder {
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "use-as-title-group-field".
*/
export interface UseAsTitleGroupField {
id: string;
name?: string | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
@@ -621,6 +633,10 @@ export interface PayloadLockedDocument {
| ({
relationTo: 'placeholder';
value: string | Placeholder;
} | null)
| ({
relationTo: 'use-as-title-group-field';
value: string | UseAsTitleGroupField;
} | null);
globalSlug?: string | null;
user: {
@@ -987,6 +1003,15 @@ export interface PlaceholderSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "use-as-title-group-field_select".
*/
export interface UseAsTitleGroupFieldSelect<T extends boolean = true> {
name?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select".