@oneuptime/common 7.0.3621 → 7.0.3652

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/Models/DatabaseModels/Alert.ts +29 -0
  2. package/Models/DatabaseModels/Index.ts +10 -0
  3. package/Models/DatabaseModels/ScheduledMaintenance.ts +29 -0
  4. package/Models/DatabaseModels/WorkspaceNotificationRule.ts +461 -0
  5. package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +379 -0
  6. package/Models/DatabaseModels/WorkspaceSetting.ts +230 -0
  7. package/Models/DatabaseModels/WorkspaceUserAuthToken.ts +312 -0
  8. package/Server/API/SlackAPI.ts +368 -0
  9. package/Server/EnvironmentConfig.ts +10 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.ts +147 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.ts +19 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.ts +23 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  14. package/Server/Middleware/SlackAuthorization.ts +60 -0
  15. package/Server/Services/AlertService.ts +38 -2
  16. package/Server/Services/Index.ts +9 -0
  17. package/Server/Services/ProjectService.ts +3 -1
  18. package/Server/Services/ScheduledMaintenanceService.ts +39 -2
  19. package/Server/Services/UserService.ts +1 -1
  20. package/Server/Services/WorkspaceCommunicationTools/Slack.ts +0 -0
  21. package/Server/Services/WorkspaceCommunicationTools/Teams.ts +0 -0
  22. package/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.ts +0 -0
  23. package/Server/Services/WorkspaceNotificationRuleService.ts +22 -0
  24. package/Server/Services/WorkspaceProjectAuthTokenService.ts +84 -0
  25. package/Server/Services/WorkspaceSettingService.ts +78 -0
  26. package/Server/Services/WorkspaceUserAuthTokenService.ts +89 -0
  27. package/Server/Types/Workflow/Components/Slack/SendMessageToChannel.ts +1 -1
  28. package/Server/Utils/Express.ts +2 -1
  29. package/Server/Utils/Monitor/MonitorResource.ts +2 -5
  30. package/Server/Utils/{Slack.ts → Slack/Slack.ts} +40 -0
  31. package/Server/Utils/Slack/app-manifest-temp.json +198 -0
  32. package/Server/Utils/Slack/app-manifest.json +67 -0
  33. package/Server/Utils/StartServer.ts +2 -1
  34. package/Types/Filter/FilterCondition.ts +2 -2
  35. package/Types/Monitor/CriteriaFilter.ts +31 -5
  36. package/Types/Monitor/MonitorCriteriaInstance.ts +40 -10
  37. package/Types/Monitor/MonitorStep.ts +1 -1
  38. package/Types/Permission.ts +34 -0
  39. package/Types/Workspace/NotificationRules/BaseNotificationRule.ts +3 -0
  40. package/Types/Workspace/NotificationRules/EventType.ts +8 -0
  41. package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +355 -0
  42. package/Types/Workspace/NotificationRules/SlackNotificationRule.ts +19 -0
  43. package/Types/Workspace/WorkspaceNotificationPayload.ts +3 -0
  44. package/Types/Workspace/WorkspaceType.ts +6 -0
  45. package/UI/Components/Forms/BasicForm.tsx +9 -0
  46. package/UI/Components/Forms/Fields/FormField.tsx +36 -1
  47. package/UI/Components/Forms/Types/Field.ts +2 -0
  48. package/UI/Components/Forms/Types/FormFieldSchemaType.ts +1 -1
  49. package/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.ts +2 -2
  50. package/UI/Components/Icon/Icon.tsx +18 -5
  51. package/UI/Components/Radio/Radio.tsx +12 -10
  52. package/UI/Config.ts +3 -0
  53. package/build/dist/Models/DatabaseModels/Alert.js +31 -0
  54. package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
  55. package/build/dist/Models/DatabaseModels/Index.js +8 -0
  56. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  57. package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js +31 -0
  58. package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
  59. package/build/dist/Models/DatabaseModels/WorkspaceNotificationRule.js +481 -0
  60. package/build/dist/Models/DatabaseModels/WorkspaceNotificationRule.js.map +1 -0
  61. package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js +390 -0
  62. package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -0
  63. package/build/dist/Models/DatabaseModels/WorkspaceSetting.js +236 -0
  64. package/build/dist/Models/DatabaseModels/WorkspaceSetting.js.map +1 -0
  65. package/build/dist/Models/DatabaseModels/WorkspaceUserAuthToken.js +326 -0
  66. package/build/dist/Models/DatabaseModels/WorkspaceUserAuthToken.js.map +1 -0
  67. package/build/dist/Server/API/SlackAPI.js +237 -0
  68. package/build/dist/Server/API/SlackAPI.js.map +1 -0
  69. package/build/dist/Server/EnvironmentConfig.js +5 -1
  70. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  71. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.js +58 -0
  72. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.js.map +1 -0
  73. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.js +14 -0
  74. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.js.map +1 -0
  75. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.js +14 -0
  76. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.js.map +1 -0
  77. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  78. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  79. package/build/dist/Server/Middleware/SlackAuthorization.js +28 -0
  80. package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -0
  81. package/build/dist/Server/Services/AlertService.js +31 -5
  82. package/build/dist/Server/Services/AlertService.js.map +1 -1
  83. package/build/dist/Server/Services/Index.js +8 -0
  84. package/build/dist/Server/Services/Index.js.map +1 -1
  85. package/build/dist/Server/Services/ProjectService.js +2 -1
  86. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  87. package/build/dist/Server/Services/ScheduledMaintenanceService.js +30 -3
  88. package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
  89. package/build/dist/Server/Services/UserService.js +1 -1
  90. package/build/dist/Server/Services/UserService.js.map +1 -1
  91. package/build/dist/Server/Services/WorkspaceCommunicationTools/Slack.js +2 -0
  92. package/build/dist/Server/Services/WorkspaceCommunicationTools/Slack.js.map +1 -0
  93. package/build/dist/Server/Services/WorkspaceCommunicationTools/Teams.js +2 -0
  94. package/build/dist/Server/Services/WorkspaceCommunicationTools/Teams.js.map +1 -0
  95. package/build/dist/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.js +2 -0
  96. package/build/dist/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.js.map +1 -0
  97. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +14 -0
  98. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -0
  99. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +63 -0
  100. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -0
  101. package/build/dist/Server/Services/WorkspaceSettingService.js +59 -0
  102. package/build/dist/Server/Services/WorkspaceSettingService.js.map +1 -0
  103. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +66 -0
  104. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -0
  105. package/build/dist/Server/Types/Workflow/Components/Slack/SendMessageToChannel.js +1 -1
  106. package/build/dist/Server/Types/Workflow/Components/Slack/SendMessageToChannel.js.map +1 -1
  107. package/build/dist/Server/Utils/Express.js.map +1 -1
  108. package/build/dist/Server/Utils/Monitor/MonitorResource.js +2 -1
  109. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  110. package/build/dist/Server/Utils/Slack/Slack.js +49 -0
  111. package/build/dist/Server/Utils/Slack/Slack.js.map +1 -0
  112. package/build/dist/Server/Utils/Slack/app-manifest.json +67 -0
  113. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  114. package/build/dist/Types/Filter/FilterCondition.js +2 -2
  115. package/build/dist/Types/Filter/FilterCondition.js.map +1 -1
  116. package/build/dist/Types/Monitor/CriteriaFilter.js +19 -5
  117. package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
  118. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +33 -10
  119. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
  120. package/build/dist/Types/Monitor/MonitorStep.js +1 -1
  121. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  122. package/build/dist/Types/Permission.js +32 -0
  123. package/build/dist/Types/Permission.js.map +1 -1
  124. package/build/dist/Types/Workspace/NotificationRules/BaseNotificationRule.js +2 -0
  125. package/build/dist/Types/Workspace/NotificationRules/BaseNotificationRule.js.map +1 -0
  126. package/build/dist/Types/Workspace/NotificationRules/EventType.js +9 -0
  127. package/build/dist/Types/Workspace/NotificationRules/EventType.js.map +1 -0
  128. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +275 -0
  129. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -0
  130. package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js +2 -0
  131. package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js.map +1 -0
  132. package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js +2 -0
  133. package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js.map +1 -0
  134. package/build/dist/Types/Workspace/WorkspaceType.js +7 -0
  135. package/build/dist/Types/Workspace/WorkspaceType.js.map +1 -0
  136. package/build/dist/UI/Components/Forms/BasicForm.js +7 -0
  137. package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
  138. package/build/dist/UI/Components/Forms/Fields/FormField.js +21 -4
  139. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  140. package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js +1 -1
  141. package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js.map +1 -1
  142. package/build/dist/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.js +2 -2
  143. package/build/dist/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.js.map +1 -1
  144. package/build/dist/UI/Components/Icon/Icon.js +5 -1
  145. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  146. package/build/dist/UI/Components/Radio/Radio.js +4 -4
  147. package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
  148. package/build/dist/UI/Config.js +1 -0
  149. package/build/dist/UI/Config.js.map +1 -1
  150. package/package.json +2 -2
  151. package/build/dist/Server/Utils/Slack.js +0 -20
  152. package/build/dist/Server/Utils/Slack.js.map +0 -1
