@oneuptime/common 7.0.3621 → 7.0.3655
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.
- package/Models/DatabaseModels/Alert.ts +48 -0
- package/Models/DatabaseModels/Incident.ts +19 -0
- package/Models/DatabaseModels/Index.ts +10 -0
- package/Models/DatabaseModels/ScheduledMaintenance.ts +48 -0
- package/Models/DatabaseModels/WorkspaceNotificationRule.ts +461 -0
- package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +379 -0
- package/Models/DatabaseModels/WorkspaceSetting.ts +230 -0
- package/Models/DatabaseModels/WorkspaceUserAuthToken.ts +312 -0
- package/Server/API/SlackAPI.ts +368 -0
- package/Server/EnvironmentConfig.ts +10 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.ts +147 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.ts +19 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.ts +23 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739282331053-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Middleware/SlackAuthorization.ts +60 -0
- package/Server/Services/AlertService.ts +38 -2
- package/Server/Services/Index.ts +9 -0
- package/Server/Services/ProjectService.ts +6 -4
- package/Server/Services/ScheduledMaintenanceService.ts +39 -2
- package/Server/Services/TeamMemberService.ts +1 -0
- package/Server/Services/UserService.ts +7 -2
- package/Server/Services/WorkspaceCommunicationTools/Slack.ts +0 -0
- package/Server/Services/WorkspaceCommunicationTools/Teams.ts +0 -0
- package/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.ts +0 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +31 -0
- package/Server/Services/WorkspaceProjectAuthTokenService.ts +84 -0
- package/Server/Services/WorkspaceSettingService.ts +78 -0
- package/Server/Services/WorkspaceUserAuthTokenService.ts +89 -0
- package/Server/Types/Workflow/Components/Slack/SendMessageToChannel.ts +2 -2
- package/Server/Utils/Express.ts +2 -1
- package/Server/Utils/Monitor/MonitorResource.ts +2 -5
- package/Server/Utils/Slack/Slack.ts +271 -0
- package/Server/Utils/Slack/app-manifest-temp.json +198 -0
- package/Server/Utils/Slack/app-manifest.json +67 -0
- package/Server/Utils/StartServer.ts +2 -1
- package/Types/Filter/FilterCondition.ts +2 -2
- package/Types/Monitor/CriteriaFilter.ts +31 -5
- package/Types/Monitor/MonitorCriteriaInstance.ts +40 -10
- package/Types/Monitor/MonitorStep.ts +1 -1
- package/Types/Permission.ts +34 -0
- package/Types/Workspace/NotificationRules/BaseNotificationRule.ts +3 -0
- package/Types/Workspace/NotificationRules/EventType.ts +8 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +355 -0
- package/Types/Workspace/NotificationRules/SlackNotificationRule.ts +19 -0
- package/Types/Workspace/WorkspaceNotificationPayload.ts +29 -0
- package/Types/Workspace/WorkspaceType.ts +6 -0
- package/UI/Components/Forms/BasicForm.tsx +9 -0
- package/UI/Components/Forms/Fields/FormField.tsx +36 -1
- package/UI/Components/Forms/Types/Field.ts +2 -0
- package/UI/Components/Forms/Types/FormFieldSchemaType.ts +1 -1
- package/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.ts +2 -2
- package/UI/Components/Icon/Icon.tsx +18 -5
- package/UI/Components/Radio/Radio.tsx +12 -10
- package/UI/Config.ts +3 -0
- package/build/dist/Models/DatabaseModels/Alert.js +52 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js +21 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +8 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js +52 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationRule.js +481 -0
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js +390 -0
- package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WorkspaceSetting.js +236 -0
- package/build/dist/Models/DatabaseModels/WorkspaceSetting.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WorkspaceUserAuthToken.js +326 -0
- package/build/dist/Models/DatabaseModels/WorkspaceUserAuthToken.js.map +1 -0
- package/build/dist/Server/API/SlackAPI.js +237 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -0
- package/build/dist/Server/EnvironmentConfig.js +5 -1
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.js +58 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739282331053-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739282331053-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/SlackAuthorization.js +28 -0
- package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -0
- package/build/dist/Server/Services/AlertService.js +31 -5
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +8 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +5 -4
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +30 -3
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +1 -0
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +5 -2
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Slack.js +2 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Slack.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Teams.js +2 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Teams.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.js +2 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +22 -0
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +63 -0
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceSettingService.js +59 -0
- package/build/dist/Server/Services/WorkspaceSettingService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +66 -0
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -0
- package/build/dist/Server/Types/Workflow/Components/Slack/SendMessageToChannel.js +2 -2
- package/build/dist/Server/Types/Workflow/Components/Slack/SendMessageToChannel.js.map +1 -1
- package/build/dist/Server/Utils/Express.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +2 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Slack/Slack.js +172 -0
- package/build/dist/Server/Utils/Slack/Slack.js.map +1 -0
- package/build/dist/Server/Utils/Slack/app-manifest.json +67 -0
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Types/Filter/FilterCondition.js +2 -2
- package/build/dist/Types/Filter/FilterCondition.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +19 -5
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +33 -10
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Permission.js +32 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/BaseNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/BaseNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/EventType.js +9 -0
- package/build/dist/Types/Workspace/NotificationRules/EventType.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +275 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js +2 -0
- package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js.map +1 -0
- package/build/dist/Types/Workspace/WorkspaceType.js +7 -0
- package/build/dist/Types/Workspace/WorkspaceType.js.map +1 -0
- package/build/dist/UI/Components/Forms/BasicForm.js +7 -0
- package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js +21 -4
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js +1 -1
- package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js.map +1 -1
- package/build/dist/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.js +2 -2
- package/build/dist/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +5 -1
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Radio/Radio.js +4 -4
- package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
- package/build/dist/UI/Config.js +1 -0
- package/build/dist/UI/Config.js.map +1 -1
- package/package.json +2 -2
- package/Server/Utils/Slack.ts +0 -29
- package/build/dist/Server/Utils/Slack.js +0 -20
- package/build/dist/Server/Utils/Slack.js.map +0 -1
|
@@ -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,29 @@
|
|
|
1
|
+
export interface WorkspacePayloadBlocks {
|
|
2
|
+
_type: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface WorkspaceNotificationPayloadButton {
|
|
6
|
+
title: string; // Button title.
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WorkspacePayloadHeader extends WorkspacePayloadBlocks {
|
|
10
|
+
_type: "WorkspacePayloadHeader";
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface WorkspacePayloadMarkdown extends WorkspacePayloadBlocks {
|
|
15
|
+
_type: "WorkspacePayloadMarkdown";
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface WorkspacePayloadButtons extends WorkspacePayloadBlocks {
|
|
20
|
+
_type: "WorkspacePayloadButtons";
|
|
21
|
+
buttons: Array<WorkspaceNotificationPayloadButton>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default interface WorkspaceNotificationPayload {
|
|
25
|
+
_type: "WorkspaceNotificationPayload";
|
|
26
|
+
channelNames: Array<string>; // which channels to post to.
|
|
27
|
+
blocks: Array<WorkspacePayloadBlocks>; // Buttons to add to the message.
|
|
28
|
+
createChannelsIfItDoesNotExist: boolean; // Should we create the channels if they don't exist.
|
|
29
|
+
}
|
|
@@ -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 ===
|
|
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.
|
|
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.
|
|
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
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
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 |
|
|
11
|
+
initialValue?: undefined | RadioValue;
|
|
12
12
|
className?: undefined | string;
|
|
13
|
-
onChange?:
|
|
14
|
-
|
|
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<
|
|
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
|
|
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
|
|
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;
|