diff --git a/packages/grafana-ui/src/components/Button/Button.tsx b/packages/grafana-ui/src/components/Button/Button.tsx index 2733df16c01..55b05c98ffe 100644 --- a/packages/grafana-ui/src/components/Button/Button.tsx +++ b/packages/grafana-ui/src/components/Button/Button.tsx @@ -153,7 +153,7 @@ export const Button = React.forwardRef( Button.displayName = 'Button'; -type ButtonLinkProps = CommonProps & AnchorHTMLAttributes; +type ButtonLinkProps = CommonProps & ButtonHTMLAttributes & AnchorHTMLAttributes; export const LinkButton = React.forwardRef( ({ variant, icon, children, className, ...otherProps }, ref) => { const theme = useContext(ThemeContext); diff --git a/packages/grafana-ui/src/components/InfoBox/InfoBox.story.tsx b/packages/grafana-ui/src/components/InfoBox/InfoBox.story.tsx new file mode 100644 index 00000000000..99df293771e --- /dev/null +++ b/packages/grafana-ui/src/components/InfoBox/InfoBox.story.tsx @@ -0,0 +1,59 @@ +import React from 'react'; +import { number } from '@storybook/addon-knobs'; +import { InfoBox } from './InfoBox'; + +export default { + title: 'General/InfoBox', + component: InfoBox, + decorators: [], + parameters: { + docs: {}, + }, +}; + +const getKnobs = () => { + const CONTAINER_GROUP = 'Container options'; + // --- + const containerWidth = number( + 'Container width', + 800, + { + range: true, + min: 100, + max: 1500, + step: 100, + }, + CONTAINER_GROUP + ); + + return { containerWidth }; +}; + +export const basic = () => { + const { containerWidth } = getKnobs(); + + return ( +
+ + Checkout the{' '} + + MySQL Data Source Docs + {' '} + for more information., + + } + > +

+ The database user should only be granted SELECT permissions on the specified database & tables you want to + query. Grafana does not validate that queries are safe so queries can contain any SQL statement. For example, + statements like USE otherdb; and DROP TABLE user; would be executed. To protect + against this we Highly recommmend you create a specific MySQL user with restricted + permissions. +

+
+
+ ); +}; diff --git a/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx b/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx new file mode 100644 index 00000000000..1a8ebae2499 --- /dev/null +++ b/packages/grafana-ui/src/components/InfoBox/InfoBox.tsx @@ -0,0 +1,77 @@ +import React from 'react'; +import { css, cx } from 'emotion'; +import { GrafanaTheme } from '@grafana/data'; +import { stylesFactory, useTheme } from '../../themes'; + +export interface Props extends React.HTMLAttributes { + header?: string | JSX.Element; + footer?: string | JSX.Element; +} + +/** + * This is a simple InfoBox component, the api is not considered stable yet and will likely see breaking changes + * in future minor releases. + * @Alpha + */ +export const InfoBox = React.memo( + React.forwardRef(({ header, footer, className, children, ...otherProps }, ref) => { + const theme = useTheme(); + const css = getInfoBoxStyles(theme); + + return ( +
+ {header && ( +
+
{header}
+
+ )} + {children} + {footer &&
{footer}
} +
+ ); + }) +); + +const getInfoBoxStyles = stylesFactory((theme: GrafanaTheme) => ({ + wrapper: css` + position: relative; + padding: ${theme.spacing.lg}; + background-color: ${theme.colors.bg2}; + border-top: 3px solid ${theme.palette.blue80}; + margin-bottom: ${theme.spacing.md}; + margin-right: ${theme.spacing.xs}; + box-shadow: ${theme.shadows.listItem}; + flex-grow: 1; + + ul { + padding-left: ${theme.spacing.lg}; + } + + code { + @include font-family-monospace(); + font-size: ${theme.typography.size.sm}; + background-color: ${theme.colors.bg1}; + color: ${theme.colors.text}; + border: 1px solid ${theme.colors.border2}; + border-radius: 4px; + } + + p:last-child { + margin-bottom: 0; + } + + a { + @extend .external-link; + } + + &--max-lg { + max-width: ${theme.breakpoints.lg}; + } + `, + header: css` + margin-bottom: ${theme.spacing.d}; + `, + footer: css` + margin-top: ${theme.spacing.d}; + `, +})); diff --git a/packages/grafana-ui/src/components/Logs/LogDetailsRow.tsx b/packages/grafana-ui/src/components/Logs/LogDetailsRow.tsx index 7858d76f5dc..babaf781eed 100644 --- a/packages/grafana-ui/src/components/Logs/LogDetailsRow.tsx +++ b/packages/grafana-ui/src/components/Logs/LogDetailsRow.tsx @@ -126,14 +126,13 @@ class UnThemedLogDetailsRow extends PureComponent { href={link.href} target={'_blank'} onClick={ - link.onClick - ? event => { - if (!(event.ctrlKey || event.metaKey || event.shiftKey) && link.onClick) { - event.preventDefault(); - link.onClick(event); - } - } - : undefined + link.onClick && + ((event: any) => { + if (!(event.ctrlKey || event.metaKey || event.shiftKey) && link.onClick) { + event.preventDefault(); + link.onClick(event); + } + }) } /> diff --git a/packages/grafana-ui/src/components/index.ts b/packages/grafana-ui/src/components/index.ts index 1ad26994f08..b0f46255720 100644 --- a/packages/grafana-ui/src/components/index.ts +++ b/packages/grafana-ui/src/components/index.ts @@ -97,6 +97,7 @@ export { DataLinksInlineEditor } from './DataLinks/DataLinksInlineEditor/DataLin export { DataLinkInput } from './DataLinks/DataLinkInput'; export { DataLinksContextMenu } from './DataLinks/DataLinksContextMenu'; export { SeriesIcon } from './Legend/SeriesIcon'; +export { InfoBox } from './InfoBox/InfoBox'; export { JSONFormatter } from './JSONFormatter/JSONFormatter'; export { JsonExplorer } from './JSONFormatter/json_explorer/json_explorer';