utils.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. export function getRequestMessages(
  30. updatedRepositoriesQuantity: number,
  31. repositoriesQuantity: number
  32. ) {
  33. if (updatedRepositoriesQuantity > repositoriesQuantity) {
  34. return {
  35. successMessage: t('Successfully added custom repository'),
  36. errorMessage: t('An error occurred while adding a new custom repository'),
  37. };
  38. }
  39. if (updatedRepositoriesQuantity < repositoriesQuantity) {
  40. return {
  41. successMessage: t('Successfully removed custom repository'),
  42. errorMessage: t('An error occurred while removing the custom repository'),
  43. };
  44. }
  45. return {
  46. successMessage: t('Successfully updated custom repository'),
  47. errorMessage: t('An error occurred while updating the custom repository'),
  48. };
  49. }
  50. export function expandKeys(obj: CustomRepo) {
  51. const result = {};
  52. forEach(obj, (value, key) => {
  53. set(result, key.split('.'), value);
  54. });
  55. return result;
  56. }