release.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {
  2. addErrorMessage,
  3. addLoadingMessage,
  4. addSuccessMessage,
  5. } from 'sentry/actionCreators/indicator';
  6. import type {Client} from 'sentry/api';
  7. import {t} from 'sentry/locale';
  8. import {ReleaseStatus} from 'sentry/types/release';
  9. type ParamsGet = {
  10. orgSlug: string;
  11. projectSlug: string;
  12. releaseVersion: string;
  13. };
  14. export function archiveRelease(api: Client, params: ParamsGet) {
  15. const {orgSlug, releaseVersion} = params;
  16. addLoadingMessage(t('Archiving Release\u2026'));
  17. return api
  18. .requestPromise(`/organizations/${orgSlug}/releases/`, {
  19. method: 'POST',
  20. data: {
  21. status: ReleaseStatus.ARCHIVED,
  22. projects: [],
  23. version: releaseVersion,
  24. },
  25. })
  26. .then(() => {
  27. addSuccessMessage(t('Release was successfully archived.'));
  28. })
  29. .catch(error => {
  30. addErrorMessage(
  31. error.responseJSON?.detail ?? t('Release could not be be archived.')
  32. );
  33. throw error;
  34. });
  35. }
  36. export function restoreRelease(api: Client, params: ParamsGet) {
  37. const {orgSlug, releaseVersion} = params;
  38. addLoadingMessage(t('Restoring Release\u2026'));
  39. return api
  40. .requestPromise(`/organizations/${orgSlug}/releases/`, {
  41. method: 'POST',
  42. data: {
  43. status: ReleaseStatus.ACTIVE,
  44. projects: [],
  45. version: releaseVersion,
  46. },
  47. })
  48. .then(() => {
  49. addSuccessMessage(t('Release was successfully restored.'));
  50. })
  51. .catch(error => {
  52. addErrorMessage(
  53. error.responseJSON?.detail ?? t('Release could not be be restored.')
  54. );
  55. throw error;
  56. });
  57. }