PluginEnterpriseBadge.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import React from 'react';
  2. import { featureEnabled } from '@grafana/runtime';
  3. import { Badge, Button, HorizontalGroup, PluginSignatureBadge, useStyles2 } from '@grafana/ui';
  4. import { CatalogPlugin } from '../../types';
  5. import { getBadgeColor } from './sharedStyles';
  6. type Props = { plugin: CatalogPlugin };
  7. export function PluginEnterpriseBadge({ plugin }: Props): React.ReactElement {
  8. const customBadgeStyles = useStyles2(getBadgeColor);
  9. const onClick = (ev: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
  10. ev.preventDefault();
  11. window.open(
  12. `https://grafana.com/grafana/plugins/${plugin.id}?utm_source=grafana_catalog_learn_more`,
  13. '_blank',
  14. 'noopener,noreferrer'
  15. );
  16. };
  17. if (featureEnabled('enterprise.plugins')) {
  18. return <Badge text="Enterprise" color="blue" />;
  19. }
  20. return (
  21. <HorizontalGroup>
  22. <PluginSignatureBadge status={plugin.signature} />
  23. <Badge icon="lock" aria-label="lock icon" text="Enterprise" color="blue" className={customBadgeStyles} />
  24. <Button size="sm" fill="text" icon="external-link-alt" onClick={onClick}>
  25. Learn more
  26. </Button>
  27. </HorizontalGroup>
  28. );
  29. }