alerts.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import {IssueConfigField} from 'app/types/index';
  2. import {SchemaFormConfig} from 'app/views/organizationIntegrations/sentryAppExternalForm';
  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. placeholder?: number | string;
  18. initial?: 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. id: string;
  26. label: string;
  27. prompt: string;
  28. enabled: boolean;
  29. actionType?: 'ticket' | 'sentryapp';
  30. formFields?:
  31. | {
  32. [key: string]: IssueAlertRuleFormField;
  33. }
  34. | SchemaFormConfig;
  35. ticketType?: string;
  36. link?: string;
  37. sentryAppInstallationUuid?: string;
  38. };
  39. export type IssueAlertRuleConditionTemplate = IssueAlertRuleActionTemplate;
  40. /**
  41. * These are the action or condition data that the user is editing or has saved.
  42. */
  43. export type IssueAlertRuleAction = Omit<
  44. IssueAlertRuleActionTemplate,
  45. 'formFields' | 'enabled'
  46. > & {
  47. dynamic_form_fields?: IssueConfigField[];
  48. } & {
  49. // These are the same values as the keys in `formFields` for a template
  50. [key: string]: number | string;
  51. };
  52. export type IssueAlertRuleCondition = Omit<
  53. IssueAlertRuleConditionTemplate,
  54. 'formFields' | 'enabled'
  55. > & {
  56. dynamic_form_fields?: IssueConfigField[];
  57. } & {
  58. // These are the same values as the keys in `formFields` for a template
  59. [key: string]: number | string;
  60. };
  61. export type UnsavedIssueAlertRule = {
  62. /** When an issue matches [actionMatch] of the following */
  63. actionMatch: 'all' | 'any' | 'none';
  64. /** If that issue has [filterMatch] of these properties */
  65. filterMatch: 'all' | 'any' | 'none';
  66. actions: IssueAlertRuleAction[];
  67. conditions: IssueAlertRuleCondition[];
  68. filters: IssueAlertRuleCondition[];
  69. environment?: null | string;
  70. frequency: number;
  71. name: string;
  72. owner?: string | null;
  73. };
  74. // Issue-based alert rule
  75. export type IssueAlertRule = UnsavedIssueAlertRule & {
  76. dateCreated: string;
  77. createdBy: {id: number; email: string; name: string} | null;
  78. projects: string[];
  79. id: string;
  80. };
  81. export enum MailActionTargetType {
  82. IssueOwners = 'IssueOwners',
  83. Team = 'Team',
  84. Member = 'Member',
  85. }
  86. export enum AssigneeTargetType {
  87. Unassigned = 'Unassigned',
  88. Team = 'Team',
  89. Member = 'Member',
  90. }
  91. export type NoteType = {
  92. text: string;
  93. mentions: string[];
  94. };