Merge pull request #27129 from drodil/offset_table_toolbar

fix: use default catalog toolbar for offset catalog table
This commit is contained in:
Fredrik Adelöw
2024-11-16 13:03:02 +01:00
committed by GitHub
2 changed files with 12 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog': patch
---
Fixed an issue causing the `CatalogIndexPage` to not properly filter results when using offset pagination.
@@ -18,10 +18,8 @@ import React, { useEffect } from 'react';
import { Table, TableProps } from '@backstage/core-components';
import { CatalogTableRow } from './types';
import {
EntityTextFilter,
useEntityList,
} from '@backstage/plugin-catalog-react';
import { useEntityList } from '@backstage/plugin-catalog-react';
import { CatalogTableToolbar } from './CatalogTableToolbar';
/**
* @internal
@@ -30,8 +28,8 @@ export function OffsetPaginatedCatalogTable(
props: TableProps<CatalogTableRow>,
) {
const { columns, data, isLoading, options } = props;
const { updateFilters, setLimit, setOffset, limit, totalItems, offset } =
useEntityList();
const { setLimit, setOffset, limit, totalItems, offset } = useEntityList();
const [page, setPage] = React.useState(
offset && limit ? Math.floor(offset / limit) : 0,
);
@@ -55,11 +53,9 @@ export function OffsetPaginatedCatalogTable(
emptyRowsWhenPaging: false,
...options,
}}
onSearchChange={(searchText: string) =>
updateFilters({
text: searchText ? new EntityTextFilter(searchText) : undefined,
})
}
components={{
Toolbar: CatalogTableToolbar,
}}
page={page}
onPageChange={newPage => {
setPage(newPage);