fix(catalog-react): fix relation cards showing only one entity
Use `paginationOptions: { type: 'none' }` in EntityDataTable instead
of deriving page size from data length, which was 0 during the initial
loading render causing only one row to be displayed.
Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
---
|
||||
|
||||
Fixed entity relation cards (e.g., "Has components") only showing one entity at a time by using `paginationOptions: { type: 'none' }` instead of deriving page size from data length.
|
||||
@@ -132,6 +132,24 @@ describe('<EntityDataTable />', () => {
|
||||
expect(rows()[1]).toHaveTextContent('alpha');
|
||||
});
|
||||
|
||||
it('shows all rows after loading completes', async () => {
|
||||
const { rerender } = await renderInTestApp(
|
||||
<EntityDataTable columnConfig={columns} data={[]} loading />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
rerender(<EntityDataTable columnConfig={columns} data={entities} />);
|
||||
|
||||
const rows = screen.getAllByRole('row').slice(1);
|
||||
expect(rows).toHaveLength(2);
|
||||
expect(rows[0]).toHaveTextContent('bravo');
|
||||
expect(rows[1]).toHaveTextContent('alpha');
|
||||
});
|
||||
|
||||
it('does not sort when column has no sortValue', async () => {
|
||||
const unsortableColumns: EntityColumnConfig[] = [
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ export function EntityDataTable(props: EntityDataTableProps) {
|
||||
mode: 'complete',
|
||||
data: tableData,
|
||||
sortFn,
|
||||
paginationOptions: { pageSize: tableData.length || 1 },
|
||||
paginationOptions: { type: 'none' },
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -71,7 +71,6 @@ export function EntityDataTable(props: EntityDataTableProps) {
|
||||
loading={loading}
|
||||
error={error}
|
||||
emptyState={emptyState}
|
||||
pagination={{ type: 'none' }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user