sentryApplicationRowButtons.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import Access from 'sentry/components/acl/access';
  2. import {t} from 'sentry/locale';
  3. import type {SentryApp} from 'sentry/types/integrations';
  4. import type {Organization} from 'sentry/types/organization';
  5. import ActionButtons from './actionButtons';
  6. type Props = {
  7. app: SentryApp;
  8. onClickRemove: (app: SentryApp) => void;
  9. organization: Organization;
  10. onClickPublish?: () => void;
  11. };
  12. function SentryApplicationRowButtons({
  13. organization,
  14. app,
  15. onClickRemove,
  16. onClickPublish,
  17. }: Props) {
  18. const isInternal = app.status === 'internal';
  19. return (
  20. <Access access={['org:admin']}>
  21. {({hasAccess}) => {
  22. let disablePublishReason = '';
  23. let disableDeleteReason = '';
  24. // Publish & Delete buttons will always be disabled if the app is published
  25. if (app.status === 'published') {
  26. disablePublishReason = t('Published integrations cannot be re-published.');
  27. disableDeleteReason = t('Published integrations cannot be removed.');
  28. } else if (!hasAccess) {
  29. disablePublishReason = t(
  30. 'Organization owner permissions are required for this action.'
  31. );
  32. disableDeleteReason = t(
  33. 'Organization owner permissions are required for this action.'
  34. );
  35. }
  36. return (
  37. <ActionButtons
  38. org={organization}
  39. app={app}
  40. showPublish={!isInternal}
  41. showDelete
  42. onPublish={onClickPublish}
  43. onDelete={onClickRemove}
  44. disablePublishReason={disablePublishReason}
  45. disableDeleteReason={disableDeleteReason}
  46. />
  47. );
  48. }}
  49. </Access>
  50. );
  51. }
  52. export default SentryApplicationRowButtons;