|
@@ -1,40 +1,48 @@
|
|
|
-import React, { Component } from 'react';
|
|
|
|
|
-
|
|
|
|
|
|
|
+import React, { useContext } from 'react';
|
|
|
|
|
+import { CallToActionCard, ExtraLargeLinkButton, ThemeContext } from '@grafana/ui';
|
|
|
|
|
+import { css } from 'emotion';
|
|
|
export interface Props {
|
|
export interface Props {
|
|
|
model: any;
|
|
model: any;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-class EmptyListCTA extends Component<Props, any> {
|
|
|
|
|
- render() {
|
|
|
|
|
- const {
|
|
|
|
|
- title,
|
|
|
|
|
- buttonIcon,
|
|
|
|
|
- buttonLink,
|
|
|
|
|
- buttonTitle,
|
|
|
|
|
- onClick,
|
|
|
|
|
- proTip,
|
|
|
|
|
- proTipLink,
|
|
|
|
|
- proTipLinkTitle,
|
|
|
|
|
- proTipTarget,
|
|
|
|
|
- } = this.props.model;
|
|
|
|
|
- return (
|
|
|
|
|
- <div className="empty-list-cta">
|
|
|
|
|
- <div className="empty-list-cta__title">{title}</div>
|
|
|
|
|
- <a onClick={onClick} href={buttonLink} className="empty-list-cta__button btn btn-xlarge btn-primary">
|
|
|
|
|
- <i className={buttonIcon} />
|
|
|
|
|
- {buttonTitle}
|
|
|
|
|
- </a>
|
|
|
|
|
- {proTip && (
|
|
|
|
|
- <div className="empty-list-cta__pro-tip">
|
|
|
|
|
- <i className="fa fa-rocket" /> ProTip: {proTip}
|
|
|
|
|
- <a className="text-link empty-list-cta__pro-tip-link" href={proTipLink} target={proTipTarget}>
|
|
|
|
|
- {proTipLinkTitle}
|
|
|
|
|
- </a>
|
|
|
|
|
- </div>
|
|
|
|
|
- )}
|
|
|
|
|
- </div>
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+const EmptyListCTA: React.FunctionComponent<Props> = props => {
|
|
|
|
|
+ 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>
|
|
|
|
|
+ ) : null;
|
|
|
|
|
+
|
|
|
|
|
+ const ctaElementClassName = !footer
|
|
|
|
|
+ ? css`
|
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
|
+ `
|
|
|
|
|
+ : '';
|
|
|
|
|
+
|
|
|
|
|
+ const ctaElement = (
|
|
|
|
|
+ <ExtraLargeLinkButton onClick={onClick} href={buttonLink} icon={buttonIcon} className={ctaElementClassName}>
|
|
|
|
|
+ {buttonTitle}
|
|
|
|
|
+ </ExtraLargeLinkButton>
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ return <CallToActionCard message={title} footer={footer} callToActionElement={ctaElement} theme={theme} />;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
export default EmptyListCTA;
|
|
export default EmptyListCTA;
|