sentryApplicationRowButtons.tsx 1.6 KB

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