mirror of https://github.com/grafana/grafana
Connections: Add redirect notice for datasources and plugins pages (#61037)
* add redirect notice for datasources and plugins pages * do not depend on the internal implementation of Alert The deleted css piece was problematic because it relied on the internals of Alert. If we don't remove that padding, then the Alert looks a bit off, so I added some title to the Alert to look better. This way the Connections LinkButton is not vertically aligned to the center, but this is the closest we can get to the designed alert without doing hacks and reimplementing the Alert component.pull/61081/head
parent
fc0e3d6c14
commit
8e8f498674
@ -0,0 +1,49 @@ |
||||
import { css } from '@emotion/css'; |
||||
import React from 'react'; |
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data'; |
||||
import { Alert, LinkButton, useStyles2 } from '@grafana/ui'; |
||||
|
||||
import { ROUTES } from '../../constants'; |
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => ({ |
||||
alertContent: css` |
||||
display: flex; |
||||
flex-direction: row; |
||||
padding: 0; |
||||
justify-content: space-between; |
||||
`,
|
||||
alertParagraph: css` |
||||
margin: 0 ${theme.spacing(1)} 0 0; |
||||
line-height: ${theme.spacing(theme.components.height.md)}; |
||||
color: ${theme.colors.text.primary}; |
||||
`,
|
||||
}); |
||||
|
||||
export enum DestinationPage { |
||||
dataSources = 'dataSources', |
||||
connectData = 'connectData', |
||||
} |
||||
|
||||
const destinationLinks = { |
||||
[DestinationPage.dataSources]: ROUTES.DataSources, |
||||
[DestinationPage.connectData]: ROUTES.ConnectData, |
||||
}; |
||||
|
||||
export function ConnectionsRedirectNotice({ destinationPage }: { destinationPage: DestinationPage }) { |
||||
const styles = useStyles2(getStyles); |
||||
|
||||
return ( |
||||
<Alert severity="warning" title="Data sources have a new home!"> |
||||
<div className={styles.alertContent}> |
||||
<p className={styles.alertParagraph}> |
||||
You can discover new data sources or manage existing ones in the new Connections section, accessible from the |
||||
left-hand navigation, or click the button here. |
||||
</p> |
||||
<LinkButton aria-label="Link to Connections" icon="link" href={destinationLinks[destinationPage]}> |
||||
Connections |
||||
</LinkButton> |
||||
</div> |
||||
</Alert> |
||||
); |
||||
} |
@ -0,0 +1 @@ |
||||
export * from './ConnectionsRedirectNotice'; |
Loading…
Reference in new issue