diff --git a/packages/grafana-e2e-selectors/src/selectors/pages.ts b/packages/grafana-e2e-selectors/src/selectors/pages.ts index 4f7b571f4fc..ff00865f431 100644 --- a/packages/grafana-e2e-selectors/src/selectors/pages.ts +++ b/packages/grafana-e2e-selectors/src/selectors/pages.ts @@ -14,7 +14,6 @@ export const Pages = { delete: 'Data source settings page Delete button', saveAndTest: 'Data source settings page Save and Test button', alert: 'Data source settings page Alert', - alertMessage: 'Data source settings page Alert message', }, DataSources: { url: '/datasources', diff --git a/packages/grafana-e2e/src/flows/addDataSource.ts b/packages/grafana-e2e/src/flows/addDataSource.ts index d6b2353e820..cd1189f84b3 100644 --- a/packages/grafana-e2e/src/flows/addDataSource.ts +++ b/packages/grafana-e2e/src/flows/addDataSource.ts @@ -85,8 +85,10 @@ export const addDataSource = (config?: Partial) => { form(); e2e.pages.DataSource.saveAndTest().click(); - e2e.pages.DataSource.alert().should('exist'); - e2e.pages.DataSource.alertMessage().contains(expectedAlertMessage); // assertion + e2e.pages.DataSource.alert() + .should('exist') + .contains(expectedAlertMessage); // assertion + e2e().logToConsole('Added data source with name:', name); return e2e() diff --git a/packages/grafana-ui/src/components/Alert/Alert.tsx b/packages/grafana-ui/src/components/Alert/Alert.tsx index c4543d43abb..b009b01d5fc 100644 --- a/packages/grafana-ui/src/components/Alert/Alert.tsx +++ b/packages/grafana-ui/src/components/Alert/Alert.tsx @@ -1,4 +1,4 @@ -import React, { FC, ReactNode } from 'react'; +import React, { FC, HTMLAttributes, ReactNode } from 'react'; import { css } from 'emotion'; import { GrafanaTheme } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; @@ -9,7 +9,7 @@ import { getColorsFromSeverity } from '../../utils/colors'; export type AlertVariant = 'success' | 'warning' | 'error' | 'info'; -export interface Props { +export interface Props extends HTMLAttributes { title: string; /** On click handler for alert button, mostly used for dismissing the alert */ onRemove?: (event: React.MouseEvent) => void; @@ -39,40 +39,36 @@ function getIconFromSeverity(severity: AlertVariant): string { } } -export const Alert: FC = ({ - title, - buttonText, - onButtonClick, - onRemove, - children, - buttonContent, - severity = 'error', -}) => { - const theme = useTheme(); - const styles = getStyles(theme, severity, !!buttonContent); +export const Alert: FC = React.forwardRef( + ({ title, buttonText, onButtonClick, onRemove, children, buttonContent, severity = 'error', ...restProps }) => { + const theme = useTheme(); + const styles = getStyles(theme, severity, !!buttonContent); - return ( -
-
- + return ( +
+
+ +
+
+
{title}
+ {children &&
{children}
} +
+ {/* If onRemove is specified, giving preference to onRemove */} + {onRemove ? ( + + ) : onButtonClick ? ( + + ) : null}
-
-
{title}
- {children &&
{children}
} -
- {/* If onRemove is specified, giving preference to onRemove */} - {onRemove ? ( - - ) : onButtonClick ? ( - - ) : null} -
- ); -}; + ); + } +); + +Alert.displayName = 'Alert'; const getStyles = (theme: GrafanaTheme, severity: AlertVariant, outline: boolean) => { const { white } = theme.palette; @@ -107,6 +103,8 @@ const getStyles = (theme: GrafanaTheme, severity: AlertVariant, outline: boolean body: css` flex-grow: 1; margin: 0 ${theme.spacing.md} 0 0; + overflow-wrap: break-word; + word-break: break-word; a { color: ${white}; diff --git a/public/app/features/datasources/settings/DataSourceSettingsPage.tsx b/public/app/features/datasources/settings/DataSourceSettingsPage.tsx index 04234e7ad04..a2bb87ee604 100644 --- a/public/app/features/datasources/settings/DataSourceSettingsPage.tsx +++ b/public/app/features/datasources/settings/DataSourceSettingsPage.tsx @@ -2,8 +2,6 @@ import React, { PureComponent } from 'react'; import { hot } from 'react-hot-loader'; import isString from 'lodash/isString'; -import { Icon } from '@grafana/ui'; -import { selectors } from '@grafana/e2e-selectors'; // Components import Page from 'app/core/components/Page/Page'; import { GenericDataSourcePlugin, PluginSettings } from './PluginSettings'; @@ -25,10 +23,12 @@ import { getRouteParamsId } from 'app/core/selectors/location'; // Types import { CoreEvents, StoreState } from 'app/types/'; import { DataSourcePluginMeta, DataSourceSettings, NavModel, UrlQueryMap } from '@grafana/data'; +import { Alert } from '@grafana/ui'; import { getDataSourceLoadingNav } from '../state/navModel'; import PluginStateinfo from 'app/features/plugins/PluginStateInfo'; import { dataSourceLoaded, setDataSourceName, setIsDefault } from '../state/reducers'; import { connectWithCleanUp } from 'app/core/components/connectWithCleanUp'; +import { selectors } from '@grafana/e2e-selectors'; export interface Props { navModel: NavModel; @@ -172,7 +172,7 @@ export class DataSourceSettingsPage extends PureComponent { } renderSettings() { - const { dataSourceMeta, setDataSourceName, setIsDefault, dataSource, testingStatus, plugin } = this.props; + const { dataSourceMeta, setDataSourceName, setIsDefault, dataSource, plugin, testingStatus } = this.props; return (
@@ -204,16 +204,11 @@ export class DataSourceSettingsPage extends PureComponent {
{testingStatus && testingStatus.message && ( -
-
- {testingStatus.status === 'error' ? : } -
-
-
- {testingStatus.message} -
-
-
+ )}
diff --git a/public/sass/components/_alerts.scss b/public/sass/components/_alerts.scss index 628d0718113..3ffbcf2d249 100644 --- a/public/sass/components/_alerts.scss +++ b/public/sass/components/_alerts.scss @@ -77,6 +77,8 @@ } .alert-body { + overflow-wrap: break-word; + word-break: break-word; flex-grow: 1; }