@@ -607,6 +607,11 @@ enum Permission {
607
607
  DeleteTableView = "DeleteTableView",
608
608
  EditTableView = "EditTableView",
609
609
  ReadTableView = "ReadTableView",
610
+
611
+ CreateWorkspaceNotificationRule = "CreateWorkspaceNotificationRule",
612
+ DeleteWorkspaceNotificationRule = "DeleteWorkspaceNotificationRule",
613
+ EditWorkspaceNotificationRule = "EditWorkspaceNotificationRule",
614
+ ReadWorkspaceNotificationRule = "ReadWorkspaceNotificationRule",
610
615
  }
611
616
 
612
617
  export class PermissionHelper {
@@ -1039,6 +1044,35 @@ export class PermissionHelper {
1039
1044
  isAccessControlPermission: false,
1040
1045
  },
1041
1046
 
1047
+ {
1048
+ permission: Permission.CreateWorkspaceNotificationRule,
1049
+ title: "Create Workspace Notification Rule",
1050
+ description: "This permission can create alert states this project.",
1051
+ isAssignableToTenant: true,
1052
+ isAccessControlPermission: false,
1053
+ },
1054
+ {
1055
+ permission: Permission.DeleteWorkspaceNotificationRule,
1056
+ title: "Delete Workspace Notification Rule",
1057
+ description: "This permission can delete alert states of this project.",
1058
+ isAssignableToTenant: true,
1059
+ isAccessControlPermission: false,
1060
+ },
1061
+ {
1062
+ permission: Permission.EditWorkspaceNotificationRule,
1063
+ title: "Edit Workspace Notification Rule",
1064
+ description: "This permission can edit alert states of this project.",
1065
+ isAssignableToTenant: true,
1066
+ isAccessControlPermission: false,
1067
+ },
1068
+ {
1069
+ permission: Permission.ReadWorkspaceNotificationRule,
1070
+ title: "Read Workspace Notification Rule",
1071
+ description: "This permission can read alert states of this project.",
1072
+ isAssignableToTenant: true,
1073
+ isAccessControlPermission: false,
1074
+ },
1075
+
1042
1076
  {
1043
1077
  permission: Permission.CreateIncidentStateTimeline,
1044
1078
  title: "Create Incident State Timeline",
@@ -0,0 +1,3 @@
1
+ export default interface BaseNotificationRule {
2
+ _type: string;
3
+ }
@@ -0,0 +1,8 @@
1
+ enum NotificationRuleEventType {
2
+ Incident = "Incident",
3
+ MonitorStatus = "Monitor Status",
4
+ Alert = "Alert",
5
+ ScheduledMaintenance = "Scheduled Maintenance",
6
+ }
7
+
8
+ export default NotificationRuleEventType;
@@ -0,0 +1,355 @@
1
+ import AlertSeverity from "../../../Models/DatabaseModels/AlertSeverity";
2
+ import AlertState from "../../../Models/DatabaseModels/AlertState";
3
+ import IncidentSeverity from "../../../Models/DatabaseModels/IncidentSeverity";
4
+ import IncidentState from "../../../Models/DatabaseModels/IncidentState";
5
+ import Label from "../../../Models/DatabaseModels/Label";
6
+ import Monitor from "../../../Models/DatabaseModels/Monitor";
7
+ import MonitorStatus from "../../../Models/DatabaseModels/MonitorStatus";
8
+ import ScheduledMaintenanceState from "../../../Models/DatabaseModels/ScheduledMaintenanceState";
9
+ import { DropdownOption } from "../../../UI/Components/Dropdown/Dropdown";
10
+ import ObjectID from "../../ObjectID";
11
+ import WorkspaceType from "../WorkspaceType";
12
+ import NotificationRuleEventType from "./EventType";
13
+ import SlackNotificationRule from "./SlackNotificationRule";
14
+
15
+ export enum NotificationRuleConditionCheckOn {
16
+ MonitorName = "Monitor Name",
17
+ IncidentName = "Incident Name",
18
+ IncidentDescription = "Incident Description",
19
+ IncidentSeverity = "Incident Severity",
20
+ IncidentState = "Incident State",
21
+ MonitorType = "Monitor Type",
22
+ MonitorStatus = "Monitor Status",
23
+ AlertName = "Alert Name",
24
+ AlertDescription = "Alert Description",
25
+ AlertSeverity = "Alert Severity",
26
+ AlertState = "Alert State",
27
+ ScheduledMaintenanceName = "Scheduled Maintenance Name",
28
+ ScheduledMaintenanceDescription = "Scheduled Maintenance Description",
29
+ ScheduledMaintenanceState = "Scheduled Maintenance State",
30
+ IncidentLabels = "Incident Labels",
31
+ AlertLabels = "Alert Labels",
32
+ MonitorLabels = "Monitor Labels",
33
+ ScheduledMaintenanceLabels = "Scheduled Maintenance Labels",
34
+ Monitors = "Monitors", // like monitor contains in the incident or scheduled event.
35
+ }
36
+
37
+ export enum ConditionType {
38
+ EqualTo = "Equal To",
39
+ NotEqualTo = "Not Equal To",
40
+ GreaterThan = "Greater Than",
41
+ LessThan = "Less Than",
42
+ GreaterThanOrEqualTo = "Greater Than Or Equal To",
43
+ LessThanOrEqualTo = "Less Than Or Equal To",
44
+ Contains = "Contains",
45
+ NotContains = "Not Contains",
46
+ StartsWith = "Starts With",
47
+ EndsWith = "Ends With",
48
+ IsEmpty = "Is Empty",
49
+ IsNotEmpty = "Is Not Empty",
50
+ True = "True",
51
+ False = "False",
52
+
53
+ // could be used for labels.
54
+ ContainsAll = "Contains All",
55
+ }
56
+
57
+ export default interface NotificationRuleCondition {
58
+ checkOn: NotificationRuleConditionCheckOn;
59
+ conditionType: ConditionType | undefined;
60
+ value:
61
+ | string
62
+ | number
63
+ | boolean
64
+ | Array<string>
65
+ | Array<ObjectID>
66
+ | undefined;
67
+ }
68
+
69
+ export class NotificationRuleConditionUtil {
70
+ public static getValidationError(data: {
71
+ notificationRule: SlackNotificationRule;
72
+ eventType: NotificationRuleEventType;
73
+ workspaceType: WorkspaceType;
74
+ }): string | null {
75
+ const { notificationRule, eventType, workspaceType } = data;
76
+
77
+ for (const condition of notificationRule.filters) {
78
+ if (!condition.checkOn) {
79
+ return "Check On is required";
80
+ }
81
+
82
+ if (!condition.conditionType) {
83
+ return `Filter Condition is required for ${condition.checkOn}`;
84
+ }
85
+
86
+ if (!condition.value) {
87
+ return `Value is required for ${condition.checkOn}`;
88
+ }
89
+
90
+ if (Array.isArray(condition.value) && condition.value.length === 0) {
91
+ return `Value is required for ${condition.checkOn}`;
92
+ }
93
+ }
94
+
95
+ if (eventType === NotificationRuleEventType.Incident) {
96
+ // either create slack channel or select existing one should be active.
97
+
98
+ if (workspaceType === WorkspaceType.Slack) {
99
+ if (
100
+ !notificationRule.shouldCreateSlackChannel &&
101
+ !notificationRule.shouldPostToExistingSlackChannel
102
+ ) {
103
+ return "Please select either create slack channel or post to existing slack channel";
104
+ }
105
+
106
+ if (notificationRule.shouldPostToExistingSlackChannel) {
107
+ if (!notificationRule.existingSlackChannelName?.trim()) {
108
+ return "Existing Slack channel name is required";
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ return null;
115
+ }
116
+
117
+ public static hasValueField(data: {
118
+ checkOn: NotificationRuleConditionCheckOn;
119
+ conditionType: ConditionType | undefined;
120
+ }): boolean {
121
+ switch (data.conditionType) {
122
+ case ConditionType.IsEmpty:
123
+ case ConditionType.IsNotEmpty:
124
+ case ConditionType.True:
125
+ case ConditionType.False:
126
+ return false;
127
+ default:
128
+ return true;
129
+ }
130
+ }
131
+
132
+ public static isDropdownValueField(data: {
133
+ checkOn: NotificationRuleConditionCheckOn | undefined;
134
+ conditionType: ConditionType | undefined;
135
+ }): boolean {
136
+ // incident state, alert state, monitor status, scheduled maintenance state, severit, labels, monitors are all dropdowns.
137
+
138
+ if (!data.checkOn || !data.conditionType) {
139
+ return false;
140
+ }
141
+
142
+ switch (data.checkOn) {
143
+ case NotificationRuleConditionCheckOn.MonitorType:
144
+ case NotificationRuleConditionCheckOn.IncidentState:
145
+ case NotificationRuleConditionCheckOn.AlertState:
146
+ case NotificationRuleConditionCheckOn.MonitorStatus:
147
+ case NotificationRuleConditionCheckOn.ScheduledMaintenanceState:
148
+ case NotificationRuleConditionCheckOn.IncidentSeverity:
149
+ case NotificationRuleConditionCheckOn.AlertSeverity:
150
+ case NotificationRuleConditionCheckOn.MonitorLabels:
151
+ case NotificationRuleConditionCheckOn.IncidentLabels:
152
+ case NotificationRuleConditionCheckOn.AlertLabels:
153
+ case NotificationRuleConditionCheckOn.ScheduledMaintenanceLabels:
154
+ case NotificationRuleConditionCheckOn.Monitors:
155
+ return true;
156
+ default:
157
+ return false;
158
+ }
159
+ }
160
+
161
+ public static getDropdownOptionsByCheckOn(data: {
162
+ alertSeverities: Array<AlertSeverity>;
163
+ alertStates: Array<AlertState>;
164
+ incidentSeverities: Array<IncidentSeverity>;
165
+ monitorStatus: Array<MonitorStatus>;
166
+ incidentStates: Array<IncidentState>;
167
+ scheduledMaintenanceStates: Array<ScheduledMaintenanceState>;
168
+ labels: Array<Label>;
169
+ monitors: Array<Monitor>;
170
+ checkOn: NotificationRuleConditionCheckOn;
171
+ }): Array<DropdownOption> {
172
+ if (data.checkOn === NotificationRuleConditionCheckOn.AlertSeverity) {
173
+ return data.alertSeverities.map((severity: AlertSeverity) => {
174
+ return {
175
+ value: severity.id!.toString(),
176
+ label: severity.name || "",
177
+ };
178
+ });
179
+ }
180
+
181
+ if (data.checkOn === NotificationRuleConditionCheckOn.IncidentSeverity) {
182
+ return data.incidentSeverities.map((severity: IncidentSeverity) => {
183
+ return {
184
+ value: severity.id!.toString(),
185
+ label: severity.name || "",
186
+ };
187
+ });
188
+ }
189
+
190
+ if (data.checkOn === NotificationRuleConditionCheckOn.MonitorStatus) {
191
+ return data.monitorStatus.map((status: MonitorStatus) => {
192
+ return {
193
+ value: status.id!.toString(),
194
+ label: status.name || "",
195
+ };
196
+ });
197
+ }
198
+
199
+ if (data.checkOn === NotificationRuleConditionCheckOn.IncidentState) {
200
+ return data.incidentStates.map((state: IncidentState) => {
201
+ return {
202
+ value: state.id!.toString(),
203
+ label: state.name || "",
204
+ };
205
+ });
206
+ }
207
+
208
+ if (
209
+ data.checkOn ===
210
+ NotificationRuleConditionCheckOn.ScheduledMaintenanceState
211
+ ) {
212
+ return data.scheduledMaintenanceStates.map(
213
+ (state: ScheduledMaintenanceState) => {
214
+ return {
215
+ value: state.id!.toString(),
216
+ label: state.name || "",
217
+ };
218
+ },
219
+ );
220
+ }
221
+
222
+ if (
223
+ data.checkOn === NotificationRuleConditionCheckOn.MonitorLabels ||
224
+ data.checkOn === NotificationRuleConditionCheckOn.IncidentLabels ||
225
+ data.checkOn === NotificationRuleConditionCheckOn.AlertLabels ||
226
+ data.checkOn ===
227
+ NotificationRuleConditionCheckOn.ScheduledMaintenanceLabels
228
+ ) {
229
+ return data.labels.map((label: Label) => {
230
+ return {
231
+ value: label.id!.toString(),
232
+ label: label.name || "",
233
+ };
234
+ });
235
+ }
236
+
237
+ if (data.checkOn === NotificationRuleConditionCheckOn.Monitors) {
238
+ return data.monitors.map((monitor: Monitor) => {
239
+ return {
240
+ value: monitor.id!.toString(),
241
+ label: monitor.name || "",
242
+ };
243
+ });
244
+ }
245
+
246
+ // alert states
247
+ if (data.checkOn === NotificationRuleConditionCheckOn.AlertState) {
248
+ return data.alertStates.map((state: AlertState) => {
249
+ return {
250
+ value: state.id!.toString(),
251
+ label: state.name || "",
252
+ };
253
+ });
254
+ }
255
+
256
+ return [];
257
+ }
258
+
259
+ public static getCheckOnByEventType(
260
+ eventType: NotificationRuleEventType,
261
+ ): Array<NotificationRuleConditionCheckOn> {
262
+ switch (eventType) {
263
+ case NotificationRuleEventType.Incident:
264
+ return [
265
+ NotificationRuleConditionCheckOn.IncidentName,
266
+ NotificationRuleConditionCheckOn.IncidentDescription,
267
+ NotificationRuleConditionCheckOn.IncidentSeverity,
268
+ NotificationRuleConditionCheckOn.IncidentState,
269
+ NotificationRuleConditionCheckOn.IncidentLabels,
270
+ NotificationRuleConditionCheckOn.MonitorLabels,
271
+ NotificationRuleConditionCheckOn.Monitors,
272
+ ];
273
+ case NotificationRuleEventType.Alert:
274
+ return [
275
+ NotificationRuleConditionCheckOn.AlertName,
276
+ NotificationRuleConditionCheckOn.AlertDescription,
277
+ NotificationRuleConditionCheckOn.AlertSeverity,
278
+ NotificationRuleConditionCheckOn.AlertState,
279
+
280
+ NotificationRuleConditionCheckOn.AlertLabels,
281
+ NotificationRuleConditionCheckOn.MonitorLabels,
282
+
283
+ NotificationRuleConditionCheckOn.Monitors,
284
+ ];
285
+ case NotificationRuleEventType.MonitorStatus:
286
+ return [
287
+ NotificationRuleConditionCheckOn.MonitorName,
288
+ NotificationRuleConditionCheckOn.MonitorStatus,
289
+ NotificationRuleConditionCheckOn.MonitorType,
290
+ NotificationRuleConditionCheckOn.Monitors,
291
+ NotificationRuleConditionCheckOn.MonitorLabels,
292
+ ];
293
+ case NotificationRuleEventType.ScheduledMaintenance:
294
+ return [
295
+ NotificationRuleConditionCheckOn.ScheduledMaintenanceName,
296
+ NotificationRuleConditionCheckOn.ScheduledMaintenanceDescription,
297
+ NotificationRuleConditionCheckOn.ScheduledMaintenanceState,
298
+ NotificationRuleConditionCheckOn.ScheduledMaintenanceLabels,
299
+ NotificationRuleConditionCheckOn.MonitorLabels,
300
+ NotificationRuleConditionCheckOn.Monitors,
301
+ ];
302
+ default:
303
+ return [];
304
+ }
305
+ }
306
+
307
+ public static getConditionTypeByCheckOn(
308
+ checkOn: NotificationRuleConditionCheckOn,
309
+ ): Array<ConditionType> {
310
+ switch (checkOn) {
311
+ case NotificationRuleConditionCheckOn.MonitorName:
312
+ case NotificationRuleConditionCheckOn.IncidentName:
313
+ case NotificationRuleConditionCheckOn.IncidentDescription:
314
+ case NotificationRuleConditionCheckOn.AlertName:
315
+ case NotificationRuleConditionCheckOn.AlertDescription:
316
+ case NotificationRuleConditionCheckOn.ScheduledMaintenanceName:
317
+ case NotificationRuleConditionCheckOn.ScheduledMaintenanceDescription:
318
+ return [
319
+ ConditionType.EqualTo,
320
+ ConditionType.NotEqualTo,
321
+ ConditionType.Contains,
322
+ ConditionType.NotContains,
323
+ ConditionType.StartsWith,
324
+ ConditionType.EndsWith,
325
+ ];
326
+ case NotificationRuleConditionCheckOn.IncidentSeverity:
327
+ case NotificationRuleConditionCheckOn.AlertSeverity:
328
+ return [ConditionType.Contains, ConditionType.NotContains];
329
+ case NotificationRuleConditionCheckOn.IncidentState:
330
+ case NotificationRuleConditionCheckOn.AlertState:
331
+ case NotificationRuleConditionCheckOn.MonitorStatus:
332
+ case NotificationRuleConditionCheckOn.ScheduledMaintenanceState:
333
+ return [ConditionType.Contains, ConditionType.NotContains];
334
+ case NotificationRuleConditionCheckOn.MonitorType:
335
+ return [ConditionType.Contains, ConditionType.NotContains];
336
+ case NotificationRuleConditionCheckOn.AlertLabels:
337
+ case NotificationRuleConditionCheckOn.IncidentLabels:
338
+ case NotificationRuleConditionCheckOn.MonitorLabels:
339
+ case NotificationRuleConditionCheckOn.ScheduledMaintenanceLabels:
340
+ return [
341
+ ConditionType.Contains,
342
+ ConditionType.NotContains,
343
+ ConditionType.ContainsAll,
344
+ ];
345
+ case NotificationRuleConditionCheckOn.Monitors:
346
+ return [
347
+ ConditionType.Contains,
348
+ ConditionType.NotContains,
349
+ ConditionType.ContainsAll,
350
+ ];
351
+ default:
352
+ return [];
353
+ }
354
+ }
355
+ }
@@ -0,0 +1,19 @@
1
+ import FilterCondition from "../../Filter/FilterCondition";
2
+ import ObjectID from "../../ObjectID";
3
+ import BaseNotificationRule from "./BaseNotificationRule";
4
+ import NotificationRuleCondition from "./NotificationRuleCondition";
5
+
6
+ export default interface SlackNotificationRule extends BaseNotificationRule {
7
+ _type: "SlackNotificationRule";
8
+ filterCondition: FilterCondition; // and OR or. Default is AND
9
+ filters: Array<NotificationRuleCondition>; // if this array is empty then it will be considered as all filters are matched.
10
+
11
+ // if filters match then do:
12
+ shouldCreateSlackChannel: boolean;
13
+ inviteTeamsToNewSlackChannel: Array<ObjectID>;
14
+ inviteUsersToNewSlackChannel: Array<ObjectID>;
15
+ shouldAutomaticallyInviteOnCallUsersToNewSlackChannel: boolean;
16
+
17
+ shouldPostToExistingSlackChannel: boolean;
18
+ existingSlackChannelName: string; // seperate by comma
19
+ }
@@ -0,0 +1,3 @@
1
+ export interface WorkspaceNotificationPayload {
2
+ _type: "WorkspaceNotificationPayload";
3
+ }
@@ -0,0 +1,6 @@
1
+ enum WorkspaceType {
2
+ Slack = "Slack",
3
+ MicrosoftTeams = "MicrosoftTeams",
4
+ }
5
+
6
+ export default WorkspaceType;
@@ -620,6 +620,15 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
620
620
 
621
621
  return true;
622
622
  })
623
+ .filter((field: Field<T>) => {
624
+ const currentValues: FormValues<T> =
625
+ refCurrentValue.current;
626
+ if (field.showIf && !field.showIf(currentValues)) {
627
+ return false;
628
+ }
629
+
630
+ return true;
631
+ })
623
632
  .map((field: Field<T>, i: number) => {
624
633
  return (
625
634
  <div key={getFieldName(field)}>
@@ -31,6 +31,9 @@ import { JSONValue } from "Common/Types/JSON";
31
31
  import ObjectID from "Common/Types/ObjectID";
32
32
  import Typeof from "Common/Types/Typeof";
33
33
  import React, { ReactElement, useEffect } from "react";
34
+ import Radio, { RadioValue } from "../../Radio/Radio";
35
+ import { BasicRadioButtonOption } from "../../RadioButtons/BasicRadioButtons";
36
+ import HorizontalRule from "../../HorizontalRule/HorizontalRule";
34
37
 
35
38
  export interface ComponentProps<T extends GenericObject> {
36
39
  field: Field<T>;
@@ -246,6 +249,8 @@ const FormField: <T extends GenericObject>(
246
249
  <div className="sm:col-span-4 mt-0 mb-2" key={props.fieldName}>
247
250
  {/*** Do not display label on checkbox because checkbox can display its own label */}
248
251
 
252
+ {props.field.showHorizontalRuleAbove && <HorizontalRule />}
253
+
249
254
  {props.field.fieldType !== FormFieldSchemaType.Checkbox && (
250
255
  <FieldLabelElement
251
256
  title={props.field.title || ""}
@@ -352,7 +357,8 @@ const FormField: <T extends GenericObject>(
352
357
  />
353
358
  )}
354
359
 
355
- {props.field.fieldType === FormFieldSchemaType.RadioButton && (
360
+ {props.field.fieldType ===
361
+ FormFieldSchemaType.OptionChooserButton && (
356
362
  <RadioButtons
357
363
  error={props.touched && props.error ? props.error : undefined}
358
364
  dataTestId={props.field.dataTestId}
@@ -370,6 +376,33 @@ const FormField: <T extends GenericObject>(
370
376
  />
371
377
  )}
372
378
 
379
+ {props.field.fieldType === FormFieldSchemaType.RadioButton && (
380
+ <Radio
381
+ error={props.touched && props.error ? props.error : undefined}
382
+ dataTestId={props.field.dataTestId}
383
+ onChange={async (value: RadioValue | null) => {
384
+ props.field.onChange && props.field.onChange(value);
385
+ props.setFieldValue(props.fieldName, value);
386
+ }}
387
+ options={
388
+ props.field.radioButtonOptions?.map(
389
+ (option: BasicRadioButtonOption) => {
390
+ return {
391
+ label: option.title,
392
+ value: option.value,
393
+ };
394
+ },
395
+ ) || []
396
+ }
397
+ initialValue={
398
+ props.currentValues &&
399
+ (props.currentValues as any)[props.fieldName]
400
+ ? (props.currentValues as any)[props.fieldName]
401
+ : ""
402
+ }
403
+ />
404
+ )}
405
+
373
406
  {props.field.fieldType === FormFieldSchemaType.LongText && (
374
407
  <TextArea
375
408
  autoFocus={!props.disableAutofocus && index === 1}
@@ -646,6 +679,8 @@ const FormField: <T extends GenericObject>(
646
679
 
647
680
  {showMultiSelectCheckboxCategoryModal &&
648
681
  getMultiSelectCheckboxCategoryModal()}
682
+
683
+ {props.field.showHorizontalRuleBelow && <HorizontalRule />}
649
684
  </div>
650
685
  );
651
686
  };
@@ -53,6 +53,8 @@ export default interface Field<TEntity> {
53
53
  fetchDropdownOptions?:
54
54
  | ((item: FormValues<TEntity>) => Promise<Array<DropdownOption>>)
55
55
  | undefined;
56
+ showHorizontalRuleBelow?: boolean | undefined;
57
+ showHorizontalRuleAbove?: boolean | undefined;
56
58
  dropdownModal?: {
57
59
  type: DatabaseBaseModelType;
58
60
  labelField: string;
@@ -18,9 +18,9 @@ enum FormFieldSchemaType {
18
18
  LongText = "LongText",
19
19
  Color = "Color",
20
20
  Dropdown = "Dropdown",
21
- Radio = "Radio",
22
21
  File = "File",
23
22
  MultiSelectDropdown = "MultiSelectDropdown",
23
+ OptionChooserButton = "OptionChooserButton",
24
24
  Toggle = "Boolean",
25
25
  Port = "Port",
26
26
  EncryptedText = "EncryptedText",
@@ -44,7 +44,7 @@ export default class FormFieldSchemaTypeUtil {
44
44
  return FieldType.Color;
45
45
  case FormFieldSchemaType.Dropdown:
46
46
  return FieldType.Dropdown;
47
- case FormFieldSchemaType.Radio:
47
+ case FormFieldSchemaType.RadioButton:
48
48
  return FieldType.Text;
49
49
  case FormFieldSchemaType.File:
50
50
  return FieldType.File;
@@ -64,7 +64,7 @@ export default class FormFieldSchemaTypeUtil {
64
64
  return FieldType.CSS;
65
65
  case FormFieldSchemaType.HTML:
66
66
  return FieldType.HTML;
67
- case FormFieldSchemaType.RadioButton:
67
+ case FormFieldSchemaType.OptionChooserButton:
68
68
  return FieldType.Element;
69
69
  case FormFieldSchemaType.JSON:
70
70
  return FieldType.JSON;
@@ -1109,11 +1109,24 @@ const Icon: FunctionComponent<ComponentProps> = ({
1109
1109
  );
1110
1110
  } else if (icon === IconProp.Slack) {
1111
1111
  return getSvgWrapper(
1112
- <path
1113
- strokeLinecap="round"
1114
- strokeLinejoin="round"
1115
- d="M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 01-.825-.242m9.345-8.334a2.126 2.126 0 00-.476-.095 48.64 48.64 0 00-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0011.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155"
1116
- />,
1112
+ <>
1113
+ <path
1114
+ d="M9.33315 2C8.22858 2 7.33328 2.89731 7.33328 4.00388C7.33302 4.26677 7.38454 4.52714 7.4849 4.77012C7.58526 5.0131 7.73249 5.23393 7.9182 5.42001C8.1039 5.60609 8.32444 5.75377 8.56722 5.85462C8.80999 5.95546 9.07026 6.0075 9.33315 6.00777H11.3333V4.00388C11.3338 3.47292 11.1233 2.96353 10.7482 2.58774C10.3731 2.21194 9.86411 2.00053 9.33315 2ZM9.33315 7.34369H3.99984C2.89527 7.34369 1.99997 8.241 1.99997 9.34791C1.99997 10.4545 2.89527 11.3518 3.99984 11.3518H9.33348C10.4377 11.3518 11.3333 10.4545 11.3333 9.34791C11.3333 8.241 10.4377 7.34369 9.33315 7.34369Z"
1115
+ strokeLinejoin="round"
1116
+ />
1117
+ <path
1118
+ d="M22 9.34791C22 8.241 21.1043 7.34369 19.9998 7.34369C18.8952 7.34369 17.9999 8.241 17.9999 9.34791V11.3518H19.9998C20.5307 11.3513 21.0397 11.1398 21.4148 10.7641C21.7899 10.3883 22.0004 9.87887 22 9.34791ZM16.6667 9.34791V4.00388C16.6671 3.47292 16.4566 2.96353 16.0815 2.58774C15.7064 2.21194 15.1974 2.00053 14.6665 2C13.5619 2 12.6666 2.89731 12.6666 4.00388V9.34757C12.6666 10.4548 13.5619 11.3521 14.6665 11.3521C15.1974 11.3516 15.7064 11.1402 16.0815 10.7644C16.4566 10.3886 16.6671 9.87887 16.6667 9.34791Z"
1119
+ strokeLinejoin="round"
1120
+ />
1121
+ <path
1122
+ d="M14.6665 22.0395C15.1974 22.039 15.7064 21.8276 16.0815 21.4518C16.4566 21.076 16.6671 20.5666 16.6667 20.0356C16.6671 19.5047 16.4566 18.9953 16.0815 18.6195C15.7064 18.2437 15.1974 18.0323 14.6665 18.0317H12.6666V20.0356C12.6666 21.1422 13.5619 22.0395 14.6665 22.0395ZM14.6665 16.6958H20.0001C21.1043 16.6958 22 15.7985 22 14.6916C22.0004 14.1606 21.7899 13.6512 21.4148 13.2755C21.0397 12.8997 20.5307 12.6882 19.9998 12.6877H14.6665C13.5619 12.6877 12.6666 13.585 12.6666 14.6916C12.6663 14.9545 12.7178 15.2149 12.8182 15.4578C12.9186 15.7008 13.0658 15.9216 13.2515 16.1077C13.4372 16.2938 13.6577 16.4415 13.9005 16.5423C14.1433 16.6432 14.4036 16.6956 14.6665 16.6958Z"
1123
+ strokeLinejoin="round"
1124
+ />
1125
+ <path
1126
+ d="M1.99997 14.6916C1.99971 14.9545 2.05123 15.2149 2.15159 15.4578C2.25194 15.7008 2.39918 15.9216 2.58489 16.1077C2.77059 16.2938 2.99113 16.4415 3.2339 16.5423C3.47668 16.6432 3.73695 16.6952 3.99984 16.6955C4.5308 16.6949 5.0398 16.4835 5.41491 16.1077C5.79001 15.732 6.00048 15.2226 6.00004 14.6916V12.6877H3.99984C2.89527 12.6877 1.99997 13.585 1.99997 14.6916ZM7.33328 14.6916V20.0353C7.33328 21.1422 8.22858 22.0395 9.33315 22.0395C9.86411 22.039 10.3731 21.8276 10.7482 21.4518C11.1233 21.076 11.3338 20.5666 11.3333 20.0356V14.6916C11.3336 14.4287 11.2821 14.1683 11.1817 13.9253C11.0813 13.6823 10.9341 13.4614 10.7483 13.2754C10.5626 13.0893 10.342 12.9416 10.0992 12.8408C9.85636 12.7399 9.59606 12.6879 9.33315 12.6877C8.22858 12.6877 7.33328 13.585 7.33328 14.6916Z"
1127
+ strokeLinejoin="round"
1128
+ />
1129
+ </>,
1117
1130
  );
1118
1131
  } else if (icon === IconProp.Drag) {
1119
1132
  return getSvgWrapper(
@@ -8,37 +8,39 @@ export type RadioValue = DropdownValue;
8
8
 
9
9
  export interface ComponentProps {
10
10
  options: Array<RadioOption>;
11
- initialValue?: undefined | RadioOption;
11
+ initialValue?: undefined | RadioValue;
12
12
  className?: undefined | string;
13
- onChange?:
14
- | undefined
15
- | ((value: RadioValue | Array<RadioValue> | null) => void);
16
- value?: RadioOption | undefined;
13
+ onChange?: undefined | ((value: RadioValue | null) => void);
14
+ value?: RadioValue | undefined;
17
15
  onFocus?: (() => void) | undefined;
18
16
  onBlur?: (() => void) | undefined;
19
17
  tabIndex?: number | undefined;
20
18
  error?: string | undefined;
19
+ dataTestId?: string | undefined;
21
20
  }
22
21
 
23
22
  const Radio: FunctionComponent<ComponentProps> = (
24
23
  props: ComponentProps,
25
24
  ): ReactElement => {
26
- const [value, setValue] = useState<RadioOption | undefined>(
27
- props.initialValue || props.value,
25
+ const [value, setValue] = useState<RadioValue | undefined>(
26
+ props.initialValue || props.value || undefined,
28
27
  );
29
28
 
30
29
  const groupName: string = Text.generateRandomText();
31
30
 
32
31
  return (
33
- <div className={`mt-2 space-y-2 ${props.className}`}>
32
+ <div
33
+ className={`mt-2 space-y-2 ${props.className}`}
34
+ data-testid={props.dataTestId}
35
+ >
34
36
  {props.options.map((option: RadioOption, index: number) => {
35
37
  return (
36
38
  <div key={index} className="flex items-center gap-x-3">
37
39
  <input
38
40
  tabIndex={props.tabIndex}
39
- defaultChecked={value?.value === option.value}
41
+ defaultChecked={value === option.value}
40
42
  onClick={() => {
41
- setValue(option);
43
+ setValue(option.value);
42
44
  props.onChange && props.onChange(option.value);
43
45
  props.onBlur && props.onBlur();
44
46
  props.onFocus && props.onFocus();
package/UI/Config.ts CHANGED
@@ -240,3 +240,6 @@ export const OpenTelemetryExporterOtlpHeaders: Dictionary<string> =
240
240
  getOpenTelemetryExporterOtlpHeaders();
241
241
 
242
242
  export const DisableTelemetry: boolean = env("DISABLE_TELEMETRY") === "true";
243
+
244
+ export const SlackAppClientId: string | null =
245
+ env("SLACK_APP_CLIENT_ID") || null;