constants.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import {t} from 'sentry/locale';
  2. export const ALL_PROVIDERS = {
  3. email: 'default',
  4. slack: 'never',
  5. msteams: 'never',
  6. };
  7. export const ALL_PROVIDER_NAMES = Object.keys(ALL_PROVIDERS);
  8. /**
  9. * These values are stolen from the DB.
  10. */
  11. export const VALUE_MAPPING = {
  12. default: 0,
  13. never: 10,
  14. always: 20,
  15. subscribe_only: 30,
  16. committed_only: 40,
  17. };
  18. export const MIN_PROJECTS_FOR_CONFIRMATION = 3;
  19. export const MIN_PROJECTS_FOR_SEARCH = 3;
  20. export const MIN_PROJECTS_FOR_PAGINATION = 100;
  21. export type SupportedProviders = 'email' | 'slack' | 'msteams';
  22. export type ProviderValue = 'always' | 'never';
  23. export type NotificationSettingsByProviderObject = {[key: string]: string};
  24. export type NotificationSettingsObject = {
  25. [key: string]: {[key: string]: {[key: string]: NotificationSettingsByProviderObject}};
  26. };
  27. interface NotificationBaseObject {
  28. id: string;
  29. scopeIdentifier: string;
  30. scopeType: string;
  31. type: string;
  32. }
  33. export interface NotificationOptionsObject extends NotificationBaseObject {
  34. value: ProviderValue | 'subscribe_only' | 'committed_only';
  35. }
  36. export interface NotificationProvidersObject extends NotificationBaseObject {
  37. provider: SupportedProviders;
  38. value: ProviderValue;
  39. }
  40. export interface DefaultSettings {
  41. providerDefaults: SupportedProviders[];
  42. typeDefaults: Record<string, ProviderValue>;
  43. }
  44. export const NOTIFICATION_SETTINGS_TYPES = [
  45. 'alerts',
  46. 'workflow',
  47. 'deploy',
  48. 'approval',
  49. 'quota',
  50. 'reports',
  51. 'email',
  52. 'spikeProtection',
  53. ] as const;
  54. export const SELF_NOTIFICATION_SETTINGS_TYPES = [
  55. 'personalActivityNotifications',
  56. 'selfAssignOnResolve',
  57. ];
  58. // 'alerts' | 'workflow' ...
  59. export type NotificationSettingsType = (typeof NOTIFICATION_SETTINGS_TYPES)[number];
  60. export const NOTIFICATION_SETTINGS_PATHNAMES: Record<NotificationSettingsType, string> = {
  61. alerts: 'alerts',
  62. workflow: 'workflow',
  63. deploy: 'deploy',
  64. approval: 'approval',
  65. quota: 'quota',
  66. reports: 'reports',
  67. email: 'email',
  68. spikeProtection: 'spike-protection',
  69. };
  70. export const CONFIRMATION_MESSAGE = (
  71. <div>
  72. <p style={{marginBottom: '20px'}}>
  73. <strong>Are you sure you want to disable these notifications?</strong>
  74. </p>
  75. <p>
  76. {t(
  77. 'Turning this off will irreversibly overwrite all of your fine-tuning settings to "off".'
  78. )}
  79. </p>
  80. </div>
  81. );
  82. export const NOTIFICATION_FEATURE_MAP: Partial<Record<NotificationSettingsType, string>> =
  83. {
  84. quota: 'slack-overage-notifications',
  85. spikeProtection: 'spike-projections',
  86. };