constants.tsx 2.4 KB

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