feat: remove pagination for single-page lists

This commit is contained in:
ahmadshaheer1 2024-06-23 14:33:16 +04:30 committed by Yunus M
parent 2fb5b16840
commit 580198ca7a
11 changed files with 46 additions and 25 deletions

View File

@ -20,6 +20,7 @@ import { ResizeTableProps } from './types';
function ResizeTable({
columns,
onDragColumn,
pagination,
...restProps
}: ResizeTableProps): JSX.Element {
const [columnsData, setColumns] = useState<ColumnsType>([]);
@ -63,8 +64,10 @@ function ResizeTable({
...restProps,
components: { header: { cell: ResizableHeader } },
columns: mergedColumns,
hideOnSinglePage: true,
pagination: { ...pagination, hideOnSinglePage: true },
}),
[mergedColumns, restProps],
[mergedColumns, pagination, restProps],
);
useEffect(() => {

View File

@ -423,6 +423,7 @@ function AllErrors(): JSX.Element {
current: getUpdatedOffset / 10 + 1,
position: ['bottomLeft'],
total: errorCountResponse.data?.payload || 0,
hideOnSinglePage: true,
}}
onChange={onChangeHandler}
/>

View File

@ -389,6 +389,7 @@ function ListAlert({ allAlertRules, refetch }: ListAlertProps): JSX.Element {
onChange={handleChange}
pagination={{
defaultCurrent: Number(paginationParam) || 1,
hideOnSinglePage: true,
}}
facingIssueBtn={{
attributes: {

View File

@ -609,6 +609,16 @@ function DashboardsList(): JSX.Element {
</>
);
const paginationConfig = data.length > 20 && {
pageSize: 20,
showTotal: showPaginationItem,
showSizeChanger: false,
onChange: (page: any): void => handlePageSizeUpdate(page),
current: Number(sortOrder.pagination),
defaultCurrent: Number(sortOrder.pagination) || 1,
hideOnSinglePage: true,
};
return (
<div className="dashboards-list-container">
<div className="dashboards-list-view-content">
@ -822,16 +832,7 @@ function DashboardsList(): JSX.Element {
showSorterTooltip
loading={isDashboardListLoading || isFilteringDashboards}
showHeader={false}
pagination={
data.length > 20 && {
pageSize: 20,
showTotal: showPaginationItem,
showSizeChanger: false,
onChange: (page): void => handlePageSizeUpdate(page),
current: Number(sortOrder.pagination),
defaultCurrent: Number(sortOrder.pagination) || 1,
}
}
pagination={paginationConfig}
/>
</>
)}

View File

@ -1,3 +1,4 @@
export const historyPagination = {
defaultPageSize: 5,
hideOnSinglePage: true,
};

View File

@ -334,6 +334,11 @@ export function PlannedDowntimeList({
}
}, [downtimeSchedules.error, downtimeSchedules.isError, notifications]);
const paginationConfig = {
pageSize: 5,
showSizeChanger: false,
hideOnSinglePage: true,
};
return (
<Table<DowntimeSchedulesTableData>
columns={columns}
@ -342,7 +347,7 @@ export function PlannedDowntimeList({
dataSource={tableData || []}
loading={downtimeSchedules.isLoading || downtimeSchedules.isFetching}
showHeader={false}
pagination={{ pageSize: 5, showSizeChanger: false }}
pagination={paginationConfig}
/>
);
}

View File

@ -79,6 +79,12 @@ function ServiceMetricTable({
}
}, [services, licenseData, isFetching, isCloudUserVal]);
const paginationConfig = {
defaultPageSize: 10,
showTotal: (total: number, range: number[]): string =>
`${range[0]}-${range[1]} of ${total} items`,
hideOnSinglePage: true,
};
return (
<>
{RPS > MAX_RPS_LIMIT && (
@ -92,11 +98,7 @@ function ServiceMetricTable({
<ResourceAttributesFilter />
<ResizeTable
pagination={{
defaultPageSize: 10,
showTotal: (total: number, range: number[]): string =>
`${range[0]}-${range[1]} of ${total} items`,
}}
pagination={paginationConfig}
columns={tableColumns}
loading={isLoading}
dataSource={services}

View File

@ -36,6 +36,12 @@ function ServiceTraceTable({
}
}, [services, licenseData, isFetching, isCloudUserVal]);
const paginationConfig = {
defaultPageSize: 10,
showTotal: (total: number, range: number[]): string =>
`${range[0]}-${range[1]} of ${total} items`,
hideOnSinglePage: true,
};
return (
<>
{RPS > MAX_RPS_LIMIT && (
@ -49,11 +55,7 @@ function ServiceTraceTable({
<ResourceAttributesFilter />
<ResizeTable
pagination={{
defaultPageSize: 10,
showTotal: (total: number, range: number[]): string =>
`${range[0]}-${range[1]} of ${total} items`,
}}
pagination={paginationConfig}
columns={tableColumns}
loading={loading}
dataSource={services}

View File

@ -215,6 +215,7 @@ function TraceTable(): JSX.Element {
responsive: true,
position: ['bottomLeft'],
total: totalCount,
hideOnSinglePage: true,
}}
/>
);

View File

@ -46,6 +46,8 @@ function DataCollected(props: DataCollectedProps): JSX.Element {
},
];
const paginationConfig = { pageSize: 20, hideOnSinglePage: true };
return (
<div className="integration-data-collected">
<div className="logs-section">
@ -59,7 +61,7 @@ function DataCollected(props: DataCollectedProps): JSX.Element {
index % 2 === 0 ? 'table-row-dark' : ''
}
dataSource={logsData}
pagination={{ pageSize: 20 }}
pagination={paginationConfig}
className="logs-section-table"
/>
</div>
@ -74,7 +76,7 @@ function DataCollected(props: DataCollectedProps): JSX.Element {
index % 2 === 0 ? 'table-row-dark' : ''
}
dataSource={metricsData}
pagination={{ pageSize: 20 }}
pagination={paginationConfig}
className="metrics-section-table"
/>
</div>

View File

@ -277,6 +277,8 @@ function SaveView(): JSX.Element {
},
];
const paginationConfig = { pageSize: 5, hideOnSinglePage: true };
return (
<div className="save-view-container">
<div className="save-view-content">
@ -303,7 +305,7 @@ function SaveView(): JSX.Element {
dataSource={dataSource}
loading={isLoading || isRefetching}
showHeader={false}
pagination={{ pageSize: 5 }}
pagination={paginationConfig}
/>
</div>