Merge pull request #7008 from Aj-vrod/master

Hide pagination when there's just one page
This commit is contained in:
Fredrik Adelöw
2021-09-01 11:02:58 +02:00
committed by GitHub
4 changed files with 18 additions and 9 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-catalog': patch
'@backstage/plugin-org': patch
---
This change hides pagination counter of search tables and group members list when results fit in one page
@@ -83,13 +83,15 @@ const SearchResultList = ({ results }: SearchResultSet) => {
}
})}
</List>
<Pagination
count={pageAmount}
page={page}
onChange={changePage}
showFirstButton
showLastButton
/>
{pageAmount > 1 && (
<Pagination
count={pageAmount}
page={page}
onChange={changePage}
showFirstButton
showLastButton
/>
)}
</>
);
};
@@ -145,13 +145,14 @@ export const CatalogTable = ({ columns, actions }: CatalogTableProps) => {
if (typeColumn) {
typeColumn.hidden = !showTypeColumn;
}
const showPagination = rows.length > 20;
return (
<Table<EntityRow>
isLoading={loading}
columns={columns || defaultColumns}
options={{
paging: true,
paging: showPagination,
pageSize: 20,
actionsColumnIndex: -1,
loadingType: 'linear',
@@ -174,7 +174,7 @@ export const MembersListCard = (_props: {
<InfoCard
title={`Members (${members?.length || 0}${paginationLabel})`}
subheader={`of ${displayName}`}
actions={pagination}
{...(nbPages <= 1 ? {} : { actions: pagination })}
>
<Grid container spacing={3}>
{members && members.length > 0 ? (