Files
grafana/public/app/features/dashboard/components/DashNav/DashNavButton.tsx

38 lines
926 B
TypeScript
Raw Normal View History

2019-02-03 18:25:13 +01:00
// Libraries
import React, { FunctionComponent } from 'react';
// Components
import { Tooltip } from '@grafana/ui';
import { e2e } from '@grafana/e2e';
2019-02-03 18:25:13 +01:00
interface Props {
icon: string;
tooltip: string;
classSuffix: string;
2019-02-03 20:38:13 +01:00
onClick?: () => void;
href?: string;
2019-02-03 18:25:13 +01:00
}
2019-02-03 20:38:13 +01:00
export const DashNavButton: FunctionComponent<Props> = ({ icon, tooltip, classSuffix, onClick, href }) => {
if (onClick) {
return (
<Tooltip content={tooltip}>
<button
className={`btn navbar-button navbar-button--${classSuffix}`}
onClick={onClick}
aria-label={e2e.pages.Dashboard.Toolbar.selectors.toolbarItems(tooltip)}
>
2019-02-03 20:38:13 +01:00
<i className={icon} />
</button>
</Tooltip>
);
}
2019-02-03 18:25:13 +01:00
return (
2019-02-03 20:38:13 +01:00
<Tooltip content={tooltip}>
<a className={`btn navbar-button navbar-button--${classSuffix}`} href={href}>
2019-02-03 18:25:13 +01:00
<i className={icon} />
2019-02-03 20:38:13 +01:00
</a>
2019-02-03 18:25:13 +01:00
</Tooltip>
);
};