Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(infra-monitoring): show total items count on list page (#11212)

Vinicius Lourenço382cd57a6af4
diff --git a/frontend/src/components/TanStackTableView/TanStackTable.tsx b/frontend/src/components/TanStackTableView/TanStackTable.tsx
index 4492cb1c1a..1bff1eec9a 100644
--- a/frontend/src/components/TanStackTableView/TanStackTable.tsx
+++ b/frontend/src/components/TanStackTableView/TanStackTable.tsx
@@ -589,6 +589,16 @@ function TanStackTableInner<TData>(
{showPagination && pagination && (
<div className={cx(viewStyles.paginationContainer, paginationClassname)}>
{prefixPaginationContent}
+ {pagination.showTotalCount && effectiveTotalCount > 0 && (
+ <span
+ className={viewStyles.paginationTotalCount}
+ data-testid="pagination-total-count"
+ >
+ Showing {(page - 1) * limit + 1} -{' '}
+ {Math.min(page * limit, effectiveTotalCount)} of {effectiveTotalCount}
+ {pagination.totalCountLabel ? ` ${pagination.totalCountLabel}` : ''}
+ </span>
+ )}
<Pagination
current={page}
pageSize={limit}
diff --git a/frontend/src/components/TanStackTableView/TanStackTableView.module.scss b/frontend/src/components/TanStackTableView/TanStackTableView.module.scss
index 10db55ff7e..22635d71bd 100644
--- a/frontend/src/components/TanStackTableView/TanStackTableView.module.scss
+++ b/frontend/src/components/TanStackTableView/TanStackTableView.module.scss
@@ -117,6 +117,10 @@
justify-content: flex-end;
gap: 12px;
margin-top: 12px;
+
+ ul {
+ padding: 0;
+ }
}
.paginationPageSize {
@@ -124,6 +128,11 @@
--combobox-trigger-height: 2rem;
}
+.paginationTotalCount {
+ font-size: var(--periscope-font-size-base);
+ color: var(--l1-foreground);
+}
+
.tanstackLoadingOverlay {
position: absolute;
left: 50%;
diff --git a/frontend/src/components/TanStackTableView/__tests__/TanStackTableView.test.tsx b/frontend/src/components/TanStackTableView/__tests__/TanStackTableView.test.tsx
index 2e36e6ae85..8f667d7951 100644
--- a/frontend/src/components/TanStackTableView/__tests__/TanStackTableView.test.tsx
+++ b/frontend/src/components/TanStackTableView/__tests__/TanStackTableView.test.tsx
@@ -188,6 +188,87 @@ describe('TanStackTableView Integration', () => {
expect(screen.getByTestId('suffix-content')).toBeInTheDocument();
});
});
+
+ it('renders total count when showTotalCount is true', async () => {
+ renderTanStackTable({
+ props: {
+ pagination: {
+ total: 100,
+ defaultPage: 1,
+ defaultLimit: 10,
+ showTotalCount: true,
+ },
+ },
+ });
+
+ await waitFor(() => {
+ const totalCount = screen.getByTestId('pagination-total-count');
+ expect(totalCount).toBeInTheDocument();
+ expect(totalCount).toHaveTextContent('Showing 1 - 10 of 100');
+ });
+ });
+
+ it('renders total count with label when totalCountLabel is provided', async () => {
+ renderTanStackTable({
+ props: {
+ pagination: {
+ total: 50,
+ defaultPage: 1,
+ defaultLimit: 10,
+ showTotalCount: true,
+ totalCountLabel: 'Pods',
+ },
+ },
+ });
+
+ await waitFor(() => {
+ const totalCount = screen.getByTestId('pagination-total-count');
+ expect(totalCount).toBeInTheDocument();
+ expect(totalCount).toHaveTextContent('Showing 1 - 10 of 50 Pods');
+ });
+ });
+
+ it('does not render total count when showTotalCount is false', async () => {
+ renderTanStackTable({
+ props: {
+ pagination: {
+ total: 100,
+ defaultPage: 1,
+ defaultLimit: 10,
+ showTotalCount: false,
+ },
+ },
+ });
+
+ await waitFor(() => {
+ expect(screen.getByRole('navigation')).toBeInTheDocument();
+ });
+
+ expect(
+ screen.queryByTestId('pagination-total-count'),
+ ).not.toBeInTheDocument();
+ });
+
+ it('does not render total count when total is 0', async () => {
+ renderTanStackTable({
+ props: {
+ pagination: {
+ total: 0,
+ defaultPage: 1,
+ defaultLimit: 10,
+ showTotalCount: true,
+ },
+ },
+ });
+
+ await waitFor(() => {
+ expect(screen.getByRole('table')).toBeInTheDocument();
+ });
+
+ expect(
+ screen.queryByTestId('pagination-total-count'),
+ ).not.toBeInTheDocument();
+ });
});
describe('sorting', () => {
diff --git a/frontend/src/components/TanStackTableView/types.ts b/frontend/src/components/TanStackTableView/types.ts
index 0cd6366296..a4b599052a 100644
--- a/frontend/src/components/TanStackTableView/types.ts
+++ b/frontend/src/components/TanStackTableView/types.ts
@@ -115,6 +115,8 @@ export type PaginationProps = {
total: number;
defaultPage?: number;
defaultLimit?: number;
+ showTotalCount?: boolean;
+ totalCountLabel?: string;
};
export type TanstackTableQueryParamsConfig = {
diff --git a/frontend/src/container/InfraMonitoringK8s/Base/K8sBaseList.tsx b/frontend/src/container/InfraMonitoringK8s/Base/K8sBaseList.tsx
index 32a1b5e25a..aae02c9d4e 100644
--- a/frontend/src/container/InfraMonitoringK8s/Base/K8sBaseList.tsx
+++ b/frontend/src/container/InfraMonitoringK8s/Base/K8sBaseList.tsx
@@ -286,6 +286,8 @@ export function K8sBaseList<T extends K8sEntityData>({
total: totalCount,
defaultLimit: 10,
defaultPage: 1,
+ showTotalCount: true,
+ totalCountLabel: entity.charAt(0).toUpperCase() + entity.slice(1),
}}
paginationClassname={styles.paginationContainer}
/>