grafana/public/app/core/components/Page/PageTabs.tsx
Ashley Harrison 4e492ae725
Navigation: Unify Page component (#66951)
* remove old page component

* add test to check initDashboard is only called once (prevent variables loading twice)

* add help node

* update unit tests

* remove last mentions of topnav

* fix unit tests

* remove unused props from ButtonRow interface

* remove prop from test
2023-04-24 16:41:32 +01:00

44 lines
1.0 KiB
TypeScript

import { css } from '@emotion/css';
import React from 'react';
import { NavModelItem, GrafanaTheme2 } from '@grafana/data';
import { useStyles2, TabsBar, Tab, toIconName } from '@grafana/ui';
export interface Props {
navItem: NavModelItem;
}
export function PageTabs({ navItem }: Props) {
const styles = useStyles2(getStyles);
return (
<div className={styles.tabsWrapper}>
<TabsBar>
{navItem.children!.map((child, index) => {
const icon = child.icon ? toIconName(child.icon) : undefined;
return (
!child.hideFromTabs && (
<Tab
label={child.text}
active={child.active}
key={`${child.url}-${index}`}
icon={icon}
href={child.url}
suffix={child.tabSuffix}
/>
)
);
})}
</TabsBar>
</div>
);
}
const getStyles = (theme: GrafanaTheme2) => {
return {
tabsWrapper: css({
paddingBottom: theme.spacing(3),
}),
};
};