2019-02-03 18:25:13 +01:00
|
|
|
// Libraries
|
|
|
|
|
import React, { FunctionComponent } from 'react';
|
|
|
|
|
// Components
|
|
|
|
|
import { Tooltip } from '@grafana/ui';
|
2019-12-09 00:14:25 -08:00
|
|
|
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}>
|
2019-05-08 16:50:21 +02:00
|
|
|
<button
|
|
|
|
|
className={`btn navbar-button navbar-button--${classSuffix}`}
|
|
|
|
|
onClick={onClick}
|
2019-12-18 06:13:58 +01:00
|
|
|
aria-label={e2e.pages.Dashboard.Toolbar.selectors.toolbarItems(tooltip)}
|
2019-05-08 16:50:21 +02:00
|
|
|
>
|
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>
|
|
|
|
|
);
|
|
|
|
|
};
|