PluginStateInfo.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React, { FC } from 'react';
  2. import { PluginState } from '@grafana/data';
  3. import { Badge, BadgeProps } from '@grafana/ui';
  4. interface Props {
  5. state?: PluginState;
  6. }
  7. export const PluginStateInfo: FC<Props> = (props) => {
  8. const display = getFeatureStateInfo(props.state);
  9. if (!display) {
  10. return null;
  11. }
  12. return <Badge color={display.color} title={display.tooltip} text={display.text} icon={display.icon} />;
  13. };
  14. function getFeatureStateInfo(state?: PluginState): BadgeProps | null {
  15. switch (state) {
  16. case PluginState.deprecated:
  17. return {
  18. text: 'Deprecated',
  19. color: 'red',
  20. tooltip: `This feature is deprecated and will be removed in a future release`,
  21. };
  22. case PluginState.alpha:
  23. return {
  24. text: 'Alpha',
  25. color: 'blue',
  26. tooltip: `This feature is experimental and future updates might not be backward compatible`,
  27. };
  28. case PluginState.beta:
  29. return {
  30. text: 'Beta',
  31. color: 'blue',
  32. tooltip: `This feature is close to complete but not fully tested`,
  33. };
  34. default:
  35. return null;
  36. }
  37. }