Skip to content

Commit 93b90da

Browse files
authored
fix(ui): use consistent empty state styling in relationship table (#15914)
# Overview Applies the same empty state styling fix from #15555 to the `RelationshipTable` component. ## Key Changes - Replaced inline empty state div with shared `NoListResults` component - `RelationshipTable` was using its own inline implementation with different styling - Now uses the same centered, dashed-border design as List, Folder, and Browse-by-Folder views - Restructured empty state to use `Message` and `Actions` props - Message includes heading ("No Results.") and description - Actions conditionally includes the AddNewButton when user has create permission ## Design Decisions Follows the exact pattern from #15555 where all list views were standardized to use the `NoListResults` component. `RelationshipTable` was missed in that PR and had the same inconsistent left-aligned, no-border styling. The shared component ensures visual consistency across all empty states in the admin UI. ### Before <img width="1329" height="142" alt="Screenshot 2026-03-11 at 1 53 19 PM" src="https://github.com/user-attachments/assets/f85284a0-8abf-49f7-b6bf-6058e514ad1a" /> ### After <img width="1313" height="188" alt="Screenshot 2026-03-11 at 2 23 02 PM" src="https://github.com/user-attachments/assets/aa84c3b7-ae01-44ae-a767-b2c14a87fe71" />
1 parent 62f2b7c commit 93b90da

File tree

2 files changed

+49
-23
lines changed

2 files changed

+49
-23
lines changed

packages/ui/src/elements/RelationshipTable/index.tsx

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { useTranslation } from '../../providers/Translation/index.js'
2525
import { AnimateHeight } from '../AnimateHeight/index.js'
2626
import { ColumnSelector } from '../ColumnSelector/index.js'
2727
import { useDocumentDrawer } from '../DocumentDrawer/index.js'
28+
import { NoListResults } from '../NoListResults/index.js'
2829
import { RelationshipProvider } from '../Table/RelationshipProvider/index.js'
2930
import { AddNewButton } from './AddNewButton.js'
3031
import { DrawerLink } from './cells/DrawerLink/index.js'
@@ -332,29 +333,41 @@ export const RelationshipTable: React.FC<RelationshipTableComponentProps> = (pro
332333
) : (
333334
<Fragment>
334335
{data?.docs && data.docs.length === 0 && (
335-
<div className={`${baseClass}__no-results`}>
336-
<p>
337-
{i18n.t('general:noResults', {
338-
label: isPolymorphic
339-
? i18n.t('general:documents')
340-
: getTranslation(collectionConfig?.labels?.plural, i18n),
341-
})}
342-
</p>
343-
<AddNewButton
344-
allowCreate={canCreate}
345-
baseClass={baseClass}
346-
collections={config.collections}
347-
i18n={i18n}
348-
label={i18n.t('general:createNewLabel', {
349-
label: isPolymorphic
350-
? i18n.t('general:document')
351-
: getTranslation(collectionConfig?.labels?.singular, i18n),
352-
})}
353-
onClick={isPolymorphic ? setSelectedCollection : openDrawer}
354-
permissions={permissions}
355-
relationTo={relationTo}
356-
/>
357-
</div>
336+
<NoListResults
337+
Actions={
338+
canCreate
339+
? [
340+
<AddNewButton
341+
allowCreate={canCreate}
342+
baseClass={baseClass}
343+
collections={config.collections}
344+
i18n={i18n}
345+
key="create"
346+
label={i18n.t('general:createNewLabel', {
347+
label: isPolymorphic
348+
? i18n.t('general:document')
349+
: getTranslation(collectionConfig?.labels?.singular, i18n),
350+
})}
351+
onClick={isPolymorphic ? setSelectedCollection : openDrawer}
352+
permissions={permissions}
353+
relationTo={relationTo}
354+
/>,
355+
]
356+
: []
357+
}
358+
Message={
359+
<>
360+
<h3>{i18n.t('general:noResultsFound')}</h3>
361+
<p>
362+
{i18n.t('general:noResults', {
363+
label: isPolymorphic
364+
? i18n.t('general:documents')
365+
: getTranslation(collectionConfig?.labels?.plural, i18n),
366+
})}
367+
</p>
368+
</>
369+
}
370+
/>
358371
)}
359372
{data?.docs && data.docs.length > 0 && (
360373
<RelationshipProvider>

test/joins/payload-types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ export interface Config {
201201
globals: {};
202202
globalsSelect: {};
203203
locale: 'en' | 'es';
204+
widgets: {
205+
collections: CollectionsWidget;
206+
};
204207
user: User;
205208
jobs: {
206209
tasks: unknown;
@@ -1454,6 +1457,16 @@ export interface PayloadMigrationsSelect<T extends boolean = true> {
14541457
updatedAt?: T;
14551458
createdAt?: T;
14561459
}
1460+
/**
1461+
* This interface was referenced by `Config`'s JSON-Schema
1462+
* via the `definition` "collections_widget".
1463+
*/
1464+
export interface CollectionsWidget {
1465+
data?: {
1466+
[k: string]: unknown;
1467+
};
1468+
width: 'full';
1469+
}
14571470
/**
14581471
* This interface was referenced by `Config`'s JSON-Schema
14591472
* via the `definition` "auth".

0 commit comments

Comments
 (0)