fields2.tsx 5.4 KB

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