constants.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. ] as const;
  51. export const SELF_NOTIFICATION_SETTINGS_TYPES = [
  52. 'personalActivityNotifications',
  53. 'selfAssignOnResolve',
  54. ];
  55. // 'alerts' | 'workflow' ...
  56. export type NotificationSettingsType = (typeof NOTIFICATION_SETTINGS_TYPES)[number];
  57. export const NOTIFICATION_SETTINGS_PATHNAMES: Record<NotificationSettingsType, string> = {
  58. alerts: 'alerts',
  59. workflow: 'workflow',
  60. deploy: 'deploy',
  61. approval: 'approval',
  62. quota: 'quota',
  63. reports: 'reports',
  64. email: 'email',
  65. spikeProtection: 'spike-protection',
  66. };
  67. export const CONFIRMATION_MESSAGE = (
  68. <div>
  69. <p style={{marginBottom: '20px'}}>
  70. <strong>Are you sure you want to disable these notifications?</strong>
  71. </p>
  72. <p>
  73. {t(
  74. 'Turning this off will irreversibly overwrite all of your fine-tuning settings to "off".'
  75. )}
  76. </p>
  77. </div>
  78. );
  79. export const NOTIFICATION_FEATURE_MAP: Partial<
  80. Record<NotificationSettingsType, string | Array<string>>
  81. > = {
  82. quota: ['spend-visibility-notifications', 'user-spend-notifications-settings'],
  83. spikeProtection: 'spike-projections',
  84. };