fields2.tsx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import {Fragment} from 'react';
  2. import type {Field} from 'sentry/components/forms/types';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import QuestionTooltip from 'sentry/components/questionTooltip';
  5. import {t, tct} from 'sentry/locale';
  6. import {getDocsLinkForEventType} from 'sentry/views/settings/account/notifications/utils';
  7. export const NOTIFICATION_SETTING_FIELDS: Record<string, Field> = {
  8. alerts: {
  9. name: 'alerts',
  10. type: 'select',
  11. label: t('Issue Alerts'),
  12. choices: [
  13. ['always', t('On')],
  14. ['never', t('Off')],
  15. ],
  16. help: t('Notifications sent from Alert rules that your team has set up.'),
  17. },
  18. workflow: {
  19. name: 'workflow',
  20. type: 'select',
  21. label: t('Issue Workflow'),
  22. choices: [
  23. ['always', t('On')],
  24. ['subscribe_only', t('Only Subscribed Issues')],
  25. ['never', t('Off')],
  26. ],
  27. help: t('Changes in issue assignment, resolution status, and comments.'),
  28. },
  29. deploy: {
  30. name: 'deploy',
  31. type: 'select',
  32. label: t('Deploys'),
  33. choices: [
  34. ['always', t('On')],
  35. ['committed_only', t('Releases with My Commits')],
  36. ['never', t('Off')],
  37. ],
  38. help: t('Release, environment, and commit overviews.'),
  39. },
  40. provider: {
  41. name: 'provider',
  42. type: 'select',
  43. label: t('Delivery Method'),
  44. choices: [
  45. ['email', t('Email')],
  46. ['slack', t('Slack')],
  47. ['msteams', t('Microsoft Teams')],
  48. ],
  49. help: t('Where personal notifications will be sent.'),
  50. multiple: true,
  51. onChange: val => {
  52. // This is a little hack to prevent this field from being empty.
  53. // TODO(nisanthan): need to prevent showing the clearable on. the multi-select when its only 1 value.
  54. if (!val || val.length === 0) {
  55. throw Error('Invalid selection. Field cannot be empty.');
  56. }
  57. },
  58. },
  59. approval: {
  60. name: 'approval',
  61. type: 'select',
  62. label: t('Nudges'),
  63. choices: [
  64. ['always', t('On')],
  65. ['never', t('Off')],
  66. ],
  67. help: t('Notifications that require review or approval.'),
  68. },
  69. quota: {
  70. name: 'quota',
  71. type: 'select',
  72. label: t('Quota'),
  73. choices: [
  74. ['always', t('On')],
  75. ['never', t('Off')],
  76. ],
  77. help: t('Error, transaction, and attachment quota limits.'),
  78. },
  79. reports: {
  80. name: 'reports',
  81. type: 'select',
  82. label: t('Weekly Reports'),
  83. help: t('A summary of the past week for an organization.'),
  84. choices: [
  85. ['always', t('On')],
  86. ['never', t('Off')],
  87. ],
  88. },
  89. email: {
  90. name: 'email routing',
  91. type: 'blank',
  92. label: t('Email Routing'),
  93. help: t('Change the email address that receives notifications.'),
  94. },
  95. spikeProtection: {
  96. name: 'spikeProtection',
  97. type: 'select',
  98. label: t('Spike Protection'),
  99. choices: [
  100. ['always', t('On')],
  101. ['never', t('Off')],
  102. ],
  103. help: t('Notifications about spikes on a per project basis.'),
  104. },
  105. // legacy options
  106. personalActivityNotifications: {
  107. name: 'personalActivityNotifications',
  108. type: 'select',
  109. label: t('My Own Activity'),
  110. choices: [
  111. [true as any, t('On')],
  112. [false as any, t('Off')],
  113. ],
  114. help: t('Notifications about your own actions on Sentry.'),
  115. },
  116. selfAssignOnResolve: {
  117. name: 'selfAssignOnResolve',
  118. type: 'select',
  119. label: t('Resolve and Auto-Assign'),
  120. choices: [
  121. [true as any, t('On')],
  122. [false as any, t('Off')],
  123. ],
  124. help: t("When you resolve an unassigned issue, we'll auto-assign it to you."),
  125. },
  126. };
  127. // partial field definition for quota sub-categories
  128. export const QUOTA_FIELDS = [
  129. {
  130. name: 'quotaWarnings',
  131. label: t('Set Quota Limit'),
  132. help: t('Receive notifications when your organization exceeds the following limits.'),
  133. choices: [
  134. ['always', t('100% and 80%')],
  135. ['never', t('100%')],
  136. ] as const,
  137. },
  138. {
  139. name: 'quotaErrors',
  140. label: t('Errors'),
  141. help: tct('Receive notifications about your error quotas. [learnMore:Learn more]', {
  142. learnMore: <ExternalLink href={getDocsLinkForEventType('error')} />,
  143. }),
  144. choices: [
  145. ['always', t('On')],
  146. ['never', t('Off')],
  147. ] as const,
  148. },
  149. {
  150. name: 'quotaTransactions',
  151. label: t('Transactions'),
  152. help: tct(
  153. 'Receive notifications about your transaction quota. [learnMore:Learn more]',
  154. {
  155. learnMore: <ExternalLink href={getDocsLinkForEventType('transaction')} />,
  156. }
  157. ),
  158. choices: [
  159. ['always', t('On')],
  160. ['never', t('Off')],
  161. ] as const,
  162. },
  163. {
  164. name: 'quotaReplays',
  165. label: t('Replays'),
  166. help: tct('Receive notifications about your replay quotas. [learnMore:Learn more]', {
  167. learnMore: <ExternalLink href={getDocsLinkForEventType('replay')} />,
  168. }),
  169. choices: [
  170. ['always', t('On')],
  171. ['never', t('Off')],
  172. ] as const,
  173. },
  174. {
  175. name: 'quotaAttachments',
  176. label: t('Attachments'),
  177. help: tct(
  178. 'Receive notifications about your attachment quota. [learnMore:Learn more]',
  179. {
  180. learnMore: <ExternalLink href={getDocsLinkForEventType('attachment')} />,
  181. }
  182. ),
  183. choices: [
  184. ['always', t('On')],
  185. ['never', t('Off')],
  186. ] as const,
  187. },
  188. {
  189. name: 'quotaMonitorSeats',
  190. label: t('Cron Monitors'),
  191. help: tct(
  192. 'Receive notifications about your cron monitors quotas. [learnMore:Learn more]',
  193. {
  194. learnMore: <ExternalLink href={getDocsLinkForEventType('monitorSeat')} />,
  195. }
  196. ),
  197. choices: [
  198. ['always', t('On')],
  199. ['never', t('Off')],
  200. ] as const,
  201. },
  202. {
  203. name: 'quotaSpendAllocations',
  204. label: (
  205. <Fragment>
  206. {t('Spend Allocations')}{' '}
  207. <QuestionTooltip position="top" title="Business plan only" size="xs" />
  208. </Fragment>
  209. ),
  210. help: t('Receive notifications about your spend allocations.'),
  211. choices: [
  212. ['always', t('On')],
  213. ['never', t('Off')],
  214. ] as const,
  215. },
  216. ];