Page: Add support for tab counters (#78127)

This commit is contained in:
Gilles De Mey
2023-11-16 13:31:14 +00:00
committed by GitHub
parent 2c0c51a0df
commit 0e5ce50b90
3 changed files with 25 additions and 0 deletions
@@ -34,6 +34,7 @@ export interface NavModelItem extends NavLinkDTO {
parentItem?: NavModelItem;
onClick?: () => void;
tabSuffix?: ComponentType<{ className?: string }>;
tabCounter?: number;
hideFromBreadcrumbs?: boolean;
emptyMessage?: string;
}
@@ -0,0 +1,23 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { NavModelItem } from '@grafana/data';
import { PageTabs } from './PageTabs';
describe('PageTabs', () => {
it('should render a tab with a counter', () => {
const navItem: NavModelItem = {
text: 'My page',
children: [
{
text: 'My tab',
tabCounter: 10,
},
],
};
render(<PageTabs navItem={navItem} />);
expect(screen.getByText('10')).toBeInTheDocument();
});
});
@@ -23,6 +23,7 @@ export function PageTabs({ navItem }: Props) {
active={child.active}
key={`${child.url}-${index}`}
icon={icon}
counter={child.tabCounter}
href={child.url}
suffix={child.tabSuffix}
/>