mirror of https://github.com/grafana/grafana
Alerting: Remove CTA button from read-only notification policy page (#41096)
* don't show cta button for read-only prometheus alertmanager * grammar fix Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com> Co-authored-by: Peter Holmberg <peterholmberg@users.noreply.github.com> Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com> Co-authored-by: Peter Holmberg <peter.hlmbrg@gmail.com>pull/41202/head^2
parent
01bc59e432
commit
345af8374c
@ -0,0 +1,61 @@ |
||||
import React, { ButtonHTMLAttributes, FC } from 'react'; |
||||
import { css } from '@emotion/css'; |
||||
import { GrafanaTheme } from '@grafana/data'; |
||||
import { Button, ButtonVariant, IconName, useStyles } from '@grafana/ui'; |
||||
import { EmptyArea } from './EmptyArea'; |
||||
|
||||
export interface EmptyAreaWithCTAProps { |
||||
buttonLabel: string; |
||||
onButtonClick: ButtonHTMLAttributes<HTMLButtonElement>['onClick']; |
||||
text: string; |
||||
|
||||
buttonIcon?: IconName; |
||||
buttonSize?: 'xs' | 'sm' | 'md' | 'lg'; |
||||
buttonVariant?: ButtonVariant; |
||||
} |
||||
|
||||
export const EmptyAreaWithCTA: FC<EmptyAreaWithCTAProps> = ({ |
||||
buttonIcon, |
||||
buttonLabel, |
||||
buttonSize = 'lg', |
||||
buttonVariant = 'primary', |
||||
onButtonClick, |
||||
text, |
||||
}) => { |
||||
const styles = useStyles(getStyles); |
||||
|
||||
return ( |
||||
<EmptyArea> |
||||
<> |
||||
<p className={styles.text}>{text}</p> |
||||
<Button |
||||
className={styles.button} |
||||
icon={buttonIcon} |
||||
onClick={onButtonClick} |
||||
size={buttonSize} |
||||
type="button" |
||||
variant={buttonVariant} |
||||
> |
||||
{buttonLabel} |
||||
</Button> |
||||
</> |
||||
</EmptyArea> |
||||
); |
||||
}; |
||||
|
||||
const getStyles = (theme: GrafanaTheme) => { |
||||
return { |
||||
container: css` |
||||
background-color: ${theme.colors.bg2}; |
||||
color: ${theme.colors.textSemiWeak}; |
||||
padding: ${theme.spacing.xl}; |
||||
text-align: center; |
||||
`,
|
||||
text: css` |
||||
margin-bottom: ${theme.spacing.md}; |
||||
`,
|
||||
button: css` |
||||
margin: ${theme.spacing.md} 0 ${theme.spacing.sm}; |
||||
`,
|
||||
}; |
||||
}; |
Loading…
Reference in new issue