import { css, cx } from '@emotion/css'; import { PanelData, GrafanaTheme2, PanelModel, LinkModel, AlertState, DataLink } from '@grafana/data'; import { Icon, PanelChrome, Tooltip, useStyles2, TimePickerTooltip } from '@grafana/ui'; import { PanelLinks } from '../PanelLinks'; import { PanelHeaderNotices } from './PanelHeaderNotices'; export interface AngularNotice { show: boolean; isAngularPanel: boolean; isAngularDatasource: boolean; } export interface Props { alertState?: string; data: PanelData; panelId: number; onShowPanelLinks?: () => Array>; panelLinks?: DataLink[]; angularNotice?: AngularNotice; } export function PanelHeaderTitleItems(props: Props) { const { alertState, data, panelId, onShowPanelLinks, panelLinks, angularNotice } = props; const styles = useStyles2(getStyles); // panel health const alertStateItem = ( ); const timeshift = ( <> {data.request && data.request.timeInfo && ( }> {data.request?.timeInfo} )} ); const message = `This ${pluginType(angularNotice)} requires Angular (deprecated).`; const angularNoticeTooltip = ( ); return ( <> {panelLinks && panelLinks.length > 0 && onShowPanelLinks && ( )} {} {timeshift} {alertState && alertStateItem} {angularNotice?.show && angularNoticeTooltip} ); } const pluginType = (angularNotice?: AngularNotice): string => { if (angularNotice?.isAngularPanel) { return 'panel'; } if (angularNotice?.isAngularDatasource) { return 'data source'; } return 'panel or data source'; }; const getStyles = (theme: GrafanaTheme2) => { return { ok: css({ color: theme.colors.success.text, '&:hover': { color: theme.colors.emphasize(theme.colors.success.text, 0.03), }, }), pending: css({ color: theme.colors.warning.text, '&:hover': { color: theme.colors.emphasize(theme.colors.warning.text, 0.03), }, }), alerting: css({ color: theme.colors.error.text, '&:hover': { color: theme.colors.emphasize(theme.colors.error.text, 0.03), }, }), timeshift: css({ color: theme.colors.text.link, gap: theme.spacing(0.5), whiteSpace: 'nowrap', '&:hover': { color: theme.colors.emphasize(theme.colors.text.link, 0.03), }, }), angularNotice: css({ color: theme.colors.warning.text, }), }; };