constants.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. interface NotificationBaseObject {
  24. id: string;
  25. scopeIdentifier: string;
  26. scopeType: string;
  27. type: string;
  28. }
  29. export interface NotificationOptionsObject extends NotificationBaseObject {
  30. value: ProviderValue | 'subscribe_only' | 'committed_only';
  31. }
  32. export interface NotificationProvidersObject extends NotificationBaseObject {
  33. provider: SupportedProviders;
  34. value: ProviderValue;
  35. }
  36. export interface DefaultSettings {
  37. providerDefaults: SupportedProviders[];
  38. typeDefaults: Record<string, ProviderValue>;
  39. }
  40. export const NOTIFICATION_SETTINGS_TYPES = [
  41. 'alerts',
  42. 'workflow',
  43. 'deploy',
  44. 'approval',
  45. 'quota',
  46. 'reports',
  47. 'email',
  48. 'spikeProtection',
  49. ] as const;
  50. export const SELF_NOTIFICATION_SETTINGS_TYPES = [
  51. 'personalActivityNotifications',
  52. 'selfAssignOnResolve',
  53. ];
  54. // 'alerts' | 'workflow' ...
  55. export type NotificationSettingsType = (typeof NOTIFICATION_SETTINGS_TYPES)[number];
  56. export const NOTIFICATION_SETTINGS_PATHNAMES: Record<NotificationSettingsType, string> = {
  57. alerts: 'alerts',
  58. workflow: 'workflow',
  59. deploy: 'deploy',
  60. approval: 'approval',
  61. quota: 'quota',
  62. reports: 'reports',
  63. email: 'email',
  64. spikeProtection: 'spike-protection',
  65. };
  66. export const CONFIRMATION_MESSAGE = (
  67. <div>
  68. <p style={{marginBottom: '20px'}}>
  69. <strong>Are you sure you want to disable these notifications?</strong>
  70. </p>
  71. <p>
  72. {t(
  73. 'Turning this off will irreversibly overwrite all of your fine-tuning settings to "off".'
  74. )}
  75. </p>
  76. </div>
  77. );
  78. export const NOTIFICATION_FEATURE_MAP: Partial<Record<NotificationSettingsType, string>> =
  79. {
  80. quota: 'slack-overage-notifications',
  81. spikeProtection: 'spike-projections',
  82. };