From 69a021b10e3af59b061a2d7edcb0c0cde9b7a032 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 10 Nov 2023 13:45:07 +0100 Subject: [PATCH] catalog: add PaginatedCatalogTable component Signed-off-by: Vincenzo Scamporlino --- .../CatalogTable/PaginatedCatalogTable.tsx | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 plugins/catalog/src/components/CatalogTable/PaginatedCatalogTable.tsx diff --git a/plugins/catalog/src/components/CatalogTable/PaginatedCatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/PaginatedCatalogTable.tsx new file mode 100644 index 0000000000..e74dfca78b --- /dev/null +++ b/plugins/catalog/src/components/CatalogTable/PaginatedCatalogTable.tsx @@ -0,0 +1,59 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React from 'react'; +import Box from '@material-ui/core/Box'; + +import { BaseTable, TableProps, tableStyles } from '@backstage/core-components'; +import { CatalogTableRow } from './types'; +import { useEntityList } from '@backstage/plugin-catalog-react'; + +export function PaginatedCatalogTable(props: TableProps) { + const { columns, data } = props; + const tableClasses = tableStyles(); + + const { next, prev } = useEntityList(); + + return ( + <> + + { + if (page > 0) { + next?.(); + } else { + prev?.(); + } + }} + /* this will enable the prev button accordingly */ + page={prev ? 1 : 0} + /* this will enable the next button accordingly */ + totalCount={next ? Number.MAX_VALUE : Number.MAX_SAFE_INTEGER} + localization={{ pagination: { labelDisplayedRows: '' } }} + /> + + + ); +}