fields2.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import {Fragment} from 'react';
  2. import FeatureBadge from 'sentry/components/featureBadge';
  3. import {Field} from 'sentry/components/forms/type';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  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. activeRelease: {
  19. name: 'activeRelease',
  20. type: 'select',
  21. label: (
  22. <Fragment>
  23. {t('Release Issues')} <FeatureBadge type="alpha" />
  24. </Fragment>
  25. ),
  26. choices: [
  27. ['always', t('On')],
  28. ['never', t('Off')],
  29. ],
  30. help: t('Notifications sent for issues likely caused by your code changes.'),
  31. },
  32. workflow: {
  33. name: 'workflow',
  34. type: 'select',
  35. label: t('Issue Workflow'),
  36. choices: [
  37. ['always', t('On')],
  38. ['subscribe_only', t('Only Subscribed Issues')],
  39. ['never', t('Off')],
  40. ],
  41. help: t('Changes in issue assignment, resolution status, and comments.'),
  42. },
  43. deploy: {
  44. name: 'deploy',
  45. type: 'select',
  46. label: t('Deploys'),
  47. choices: [
  48. ['always', t('On')],
  49. ['committed_only', t('Releases with My Commits')],
  50. ['never', t('Off')],
  51. ],
  52. help: t('Release, environment, and commit overviews.'),
  53. },
  54. provider: {
  55. name: 'provider',
  56. type: 'select',
  57. label: t('Delivery Method'),
  58. choices: [
  59. ['email', t('Email')],
  60. ['slack', t('Slack')],
  61. ['msteams', t('Microsoft Teams')],
  62. ],
  63. multiple: true,
  64. onChange: val => {
  65. // This is a little hack to prevent this field from being empty.
  66. // TODO(nisanthan): need to prevent showing the clearable on. the multi-select when its only 1 value.
  67. if (!val || val.length === 0) {
  68. throw Error('Invalid selection. Field cannot be empty.');
  69. }
  70. },
  71. },
  72. approval: {
  73. name: 'approval',
  74. type: 'select',
  75. label: t('Approvals'),
  76. choices: [
  77. ['always', t('On')],
  78. ['never', t('Off')],
  79. ],
  80. help: t('Notifications from teammates that require review or approval.'),
  81. },
  82. quota: {
  83. name: 'quota',
  84. type: 'select',
  85. label: t('Quota'),
  86. choices: [
  87. ['always', t('On')],
  88. ['never', t('Off')],
  89. ],
  90. help: t('Error, transaction, and attachment quota limits.'),
  91. },
  92. reports: {
  93. name: 'weekly reports',
  94. type: 'blank',
  95. label: t('Weekly Reports'),
  96. help: t('A summary of the past week for an organization.'),
  97. },
  98. email: {
  99. name: 'email routing',
  100. type: 'blank',
  101. label: t('Email Routing'),
  102. help: t('Change the email address that receives notifications.'),
  103. },
  104. personalActivityNotifications: {
  105. name: 'personalActivityNotifications',
  106. type: 'select',
  107. label: t('My Own Activity'),
  108. choices: [
  109. [true as any, t('On')],
  110. [false as any, t('Off')],
  111. ],
  112. help: t('Notifications about your own actions on Sentry.'),
  113. },
  114. selfAssignOnResolve: {
  115. name: 'selfAssignOnResolve',
  116. type: 'select',
  117. label: t('Claim Unassigned Issues I’ve Resolved'),
  118. choices: [
  119. [true as any, t('On')],
  120. [false as any, t('Off')],
  121. ],
  122. help: t('You’ll receive notifications about any changes that happen afterwards.'),
  123. },
  124. };
  125. // partial field definition for quota sub-categories
  126. export const QUOTA_FIELDS = [
  127. {
  128. name: 'quotaWarnings',
  129. label: t('Set Quota Limit'),
  130. help: t(
  131. 'Receive notifications when your organization exceeeds the following limits.'
  132. ),
  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: 'quotaAttachments',
  165. label: t('Attachments'),
  166. help: tct(
  167. 'Receive notifications about your attachment quota. [learnMore:Learn more]',
  168. {
  169. learnMore: <ExternalLink href={getDocsLinkForEventType('attachment')} />,
  170. }
  171. ),
  172. choices: [
  173. ['always', t('On')],
  174. ['never', t('Off')],
  175. ] as const,
  176. },
  177. ];