utils.tsx 1.9 KB

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