alerts.tsx 2.3 KB

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