The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/packages/grafana-ui/src/components/PanelChrome/ErrorIndicator.tsx

49 lines
954 B

import { css, cx } from '@emotion/css';
import React from 'react';
import { useStyles2 } from '../../themes';
import { commonColorsPalette } from '../../themes/default';
import { Icon } from '../Icon/Icon';
import { Tooltip } from '../Tooltip/Tooltip';
/**
* @internal
*/
export type ErrorIndicatorProps = {
error?: string;
onClick?: () => void;
};
/**
* @internal
*/
export const ErrorIndicator = ({ error, onClick }: ErrorIndicatorProps) => {
const styles = useStyles2(getStyles);
if (!error) {
return null;
}
return (
<Tooltip theme="error" content={error}>
<Icon
onClick={onClick}
className={cx(styles.icon, { [styles.clickable]: !!onClick })}
size="sm"
name="exclamation-triangle"
/>
</Tooltip>
);
};
const getStyles = () => {
return {
PanelChrome: Implementing the new layout on PanelChrome @ grafana/ui (#57203) * Use newPanelChromeUI feature flag in DashboardPanel panel rendering * just render the PanelChromeUI instead of the PanelChrome * add new props to PanelChrome; have ChromePanel from grafana/ui in DashboardPanel for testing (will remove before finished); * put icons next to the title of PanelChrome header space * arrange PanelChrome's title icons into view/edit/status sections * icons next to title in PanelChrome are surrounded by square focusable space * items to be render in Header in PanelChrome come in as props * PanelChrome accepts items next to title from the outside; currently them being ordered in the left side is okay, right side not so much * revert local changes to DashboardPanel * cleanup unused imports * simple PanelChrome render without any header props * CSS function * add test PanelChrome prop padding * add icons next to title if they are passed to PanelChrome * fixed PanelChrome header: hoverHeader, having a menu prop; * only show icons with correct icon names; show menu icon only on hover over panel container; minor other fixes * attempt to resolve hovering in an RTL test for the menu icon to work as expected * menu opens in a Dropdown if provided as prop * fixing tooltips and aria-labels * Fixed issue with light theme in storybook * comment out props and tests that are not yet used * Fixed issue where content was overflowing the boundaries Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
3 years ago
clickable: css({
cursor: 'pointer',
}),
icon: css({
color: `${commonColorsPalette.red88}`,
}),
};
};