fields2.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import {Fragment} from 'react';
  2. import {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. multiple: true,
  50. onChange: val => {
  51. // This is a little hack to prevent this field from being empty.
  52. // TODO(nisanthan): need to prevent showing the clearable on. the multi-select when its only 1 value.
  53. if (!val || val.length === 0) {
  54. throw Error('Invalid selection. Field cannot be empty.');
  55. }
  56. },
  57. },
  58. approval: {
  59. name: 'approval',
  60. type: 'select',
  61. label: t('Approvals'),
  62. choices: [
  63. ['always', t('On')],
  64. ['never', t('Off')],
  65. ],
  66. help: t('Notifications from teammates that require review or approval.'),
  67. },
  68. quota: {
  69. name: 'quota',
  70. type: 'select',
  71. label: t('Quota'),
  72. choices: [
  73. ['always', t('On')],
  74. ['never', t('Off')],
  75. ],
  76. help: t('Error, transaction, and attachment quota limits.'),
  77. },
  78. reports: {
  79. name: 'weekly reports',
  80. type: 'blank',
  81. label: t('Weekly Reports'),
  82. help: t('A summary of the past week for an organization.'),
  83. },
  84. email: {
  85. name: 'email routing',
  86. type: 'blank',
  87. label: t('Email Routing'),
  88. help: t('Change the email address that receives notifications.'),
  89. },
  90. spikeProtection: {
  91. name: 'spikeProtection',
  92. type: 'select',
  93. label: t('Spike Protection'),
  94. choices: [
  95. ['always', t('On')],
  96. ['never', t('Off')],
  97. ],
  98. help: t('Notifications about spikes on a per project basis.'),
  99. },
  100. personalActivityNotifications: {
  101. name: 'personalActivityNotifications',
  102. type: 'select',
  103. label: t('My Own Activity'),
  104. choices: [
  105. [true as any, t('On')],
  106. [false as any, t('Off')],
  107. ],
  108. help: t('Notifications about your own actions on Sentry.'),
  109. },
  110. selfAssignOnResolve: {
  111. name: 'selfAssignOnResolve',
  112. type: 'select',
  113. label: t('Resolve and Auto-Assign'),
  114. choices: [
  115. [true as any, t('On')],
  116. [false as any, t('Off')],
  117. ],
  118. help: t("When you resolve an unassigned issue, we'll auto-assign it to you."),
  119. },
  120. };
  121. // partial field definition for quota sub-categories
  122. export const QUOTA_FIELDS = [
  123. {
  124. name: 'quotaWarnings',
  125. label: t('Set Quota Limit'),
  126. help: t('Receive notifications when your organization exceeds the following limits.'),
  127. choices: [
  128. ['always', t('100% and 80%')],
  129. ['never', t('100%')],
  130. ] as const,
  131. },
  132. {
  133. name: 'quotaErrors',
  134. label: t('Errors'),
  135. help: tct('Receive notifications about your error quotas. [learnMore:Learn more]', {
  136. learnMore: <ExternalLink href={getDocsLinkForEventType('error')} />,
  137. }),
  138. choices: [
  139. ['always', t('On')],
  140. ['never', t('Off')],
  141. ] as const,
  142. },
  143. {
  144. name: 'quotaTransactions',
  145. label: t('Transactions'),
  146. help: tct(
  147. 'Receive notifications about your transaction quota. [learnMore:Learn more]',
  148. {
  149. learnMore: <ExternalLink href={getDocsLinkForEventType('transaction')} />,
  150. }
  151. ),
  152. choices: [
  153. ['always', t('On')],
  154. ['never', t('Off')],
  155. ] as const,
  156. },
  157. {
  158. name: 'quotaReplays',
  159. label: t('Replays'),
  160. help: tct('Receive notifications about your replay quotas. [learnMore:Learn more]', {
  161. learnMore: <ExternalLink href={getDocsLinkForEventType('replay')} />,
  162. }),
  163. choices: [
  164. ['always', t('On')],
  165. ['never', t('Off')],
  166. ] as const,
  167. },
  168. {
  169. name: 'quotaAttachments',
  170. label: t('Attachments'),
  171. help: tct(
  172. 'Receive notifications about your attachment quota. [learnMore:Learn more]',
  173. {
  174. learnMore: <ExternalLink href={getDocsLinkForEventType('attachment')} />,
  175. }
  176. ),
  177. choices: [
  178. ['always', t('On')],
  179. ['never', t('Off')],
  180. ] as const,
  181. },
  182. {
  183. name: 'quotaSpendAllocations',
  184. label: (
  185. <Fragment>
  186. {t('Spend Allocations')}{' '}
  187. <QuestionTooltip position="top" title="Business plan only" size="xs" />
  188. </Fragment>
  189. ),
  190. help: t('Receive notifications about your spend allocations.'),
  191. choices: [
  192. ['always', t('On')],
  193. ['never', t('Off')],
  194. ] as const,
  195. },
  196. ];