PluginStateInfo.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React, { FC, useContext } from 'react';
  2. import { css } from 'emotion';
  3. import { PluginState, Tooltip, ThemeContext } from '@grafana/ui';
  4. import { PopoverContent } from '@grafana/ui/src/components/Tooltip/Tooltip';
  5. interface Props {
  6. state?: PluginState;
  7. }
  8. function getPluginStateInfoText(state?: PluginState): PopoverContent | null {
  9. switch (state) {
  10. case PluginState.alpha:
  11. return (
  12. <div>
  13. <h5>Alpha Plugin</h5>
  14. <p>This plugin is a work in progress and updates may include breaking changes.</p>
  15. </div>
  16. );
  17. case PluginState.beta:
  18. return (
  19. <div>
  20. <h5>Beta Plugin</h5>
  21. <p>There could be bugs and minor breaking changes to this plugin.</p>
  22. </div>
  23. );
  24. }
  25. return null;
  26. }
  27. const PluginStateinfo: FC<Props> = props => {
  28. const text = getPluginStateInfoText(props.state);
  29. if (!text) {
  30. return null;
  31. }
  32. const theme = useContext(ThemeContext);
  33. const styles = css`
  34. background: linear-gradient(to bottom, ${theme.colors.blueBase}, ${theme.colors.blueShade});
  35. color: ${theme.colors.gray7};
  36. white-space: nowrap;
  37. border-radius: 3px;
  38. text-shadow: none;
  39. font-size: 13px;
  40. padding: 4px 8px;
  41. margin-left: 16px;
  42. cursor: help;
  43. `;
  44. return (
  45. <Tooltip content={text} theme={'info'} placement={'top'}>
  46. <div className={styles}>
  47. <i className="fa fa-warning" /> {props.state}
  48. </div>
  49. </Tooltip>
  50. );
  51. };
  52. export default PluginStateinfo;