fields2.tsx 5.4 KB

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