relocationRetryModal.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {Fragment} from 'react';
  2. import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
  3. import type {ModalRenderProps} from 'sentry/actionCreators/modal';
  4. import ApiForm from 'sentry/components/forms/apiForm';
  5. import type {Relocation} from 'admin/types';
  6. type Props = ModalRenderProps & {
  7. relocation: Relocation;
  8. onSuccess?: (relocation: Relocation) => void;
  9. };
  10. function RelocationRetryModal({Body, Header, relocation, onSuccess, closeModal}: Props) {
  11. return (
  12. <Fragment>
  13. <Header closeButton>Retry Relocation</Header>
  14. <Body>
  15. <ApiForm
  16. apiMethod="POST"
  17. apiEndpoint={`/relocations/${relocation.uuid}/retry/`}
  18. hostOverride={relocation.region.url}
  19. onSubmitSuccess={(rawRelocation: Relocation) => {
  20. if (onSuccess) {
  21. onSuccess(rawRelocation);
  22. }
  23. closeModal();
  24. addSuccessMessage('This relocation is being retried.');
  25. }}
  26. onSubmitError={error => {
  27. addErrorMessage(error.responseJSON?.detail);
  28. }}
  29. submitLabel="Retry"
  30. >
  31. <p>
  32. Trigger a new relocation with all of the same user submitted data as its
  33. predecessor. This is useful when transient errors or since-fixed bugs cause a
  34. relocation attempt to fail.
  35. </p>
  36. </ApiForm>
  37. </Body>
  38. </Fragment>
  39. );
  40. }
  41. export default RelocationRetryModal;