alerts.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import type {SchemaFormConfig} from 'sentry/views/organizationIntegrations/sentryAppExternalForm';
  2. import type {IssueConfigField} from './integrations';
  3. type IssueAlertRuleFormField =
  4. | {
  5. type: 'choice';
  6. choices?: [string, string][];
  7. initial?: string;
  8. placeholder?: string;
  9. }
  10. | {
  11. type: 'string';
  12. initial?: string;
  13. placeholder?: string;
  14. }
  15. | {
  16. type: 'number';
  17. initial?: string;
  18. placeholder?: number | string;
  19. };
  20. /**
  21. * These templates that tell the UI how to render the action or condition
  22. * and what fields it needs
  23. */
  24. export type IssueAlertRuleActionTemplate = {
  25. enabled: boolean;
  26. id: string;
  27. label: string;
  28. name: string;
  29. prompt: string;
  30. actionType?: 'ticket' | 'sentryapp';
  31. formFields?:
  32. | {
  33. [key: string]: IssueAlertRuleFormField;
  34. }
  35. | SchemaFormConfig;
  36. link?: string;
  37. sentryAppInstallationUuid?: string;
  38. ticketType?: string;
  39. };
  40. export type IssueAlertRuleConditionTemplate = IssueAlertRuleActionTemplate;
  41. /**
  42. * These are the action or condition data that the user is editing or has saved.
  43. */
  44. export type IssueAlertRuleAction = Omit<
  45. IssueAlertRuleActionTemplate,
  46. 'formFields' | 'enabled'
  47. > & {
  48. dynamic_form_fields?: IssueConfigField[];
  49. } & {
  50. // These are the same values as the keys in `formFields` for a template
  51. [key: string]: any;
  52. };
  53. export type IssueAlertRuleCondition = Omit<
  54. IssueAlertRuleConditionTemplate,
  55. 'formFields' | 'enabled'
  56. > & {
  57. dynamic_form_fields?: IssueConfigField[];
  58. } & {
  59. // These are the same values as the keys in `formFields` for a template
  60. [key: string]: number | string;
  61. };
  62. export type UnsavedIssueAlertRule = {
  63. /** When an issue matches [actionMatch] of the following */
  64. actionMatch: 'all' | 'any' | 'none';
  65. actions: IssueAlertRuleAction[];
  66. conditions: IssueAlertRuleCondition[];
  67. /** If that issue has [filterMatch] of these properties */
  68. filterMatch: 'all' | 'any' | 'none';
  69. filters: IssueAlertRuleCondition[];
  70. frequency: number;
  71. name: string;
  72. environment?: null | string;
  73. owner?: string | null;
  74. };
  75. // Issue-based alert rule
  76. export type IssueAlertRule = UnsavedIssueAlertRule & {
  77. createdBy: {email: string; id: number; name: string} | null;
  78. dateCreated: string;
  79. id: string;
  80. projects: string[];
  81. errors?: {detail: string}[];
  82. lastTriggered?: string;
  83. };
  84. // Project's alert rule stats
  85. export type ProjectAlertRuleStats = {
  86. count: number;
  87. date: string;
  88. };
  89. export enum MailActionTargetType {
  90. IssueOwners = 'IssueOwners',
  91. Team = 'Team',
  92. Member = 'Member',
  93. ReleaseMembers = 'ReleaseMembers',
  94. }
  95. export enum AssigneeTargetType {
  96. Unassigned = 'Unassigned',
  97. Team = 'Team',
  98. Member = 'Member',
  99. }
  100. export type NoteType = {
  101. mentions: string[];
  102. text: string;
  103. };