ExternallyManagedButton.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from 'react';
  2. import { HorizontalGroup, LinkButton } from '@grafana/ui';
  3. import { getExternalManageLink } from '../../helpers';
  4. import { PluginStatus } from '../../types';
  5. type ExternallyManagedButtonProps = {
  6. pluginId: string;
  7. pluginStatus: PluginStatus;
  8. };
  9. export function ExternallyManagedButton({ pluginId, pluginStatus }: ExternallyManagedButtonProps) {
  10. const externalManageLink = `${getExternalManageLink(pluginId)}/?tab=installation`;
  11. if (pluginStatus === PluginStatus.UPDATE) {
  12. return (
  13. <HorizontalGroup height="auto">
  14. <LinkButton href={externalManageLink} target="_blank" rel="noopener noreferrer">
  15. Update via grafana.com
  16. </LinkButton>
  17. <LinkButton variant="destructive" href={externalManageLink} target="_blank" rel="noopener noreferrer">
  18. Uninstall via grafana.com
  19. </LinkButton>
  20. </HorizontalGroup>
  21. );
  22. }
  23. if (pluginStatus === PluginStatus.UNINSTALL) {
  24. return (
  25. <LinkButton variant="destructive" href={externalManageLink} target="_blank" rel="noopener noreferrer">
  26. Uninstall via grafana.com
  27. </LinkButton>
  28. );
  29. }
  30. return (
  31. <LinkButton href={externalManageLink} target="_blank" rel="noopener noreferrer">
  32. Install via grafana.com
  33. </LinkButton>
  34. );
  35. }