Page: Add support for tab counters (#78127)

pull/78279/head
Gilles De Mey 2 years ago committed by GitHub
parent 2c0c51a0df
commit 0e5ce50b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      packages/grafana-data/src/types/navModel.ts
  2. 23
      public/app/core/components/Page/PageTabs.test.tsx
  3. 1
      public/app/core/components/Page/PageTabs.tsx

@ -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}
/>

Loading…
Cancel
Save