PluginStateInfo.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React, { FC, useContext } from 'react';
  2. import { css } from 'emotion';
  3. import { PluginState, Tooltip, ThemeContext } from '@grafana/ui';
  4. interface Props {
  5. state?: PluginState;
  6. }
  7. function getPluginStateInfoText(state?: PluginState): string | null {
  8. switch (state) {
  9. case PluginState.alpha:
  10. return 'Plugin in alpha state. Means work in progress and updates may include breaking changes.';
  11. case PluginState.beta:
  12. return 'Plugin in beta state. Means there could be bugs and minor breaking changes.';
  13. }
  14. return null;
  15. }
  16. const PluginStateinfo: FC<Props> = props => {
  17. const text = getPluginStateInfoText(props.state);
  18. if (!text) {
  19. return null;
  20. }
  21. const theme = useContext(ThemeContext);
  22. const styles = css`
  23. background: linear-gradient(to bottom, ${theme.colors.blueBase}, ${theme.colors.blueShade});
  24. color: ${theme.colors.gray7};
  25. white-space: nowrap;
  26. border-radius: 3px;
  27. text-shadow: none;
  28. font-size: 13px;
  29. padding: 4px 8px;
  30. margin-left: 16px;
  31. `;
  32. return (
  33. <Tooltip content={text}>
  34. <div className={styles}>
  35. <i className="fa fa-warning" /> {props.state}
  36. </div>
  37. </Tooltip>
  38. );
  39. };
  40. export default PluginStateinfo;