fix: use default catalog toolbar for offset catalog table

mostly to get debounce working the same way with the entity text filter

Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
Heikki Hellgren
2024-10-15 10:16:57 +03:00
committed by Vincenzo Scamporlino
parent a59622755f
commit 2a6759430b
2 changed files with 12 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog': patch
---
Use default `CatalogTableToolbar` for offset paginated catalog table
@@ -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);