utils.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import forEach from 'lodash/forEach';
  2. import set from 'lodash/set';
  3. import {t} from 'sentry/locale';
  4. import type {CustomRepo} from 'sentry/types/debugFiles';
  5. import {CustomRepoType} from 'sentry/types/debugFiles';
  6. export const customRepoTypeLabel = {
  7. [CustomRepoType.APP_STORE_CONNECT]: 'App Store Connect',
  8. [CustomRepoType.HTTP]: 'SymbolServer (HTTP)',
  9. [CustomRepoType.S3]: 'Amazon S3',
  10. [CustomRepoType.GCS]: 'Google Cloud Storage',
  11. };
  12. export const dropDownItems = [
  13. {
  14. value: CustomRepoType.S3,
  15. label: customRepoTypeLabel[CustomRepoType.S3],
  16. searchKey: t('aws amazon s3 bucket'),
  17. },
  18. {
  19. value: CustomRepoType.GCS,
  20. label: customRepoTypeLabel[CustomRepoType.GCS],
  21. searchKey: t('gcs google cloud storage bucket'),
  22. },
  23. {
  24. value: CustomRepoType.HTTP,
  25. label: customRepoTypeLabel[CustomRepoType.HTTP],
  26. searchKey: t('http symbol server ssqp symstore symsrv'),
  27. },
  28. {
  29. value: CustomRepoType.APP_STORE_CONNECT,
  30. label: customRepoTypeLabel[CustomRepoType.APP_STORE_CONNECT],
  31. searchKey: t('apple store connect itunes ios'),
  32. },
  33. ];
  34. export function getRequestMessages(
  35. updatedRepositoriesQuantity: number,
  36. repositoriesQuantity: number
  37. ) {
  38. if (updatedRepositoriesQuantity > repositoriesQuantity) {
  39. return {
  40. successMessage: t('Successfully added custom repository'),
  41. errorMessage: t('An error occurred while adding a new custom repository'),
  42. };
  43. }
  44. if (updatedRepositoriesQuantity < repositoriesQuantity) {
  45. return {
  46. successMessage: t('Successfully removed custom repository'),
  47. errorMessage: t('An error occurred while removing the custom repository'),
  48. };
  49. }
  50. return {
  51. successMessage: t('Successfully updated custom repository'),
  52. errorMessage: t('An error occurred while updating the custom repository'),
  53. };
  54. }
  55. export function expandKeys(obj: CustomRepo) {
  56. const result = {};
  57. forEach(obj, (value, key) => {
  58. set(result, key.split('.'), value);
  59. });
  60. return result;
  61. }