PluginDisabledBadge.tsx 865 B

123456789101112131415161718192021222324
  1. import React from 'react';
  2. import { PluginErrorCode } from '@grafana/data';
  3. import { Badge } from '@grafana/ui';
  4. type Props = { error?: PluginErrorCode };
  5. export function PluginDisabledBadge({ error }: Props): React.ReactElement {
  6. const tooltip = errorCodeToTooltip(error);
  7. return <Badge icon="exclamation-triangle" text="Disabled" color="red" tooltip={tooltip} />;
  8. }
  9. function errorCodeToTooltip(error?: PluginErrorCode): string | undefined {
  10. switch (error) {
  11. case PluginErrorCode.modifiedSignature:
  12. return 'Plugin disabled due to modified content';
  13. case PluginErrorCode.invalidSignature:
  14. return 'Plugin disabled due to invalid plugin signature';
  15. case PluginErrorCode.missingSignature:
  16. return 'Plugin disabled due to missing plugin signature';
  17. default:
  18. return `Plugin disabled due to unkown error: ${error}`;
  19. }
  20. }