shareIssue.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import styled from '@emotion/styled';
  2. import {openModal} from 'sentry/actionCreators/modal';
  3. import Button from 'sentry/components/button';
  4. import Tooltip from 'sentry/components/tooltip';
  5. import {t} from 'sentry/locale';
  6. import type {Group, Organization} from 'sentry/types';
  7. import ShareIssueModal from './shareModal';
  8. interface ShareIssueProps {
  9. group: Group;
  10. onToggle: () => void;
  11. organization: Organization;
  12. disabled?: boolean;
  13. disabledReason?: string;
  14. }
  15. function ShareIssue({
  16. onToggle,
  17. disabled,
  18. group,
  19. organization,
  20. disabledReason,
  21. }: ShareIssueProps) {
  22. const handleOpen = () => {
  23. // Starts sharing as soon as dropdown is opened
  24. openModal(modalProps => (
  25. <ShareIssueModal
  26. {...modalProps}
  27. organization={organization}
  28. projectSlug={group.project.slug}
  29. groupId={group.id}
  30. onToggle={onToggle}
  31. />
  32. ));
  33. };
  34. return (
  35. <Tooltip title={disabledReason} disabled={!disabled}>
  36. <Button
  37. type="button"
  38. size="xs"
  39. onClick={handleOpen}
  40. disabled={disabled}
  41. icon={
  42. <IndicatorDot
  43. aria-label={group.isPublic ? t('Shared') : t('Not Shared')}
  44. isShared={group.isPublic}
  45. />
  46. }
  47. >
  48. {t('Share')}
  49. </Button>
  50. </Tooltip>
  51. );
  52. }
  53. export default ShareIssue;
  54. const IndicatorDot = styled('div')<{isShared?: boolean}>`
  55. border-radius: 50%;
  56. width: 10px;
  57. height: 10px;
  58. background: ${p => (p.isShared ? p.theme.active : p.theme.border)};
  59. `;