actions.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {Fragment} from 'react';
  2. import {Button} from 'sentry/components/button';
  3. import {openConfirmModal} from 'sentry/components/confirm';
  4. import {DropdownMenu} from 'sentry/components/dropdownMenu';
  5. import {IconEllipsis} from 'sentry/icons/iconEllipsis';
  6. import {t} from 'sentry/locale';
  7. import TextBlock from 'sentry/views/settings/components/text/textBlock';
  8. type Props = {
  9. hasAccess: boolean;
  10. hasFeature: boolean;
  11. onDelete: () => void;
  12. onEdit: () => void;
  13. repositoryName: string;
  14. };
  15. function Actions({repositoryName, onEdit, onDelete, hasFeature, hasAccess}: Props) {
  16. const actionsDisabled = !hasAccess || !hasFeature;
  17. return (
  18. <DropdownMenu
  19. isDisabled={actionsDisabled}
  20. trigger={triggerProps => (
  21. <Button
  22. size="xs"
  23. aria-label={t('Actions')}
  24. disabled={actionsDisabled}
  25. title={
  26. !hasFeature
  27. ? undefined
  28. : !hasAccess
  29. ? t(
  30. 'You do not have permission to edit and delete custom repositories configurations.'
  31. )
  32. : undefined
  33. }
  34. icon={<IconEllipsis />}
  35. {...triggerProps}
  36. />
  37. )}
  38. position="bottom-end"
  39. items={[
  40. {
  41. key: 'configure',
  42. label: t('Configure'),
  43. onAction: onEdit,
  44. },
  45. {
  46. key: 'delete',
  47. label: t('Delete'),
  48. onAction: () => {
  49. openConfirmModal({
  50. header: <h6>{t('Delete %s?', repositoryName)}</h6>,
  51. message: (
  52. <Fragment>
  53. <TextBlock>
  54. <strong>
  55. {t('Removing this repository applies instantly to new events.')}
  56. </strong>
  57. </TextBlock>
  58. <TextBlock>
  59. {t(
  60. 'Debug files from this repository will not be used to symbolicate future events. This may create new issues and alert members in your organization.'
  61. )}
  62. </TextBlock>
  63. </Fragment>
  64. ),
  65. onConfirm: onDelete,
  66. });
  67. },
  68. },
  69. ]}
  70. />
  71. );
  72. }
  73. export default Actions;