|
|
@@ -1,38 +1,71 @@
|
|
|
-import React, { useContext } from 'react';
|
|
|
+import React, { useContext, MouseEvent } from 'react';
|
|
|
import { CallToActionCard, LinkButton, ThemeContext } from '@grafana/ui';
|
|
|
import { css } from 'emotion';
|
|
|
export interface Props {
|
|
|
- model: any;
|
|
|
+ title: string;
|
|
|
+ buttonIcon: string;
|
|
|
+ buttonLink?: string;
|
|
|
+ buttonTitle: string;
|
|
|
+ onClick?: (event: MouseEvent) => void;
|
|
|
+ proTip?: string;
|
|
|
+ proTipLink?: string;
|
|
|
+ proTipLinkTitle?: string;
|
|
|
+ proTipTarget?: string;
|
|
|
+ infoBox?: { __html: string };
|
|
|
+ infoBoxTitle?: string;
|
|
|
}
|
|
|
|
|
|
-const EmptyListCTA: React.FunctionComponent<Props> = props => {
|
|
|
+const ctaStyle = css`
|
|
|
+ text-align: center;
|
|
|
+`;
|
|
|
+
|
|
|
+const infoBoxStyles = css`
|
|
|
+ max-width: 700px;
|
|
|
+ margin: 0 auto;
|
|
|
+`;
|
|
|
+
|
|
|
+const EmptyListCTA: React.FunctionComponent<Props> = ({
|
|
|
+ title,
|
|
|
+ buttonIcon,
|
|
|
+ buttonLink,
|
|
|
+ buttonTitle,
|
|
|
+ onClick,
|
|
|
+ proTip,
|
|
|
+ proTipLink,
|
|
|
+ proTipLinkTitle,
|
|
|
+ proTipTarget,
|
|
|
+ infoBox,
|
|
|
+ infoBoxTitle,
|
|
|
+}) => {
|
|
|
const theme = useContext(ThemeContext);
|
|
|
|
|
|
- const {
|
|
|
- title,
|
|
|
- buttonIcon,
|
|
|
- buttonLink,
|
|
|
- buttonTitle,
|
|
|
- onClick,
|
|
|
- proTip,
|
|
|
- proTipLink,
|
|
|
- proTipLinkTitle,
|
|
|
- proTipTarget,
|
|
|
- } = props.model;
|
|
|
-
|
|
|
- const footer = proTip ? (
|
|
|
- <span>
|
|
|
- <i className="fa fa-rocket" />
|
|
|
- <> ProTip: {proTip} </>
|
|
|
- <a href={proTipLink} target={proTipTarget} className="text-link">
|
|
|
- {proTipLinkTitle}
|
|
|
- </a>
|
|
|
- </span>
|
|
|
- ) : (
|
|
|
- ''
|
|
|
- );
|
|
|
+ const footer = () => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {proTip ? (
|
|
|
+ <span key="proTipFooter">
|
|
|
+ <i className="fa fa-rocket" />
|
|
|
+ <> ProTip: {proTip} </>
|
|
|
+ <a href={proTipLink} target={proTipTarget} className="text-link">
|
|
|
+ {proTipLinkTitle}
|
|
|
+ </a>
|
|
|
+ </span>
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
+ {infoBox ? (
|
|
|
+ <div key="infoBoxHtml" className={`grafana-info-box ${infoBoxStyles}`}>
|
|
|
+ {infoBoxTitle && <h5>{infoBoxTitle}</h5>}
|
|
|
+ <div dangerouslySetInnerHTML={infoBox} />
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ };
|
|
|
|
|
|
- const ctaElementClassName = !footer
|
|
|
+ const ctaElementClassName = !footer()
|
|
|
? css`
|
|
|
margin-bottom: 20px;
|
|
|
`
|
|
|
@@ -44,7 +77,15 @@ const EmptyListCTA: React.FunctionComponent<Props> = props => {
|
|
|
</LinkButton>
|
|
|
);
|
|
|
|
|
|
- return <CallToActionCard message={title} footer={footer} callToActionElement={ctaElement} theme={theme} />;
|
|
|
+ return (
|
|
|
+ <CallToActionCard
|
|
|
+ className={ctaStyle}
|
|
|
+ message={title}
|
|
|
+ footer={footer()}
|
|
|
+ callToActionElement={ctaElement}
|
|
|
+ theme={theme}
|
|
|
+ />
|
|
|
+ );
|
|
|
};
|
|
|
|
|
|
export default EmptyListCTA;
|