mirror of https://github.com/grafana/grafana
QueryEditorRow: Show query errors next to query in a consistent way across Grafana (#47613)
* Show query errors under each query row * Testing a more plain error box * Font size * Make it green * Nit UI * Slight simplification of condition * New design * Update Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>pull/47769/head
parent
c8189e4808
commit
6f31a69bfd
@ -0,0 +1,41 @@ |
|||||||
|
import React from 'react'; |
||||||
|
import { DataQueryError, GrafanaTheme2 } from '@grafana/data'; |
||||||
|
import { Icon, useStyles2 } from '@grafana/ui'; |
||||||
|
import { css } from '@emotion/css'; |
||||||
|
|
||||||
|
export interface Props { |
||||||
|
error: DataQueryError; |
||||||
|
} |
||||||
|
|
||||||
|
export function QueryErrorAlert({ error }: Props) { |
||||||
|
const styles = useStyles2(getStyles); |
||||||
|
|
||||||
|
const message = error?.message ?? error?.data?.message ?? 'Query error'; |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className={styles.wrapper}> |
||||||
|
<div className={styles.icon}> |
||||||
|
<Icon name="exclamation-triangle" /> |
||||||
|
</div> |
||||||
|
<div className={styles.message}>{message}</div> |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
const getStyles = (theme: GrafanaTheme2) => ({ |
||||||
|
wrapper: css({ |
||||||
|
marginTop: theme.spacing(0.5), |
||||||
|
background: theme.colors.background.secondary, |
||||||
|
display: 'flex', |
||||||
|
}), |
||||||
|
icon: css({ |
||||||
|
background: theme.colors.error.main, |
||||||
|
color: theme.colors.error.contrastText, |
||||||
|
padding: theme.spacing(1), |
||||||
|
}), |
||||||
|
message: css({ |
||||||
|
fontSize: theme.typography.bodySmall.fontSize, |
||||||
|
fontFamily: theme.typography.fontFamilyMonospace, |
||||||
|
padding: theme.spacing(1), |
||||||
|
}), |
||||||
|
}); |
Loading…
Reference in new issue