utils.tsx 1.7 KB

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