subscribeAction.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import ActionButton from 'sentry/components/actions/button';
  2. import {IconSubscribed} from 'sentry/icons';
  3. import {t} from 'sentry/locale';
  4. import type {Group} from 'sentry/types/group';
  5. import {getSubscriptionReason} from '../utils';
  6. type Props = {
  7. group: Group;
  8. onClick: (event: React.MouseEvent) => void;
  9. className?: string;
  10. /**
  11. * Disables the primary color scheme when subscribed
  12. */
  13. disablePriority?: boolean;
  14. disabled?: boolean;
  15. icon?: React.ReactNode;
  16. size?: 'xs' | 'sm';
  17. };
  18. function SubscribeAction({
  19. className,
  20. disabled,
  21. group,
  22. icon,
  23. onClick,
  24. disablePriority,
  25. size = 'xs',
  26. }: Props) {
  27. const disabledNotifications = group.subscriptionDetails?.disabled ?? false;
  28. return (
  29. <ActionButton
  30. className={className}
  31. disabled={disabled || disabledNotifications}
  32. title={getSubscriptionReason(group)}
  33. tooltipProps={{delay: 300}}
  34. priority={!disablePriority && group.isSubscribed ? 'primary' : 'default'}
  35. size={size}
  36. aria-label={t('Subscribe')}
  37. onClick={onClick}
  38. icon={icon ?? <IconSubscribed size={size} />}
  39. />
  40. );
  41. }
  42. export default SubscribeAction;