fields2.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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('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: '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. export const NOTIFICATION_SETTING_FIELDS_V2: Record<string, Field> = {
  123. ...NOTIFICATION_SETTING_FIELDS,
  124. reports: {
  125. name: 'reports',
  126. type: 'select',
  127. label: t('Weekly Reports'),
  128. help: t('A summary of the past week for an organization.'),
  129. choices: [
  130. ['always', t('On')],
  131. ['never', t('Off')],
  132. ],
  133. },
  134. };
  135. // partial field definition for quota sub-categories
  136. export const QUOTA_FIELDS = [
  137. {
  138. name: 'quotaWarnings',
  139. label: t('Set Quota Limit'),
  140. help: t('Receive notifications when your organization exceeds the following limits.'),
  141. choices: [
  142. ['always', t('100% and 80%')],
  143. ['never', t('100%')],
  144. ] as const,
  145. },
  146. {
  147. name: 'quotaErrors',
  148. label: t('Errors'),
  149. help: tct('Receive notifications about your error quotas. [learnMore:Learn more]', {
  150. learnMore: <ExternalLink href={getDocsLinkForEventType('error')} />,
  151. }),
  152. choices: [
  153. ['always', t('On')],
  154. ['never', t('Off')],
  155. ] as const,
  156. },
  157. {
  158. name: 'quotaTransactions',
  159. label: t('Transactions'),
  160. help: tct(
  161. 'Receive notifications about your transaction quota. [learnMore:Learn more]',
  162. {
  163. learnMore: <ExternalLink href={getDocsLinkForEventType('transaction')} />,
  164. }
  165. ),
  166. choices: [
  167. ['always', t('On')],
  168. ['never', t('Off')],
  169. ] as const,
  170. },
  171. {
  172. name: 'quotaReplays',
  173. label: t('Replays'),
  174. help: tct('Receive notifications about your replay quotas. [learnMore:Learn more]', {
  175. learnMore: <ExternalLink href={getDocsLinkForEventType('replay')} />,
  176. }),
  177. choices: [
  178. ['always', t('On')],
  179. ['never', t('Off')],
  180. ] as const,
  181. },
  182. {
  183. name: 'quotaAttachments',
  184. label: t('Attachments'),
  185. help: tct(
  186. 'Receive notifications about your attachment quota. [learnMore:Learn more]',
  187. {
  188. learnMore: <ExternalLink href={getDocsLinkForEventType('attachment')} />,
  189. }
  190. ),
  191. choices: [
  192. ['always', t('On')],
  193. ['never', t('Off')],
  194. ] as const,
  195. },
  196. {
  197. name: 'quotaSpendAllocations',
  198. label: (
  199. <Fragment>
  200. {t('Spend Allocations')}{' '}
  201. <QuestionTooltip position="top" title="Business plan only" size="xs" />
  202. </Fragment>
  203. ),
  204. help: t('Receive notifications about your spend allocations.'),
  205. choices: [
  206. ['always', t('On')],
  207. ['never', t('Off')],
  208. ] as const,
  209. },
  210. ];