@oneuptime/common 7.0.3717 → 7.0.3786
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 +3 -2
- package/Models/DatabaseModels/Incident.ts +3 -2
- package/Models/DatabaseModels/Index.ts +3 -0
- package/Models/DatabaseModels/ProjectUser.ts +335 -0
- package/Models/DatabaseModels/ScheduledMaintenance.ts +3 -2
- package/Server/API/SlackAPI.ts +65 -97
- package/Server/API/UserOnCallLogTimelineAPI.ts +2 -9
- package/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.ts +101 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Middleware/SlackAuthorization.ts +11 -2
- package/Server/Services/AlertFeedService.ts +2 -2
- package/Server/Services/AlertInternalNoteService.ts +2 -2
- package/Server/Services/AlertOwnerTeamService.ts +4 -4
- package/Server/Services/AlertOwnerUserService.ts +3 -3
- package/Server/Services/AlertService.ts +62 -20
- package/Server/Services/AlertStateTimelineService.ts +8 -18
- package/Server/Services/IncidentFeedService.ts +101 -2
- package/Server/Services/IncidentInternalNoteService.ts +47 -4
- package/Server/Services/IncidentOwnerTeamService.ts +57 -4
- package/Server/Services/IncidentOwnerUserService.ts +59 -15
- package/Server/Services/IncidentPublicNoteService.ts +41 -4
- package/Server/Services/IncidentService.ts +279 -193
- package/Server/Services/IncidentStateService.ts +25 -0
- package/Server/Services/IncidentStateTimelineService.ts +37 -19
- package/Server/Services/MonitorStatusTimelineService.ts +7 -17
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +2 -0
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +74 -7
- package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +63 -4
- package/Server/Services/OnCallDutyPolicyService.ts +13 -0
- package/Server/Services/ProjectUserService.ts +130 -0
- package/Server/Services/ScheduledMaintenanceFeedService.ts +2 -2
- package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +12 -10
- package/Server/Services/ScheduledMaintenanceOwnerTeamService.ts +22 -18
- package/Server/Services/ScheduledMaintenanceOwnerUserService.ts +28 -30
- package/Server/Services/ScheduledMaintenancePublicNoteService.ts +12 -10
- package/Server/Services/ScheduledMaintenanceService.ts +16 -10
- package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +1 -1
- package/Server/Services/StatusPageSubscriberService.ts +3 -0
- package/Server/Services/TeamMemberService.ts +20 -0
- package/Server/Services/UserNotificationRuleService.ts +74 -0
- package/Server/Services/UserOnCallLogService.ts +1 -1
- package/Server/Services/UserService.ts +35 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +508 -149
- package/Server/Services/WorkspaceUserAuthTokenService.ts +23 -0
- package/Server/Utils/Express.ts +1 -1
- package/Server/Utils/StartServer.ts +6 -1
- package/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.ts +195 -0
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +20 -0
- package/Server/Utils/Workspace/Slack/Actions/Auth.ts +266 -0
- package/Server/Utils/Workspace/Slack/Actions/Incident.ts +1117 -0
- package/Server/Utils/Workspace/Slack/Messages/Incident.ts +116 -0
- package/Server/Utils/Workspace/Slack/Slack.ts +555 -18
- package/Server/Utils/Workspace/Slack/app-manifest.json +18 -10
- package/Server/Utils/Workspace/Workspace.ts +194 -1
- package/Server/Utils/Workspace/WorkspaceBase.ts +145 -19
- package/Server/Utils/Workspace/WorkspaceMessages/Incident.ts +68 -0
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +2 -1
- package/Types/Workspace/NotificationRules/NotificationRuleUtil.ts +251 -121
- package/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.ts +6 -0
- package/Types/Workspace/WorkspaceMessagePayload.ts +71 -2
- package/UI/Components/ComingSoon/ComingSoon.tsx +13 -3
- package/UI/Components/Forms/Fields/FormField.tsx +2 -2
- package/UI/Components/Icon/Icon.tsx +39 -2
- package/UI/Components/ModelTable/BaseModelTable.tsx +16 -0
- package/UI/Components/Radio/Radio.tsx +11 -2
- package/UI/Components/Table/TableCard.tsx +2 -2
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProjectUser.js +340 -0
- package/build/dist/Models/DatabaseModels/ProjectUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Server/API/SlackAPI.js +39 -79
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.js +42 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-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 +8 -2
- package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
- package/build/dist/Server/Services/AlertFeedService.js +2 -2
- package/build/dist/Server/Services/AlertFeedService.js.map +1 -1
- package/build/dist/Server/Services/AlertInternalNoteService.js +2 -2
- package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerTeamService.js +4 -4
- package/build/dist/Server/Services/AlertOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerUserService.js +3 -3
- package/build/dist/Server/Services/AlertOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +44 -19
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/AlertStateTimelineService.js +6 -16
- package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentFeedService.js +62 -2
- package/build/dist/Server/Services/IncidentFeedService.js.map +1 -1
- package/build/dist/Server/Services/IncidentInternalNoteService.js +35 -4
- package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentOwnerTeamService.js +42 -4
- package/build/dist/Server/Services/IncidentOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/IncidentOwnerUserService.js +43 -15
- package/build/dist/Server/Services/IncidentOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js +32 -4
- package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +221 -170
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateService.js +14 -0
- package/build/dist/Server/Services/IncidentStateService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +31 -17
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/MonitorStatusTimelineService.js +5 -15
- package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +1 -0
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +62 -7
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +51 -5
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyService.js +6 -0
- package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
- package/build/dist/Server/Services/ProjectUserService.js +106 -0
- package/build/dist/Server/Services/ProjectUserService.js.map +1 -0
- package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js +2 -2
- package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +2 -2
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js +4 -4
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js +8 -16
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +2 -2
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +5 -2
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberService.js +3 -0
- package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +17 -0
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +52 -0
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +23 -0
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +306 -84
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +18 -0
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +4 -0
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js +148 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +19 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js +167 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +727 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js +82 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +397 -14
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +18 -10
- package/build/dist/Server/Utils/Workspace/Workspace.js +126 -0
- package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/WorkspaceBase.js +69 -11
- package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Incident.js +47 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Incident.js.map +1 -0
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +2 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js +214 -120
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.js.map +1 -0
- package/build/dist/UI/Components/ComingSoon/ComingSoon.js +3 -2
- package/build/dist/UI/Components/ComingSoon/ComingSoon.js.map +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js +2 -2
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +19 -2
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +11 -0
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/Radio/Radio.js +5 -2
- package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
- package/build/dist/UI/Components/Table/TableCard.js +2 -2
- package/build/dist/UI/Components/Table/TableCard.js.map +1 -1
- package/package.json +3 -2
- package/Server/Utils/Workspace/Slack/app-manifest.example.json +0 -198
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logger from "../../../Server/Utils/Logger";
|
|
1
2
|
import FilterCondition from "../../Filter/FilterCondition";
|
|
2
3
|
import {
|
|
3
4
|
ConditionType,
|
|
@@ -17,20 +18,37 @@ export class WorkspaceNotificationRuleUtil {
|
|
|
17
18
|
}): boolean {
|
|
18
19
|
const notificationRule: IncidentNotificationRule = data.notificationRule;
|
|
19
20
|
|
|
21
|
+
logger.debug("Checking if rule matches for notificationRule:");
|
|
22
|
+
logger.debug(notificationRule);
|
|
23
|
+
|
|
20
24
|
// no filters means all filters are matched
|
|
21
25
|
if (data.notificationRule.filters.length === 0) {
|
|
26
|
+
logger.debug("No filters found. Rule matches by default.");
|
|
22
27
|
return true;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
const filterCondition: FilterCondition = notificationRule.filterCondition;
|
|
26
31
|
|
|
32
|
+
logger.debug("Filter condition:");
|
|
33
|
+
logger.debug(filterCondition);
|
|
34
|
+
|
|
27
35
|
for (const filter of notificationRule.filters) {
|
|
28
36
|
const value: string | Array<string> | undefined =
|
|
29
37
|
data.values[filter.checkOn];
|
|
30
38
|
const condition: ConditionType | undefined = filter.conditionType;
|
|
31
39
|
const filterValue: string | Array<string> | undefined = filter.value;
|
|
32
40
|
|
|
41
|
+
logger.debug("Evaluating filter:");
|
|
42
|
+
logger.debug(filter);
|
|
43
|
+
logger.debug("Value:");
|
|
44
|
+
logger.debug(value);
|
|
45
|
+
logger.debug("Condition:");
|
|
46
|
+
logger.debug(condition);
|
|
47
|
+
logger.debug("Filter value:");
|
|
48
|
+
logger.debug(filterValue);
|
|
49
|
+
|
|
33
50
|
if (!condition) {
|
|
51
|
+
logger.debug("No condition found for filter. Skipping.");
|
|
34
52
|
continue;
|
|
35
53
|
}
|
|
36
54
|
|
|
@@ -40,27 +58,39 @@ export class WorkspaceNotificationRuleUtil {
|
|
|
40
58
|
filterValue,
|
|
41
59
|
});
|
|
42
60
|
|
|
61
|
+
logger.debug("Filter match result:");
|
|
62
|
+
logger.debug(isMatched);
|
|
63
|
+
|
|
43
64
|
if (filterCondition === FilterCondition.All) {
|
|
44
65
|
if (!isMatched) {
|
|
66
|
+
logger.debug(
|
|
67
|
+
"Filter condition is 'All' and a filter did not match. Rule does not match.",
|
|
68
|
+
);
|
|
45
69
|
return false;
|
|
46
70
|
}
|
|
47
71
|
}
|
|
48
72
|
|
|
49
73
|
if (filterCondition === FilterCondition.Any) {
|
|
50
74
|
if (isMatched) {
|
|
75
|
+
logger.debug(
|
|
76
|
+
"Filter condition is 'Any' and a filter matched. Rule matches.",
|
|
77
|
+
);
|
|
51
78
|
return true;
|
|
52
79
|
}
|
|
53
80
|
}
|
|
54
81
|
}
|
|
55
82
|
|
|
56
83
|
if (filterCondition === FilterCondition.All) {
|
|
84
|
+
logger.debug("All filters matched. Rule matches.");
|
|
57
85
|
return true;
|
|
58
86
|
}
|
|
59
87
|
|
|
60
88
|
if (filterCondition === FilterCondition.Any) {
|
|
89
|
+
logger.debug("No filters matched. Rule does not match.");
|
|
61
90
|
return false;
|
|
62
91
|
}
|
|
63
92
|
|
|
93
|
+
logger.debug("No valid filter condition found. Rule does not match.");
|
|
64
94
|
return false;
|
|
65
95
|
}
|
|
66
96
|
|
|
@@ -73,187 +103,287 @@ export class WorkspaceNotificationRuleUtil {
|
|
|
73
103
|
const condition: ConditionType = data.condition;
|
|
74
104
|
const filterValue: string | Array<string> | undefined = data.filterValue;
|
|
75
105
|
|
|
106
|
+
logger.debug("Checking condition match:");
|
|
107
|
+
logger.debug("Value:");
|
|
108
|
+
logger.debug(value);
|
|
109
|
+
logger.debug("Condition:");
|
|
110
|
+
logger.debug(condition);
|
|
111
|
+
logger.debug("Filter value:");
|
|
112
|
+
logger.debug(filterValue);
|
|
113
|
+
|
|
76
114
|
if (value === undefined || filterValue === undefined) {
|
|
115
|
+
logger.debug(
|
|
116
|
+
"Value or filter value is undefined. Condition does not match.",
|
|
117
|
+
);
|
|
77
118
|
return false;
|
|
78
119
|
}
|
|
79
120
|
|
|
80
121
|
switch (condition) {
|
|
81
122
|
case ConditionType.EqualTo: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
123
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
124
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
125
|
+
? filterValue
|
|
126
|
+
: [filterValue];
|
|
127
|
+
|
|
128
|
+
const result: boolean = values.every((val: string) => {
|
|
129
|
+
return filterValues.every((fVal: string) => {
|
|
130
|
+
// if val and fVal can be converted to numbers, compare them as numbers
|
|
131
|
+
if (!isNaN(Number(val)) && !isNaN(Number(fVal))) {
|
|
132
|
+
return Number(val) === Number(fVal);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return val === fVal;
|
|
85
136
|
});
|
|
86
|
-
}
|
|
87
|
-
|
|
137
|
+
});
|
|
138
|
+
logger.debug("EqualTo condition result:");
|
|
139
|
+
logger.debug(result);
|
|
140
|
+
return result;
|
|
88
141
|
}
|
|
89
142
|
|
|
90
143
|
case ConditionType.NotEqualTo: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
144
|
+
const result: boolean =
|
|
145
|
+
Array.isArray(value) && Array.isArray(filterValue)
|
|
146
|
+
? !value.every((val: string) => {
|
|
147
|
+
return filterValue.includes(val);
|
|
148
|
+
})
|
|
149
|
+
: value !== filterValue;
|
|
150
|
+
logger.debug("NotEqualTo condition result:");
|
|
151
|
+
logger.debug(result);
|
|
152
|
+
return result;
|
|
97
153
|
}
|
|
98
154
|
|
|
99
155
|
case ConditionType.GreaterThan: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
156
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
157
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
158
|
+
? filterValue
|
|
159
|
+
: [filterValue];
|
|
160
|
+
|
|
161
|
+
const result: boolean = values.every((val: string) => {
|
|
162
|
+
return filterValues.every((fVal: string) => {
|
|
163
|
+
// if val and fVal can be converted to numbers, compare them as numbers
|
|
164
|
+
if (!isNaN(Number(val)) && !isNaN(Number(fVal))) {
|
|
165
|
+
return Number(val) > Number(fVal);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return val > fVal;
|
|
105
169
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return
|
|
170
|
+
});
|
|
171
|
+
logger.debug("GreaterThan condition result:");
|
|
172
|
+
logger.debug(result);
|
|
173
|
+
return result;
|
|
110
174
|
}
|
|
111
175
|
|
|
112
176
|
case ConditionType.LessThan: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
177
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
178
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
179
|
+
? filterValue
|
|
180
|
+
: [filterValue];
|
|
181
|
+
|
|
182
|
+
const result: boolean = values.every((val: string) => {
|
|
183
|
+
return filterValues.every((fVal: string) => {
|
|
184
|
+
// if val and fVal can be converted to numbers, compare them as numbers
|
|
185
|
+
if (!isNaN(Number(val)) && !isNaN(Number(fVal))) {
|
|
186
|
+
return Number(val) < Number(fVal);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return val < fVal;
|
|
118
190
|
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return
|
|
191
|
+
});
|
|
192
|
+
logger.debug("LessThan condition result:");
|
|
193
|
+
logger.debug(result);
|
|
194
|
+
return result;
|
|
123
195
|
}
|
|
124
196
|
|
|
125
197
|
case ConditionType.GreaterThanOrEqualTo: {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
198
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
199
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
200
|
+
? filterValue
|
|
201
|
+
: [filterValue];
|
|
202
|
+
|
|
203
|
+
const result: boolean = values.every((val: string) => {
|
|
204
|
+
return filterValues.every((fVal: string) => {
|
|
205
|
+
// if val and fVal can be converted to numbers, compare them as numbers
|
|
206
|
+
if (!isNaN(Number(val)) && !isNaN(Number(fVal))) {
|
|
207
|
+
return Number(val) >= Number(fVal);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return val >= fVal;
|
|
131
211
|
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return
|
|
212
|
+
});
|
|
213
|
+
logger.debug("GreaterThanOrEqualTo condition result:");
|
|
214
|
+
logger.debug(result);
|
|
215
|
+
return result;
|
|
136
216
|
}
|
|
137
217
|
|
|
138
218
|
case ConditionType.LessThanOrEqualTo: {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
219
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
220
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
221
|
+
? filterValue
|
|
222
|
+
: [filterValue];
|
|
223
|
+
|
|
224
|
+
const result: boolean = values.every((val: string) => {
|
|
225
|
+
return filterValues.every((fVal: string) => {
|
|
226
|
+
// if val and fVal can be converted to numbers, compare them as numbers
|
|
227
|
+
if (!isNaN(Number(val)) && !isNaN(Number(fVal))) {
|
|
228
|
+
return Number(val) <= Number(fVal);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return val <= fVal;
|
|
144
232
|
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
logger.debug("LessThanOrEqualTo condition result:");
|
|
236
|
+
logger.debug(result);
|
|
237
|
+
return result;
|
|
149
238
|
}
|
|
150
239
|
|
|
151
|
-
case ConditionType.ContainsAny:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
filterValue
|
|
159
|
-
|
|
160
|
-
)
|
|
161
|
-
|
|
240
|
+
case ConditionType.ContainsAny:
|
|
241
|
+
case ConditionType.Contains: {
|
|
242
|
+
const result: boolean = false;
|
|
243
|
+
|
|
244
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
245
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
246
|
+
? filterValue
|
|
247
|
+
: [filterValue];
|
|
248
|
+
|
|
249
|
+
logger.debug("Values:");
|
|
250
|
+
logger.debug(values);
|
|
251
|
+
logger.debug("Filter values:");
|
|
252
|
+
logger.debug(filterValues);
|
|
253
|
+
|
|
254
|
+
for (const val of values) {
|
|
255
|
+
for (const fVal of filterValues) {
|
|
256
|
+
if (val.includes(fVal)) {
|
|
257
|
+
logger.debug("ContainsAny condition result:");
|
|
258
|
+
logger.debug(true);
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
162
262
|
}
|
|
163
|
-
|
|
263
|
+
|
|
264
|
+
logger.debug("ContainsAny condition result:");
|
|
265
|
+
logger.debug(result);
|
|
266
|
+
return result;
|
|
164
267
|
}
|
|
165
268
|
|
|
166
269
|
case ConditionType.NotContains: {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
270
|
+
const result: boolean = true;
|
|
271
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
272
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
273
|
+
? filterValue
|
|
274
|
+
: [filterValue];
|
|
275
|
+
|
|
276
|
+
for (const val of values) {
|
|
277
|
+
for (const fVal of filterValues) {
|
|
278
|
+
if (val.includes(fVal)) {
|
|
279
|
+
logger.debug("NotContains condition result:");
|
|
280
|
+
logger.debug(false);
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
177
284
|
}
|
|
178
|
-
|
|
285
|
+
|
|
286
|
+
logger.debug("NotContains condition result:");
|
|
287
|
+
logger.debug(result);
|
|
288
|
+
return result;
|
|
179
289
|
}
|
|
180
290
|
|
|
181
291
|
case ConditionType.StartsWith: {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
292
|
+
const result: boolean = false;
|
|
293
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
294
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
295
|
+
? filterValue
|
|
296
|
+
: [filterValue];
|
|
297
|
+
|
|
298
|
+
for (const val of values) {
|
|
299
|
+
for (const fVal of filterValues) {
|
|
300
|
+
if (val.startsWith(fVal)) {
|
|
301
|
+
logger.debug("StartsWith condition result:");
|
|
302
|
+
logger.debug(true);
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
194
306
|
}
|
|
195
|
-
|
|
307
|
+
|
|
308
|
+
logger.debug("StartsWith condition result:");
|
|
309
|
+
logger.debug(result);
|
|
310
|
+
|
|
311
|
+
return result;
|
|
196
312
|
}
|
|
197
313
|
|
|
198
314
|
case ConditionType.EndsWith: {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
315
|
+
const result: boolean = false;
|
|
316
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
317
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
318
|
+
? filterValue
|
|
319
|
+
: [filterValue];
|
|
320
|
+
|
|
321
|
+
for (const val of values) {
|
|
322
|
+
for (const fVal of filterValues) {
|
|
323
|
+
if (val.endsWith(fVal)) {
|
|
324
|
+
logger.debug("StartsWith condition result:");
|
|
325
|
+
logger.debug(true);
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
211
329
|
}
|
|
212
|
-
|
|
330
|
+
|
|
331
|
+
logger.debug("StartsWith condition result:");
|
|
332
|
+
logger.debug(result);
|
|
333
|
+
|
|
334
|
+
return result;
|
|
213
335
|
}
|
|
214
336
|
|
|
215
337
|
case ConditionType.IsEmpty: {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
338
|
+
const result: boolean = Array.isArray(value)
|
|
339
|
+
? value.length === 0
|
|
340
|
+
: value === "";
|
|
341
|
+
logger.debug("IsEmpty condition result:");
|
|
342
|
+
logger.debug(result);
|
|
343
|
+
return result;
|
|
220
344
|
}
|
|
221
345
|
|
|
222
346
|
case ConditionType.IsNotEmpty: {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
347
|
+
const result: boolean = Array.isArray(value)
|
|
348
|
+
? value.length > 0
|
|
349
|
+
: value !== "";
|
|
350
|
+
logger.debug("IsNotEmpty condition result:");
|
|
351
|
+
logger.debug(result);
|
|
352
|
+
return result;
|
|
227
353
|
}
|
|
228
354
|
|
|
229
355
|
case ConditionType.True: {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
return value === "true";
|
|
356
|
+
const result: boolean = value === "true";
|
|
357
|
+
logger.debug("True condition result:");
|
|
358
|
+
logger.debug(result);
|
|
359
|
+
return result;
|
|
236
360
|
}
|
|
237
361
|
|
|
238
362
|
case ConditionType.False: {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
return value === "false";
|
|
363
|
+
const result: boolean = value === "false";
|
|
364
|
+
logger.debug("False condition result:");
|
|
365
|
+
logger.debug(result);
|
|
366
|
+
return result;
|
|
245
367
|
}
|
|
246
368
|
|
|
247
369
|
case ConditionType.ContainsAll: {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
370
|
+
const values: string[] = Array.isArray(value) ? value : [value];
|
|
371
|
+
const filterValues: string[] = Array.isArray(filterValue)
|
|
372
|
+
? filterValue
|
|
373
|
+
: [filterValue];
|
|
374
|
+
|
|
375
|
+
const result: boolean = filterValues.every((fVal: string) => {
|
|
376
|
+
return values.some((val: string) => {
|
|
377
|
+
return val.includes(fVal);
|
|
251
378
|
});
|
|
252
|
-
}
|
|
253
|
-
|
|
379
|
+
});
|
|
380
|
+
logger.debug("ContainsAll condition result:");
|
|
381
|
+
logger.debug(result);
|
|
382
|
+
return result;
|
|
254
383
|
}
|
|
255
384
|
|
|
256
385
|
default: {
|
|
386
|
+
logger.debug("Unknown condition type. Condition does not match.");
|
|
257
387
|
return false;
|
|
258
388
|
}
|
|
259
389
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { DropdownOption } from "../../UI/Components/Dropdown/Dropdown";
|
|
2
|
+
import URL from "../API/URL";
|
|
3
|
+
import WorkspaceType from "./WorkspaceType";
|
|
4
|
+
|
|
1
5
|
export interface WorkspaceMessageBlock {
|
|
2
6
|
_type: string;
|
|
3
|
-
onlyPostToTheseChannelNames?: Array<string>;
|
|
4
7
|
}
|
|
5
8
|
|
|
6
9
|
export interface WorkspaceMessagePayloadButton {
|
|
10
|
+
_type: "WorkspaceMessagePayloadButton";
|
|
7
11
|
title: string; // Button title.
|
|
8
|
-
|
|
12
|
+
value: string; // Button value.
|
|
13
|
+
actionId: string; // Button action id.
|
|
14
|
+
url?: URL | undefined; // Button url.
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
export interface WorkspacePayloadHeader extends WorkspaceMessageBlock {
|
|
@@ -13,11 +19,72 @@ export interface WorkspacePayloadHeader extends WorkspaceMessageBlock {
|
|
|
13
19
|
text: string;
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
export interface WorkspaceTextAreaBlock extends WorkspaceMessageBlock {
|
|
23
|
+
_type: "WorkspaceTextAreaBlock";
|
|
24
|
+
label: string;
|
|
25
|
+
blockId: string;
|
|
26
|
+
placeholder: string;
|
|
27
|
+
initialValue?: string | undefined;
|
|
28
|
+
description?: string | undefined;
|
|
29
|
+
optional?: boolean | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface WorkspaceTextBoxBlock extends WorkspaceMessageBlock {
|
|
33
|
+
_type: "WorkspaceTextBoxBlock";
|
|
34
|
+
label: string;
|
|
35
|
+
blockId: string;
|
|
36
|
+
placeholder: string;
|
|
37
|
+
initialValue?: string | undefined;
|
|
38
|
+
description?: string | undefined;
|
|
39
|
+
optional?: boolean | undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface WorkspacePayloadImage extends WorkspaceMessageBlock {
|
|
43
|
+
_type: "WorkspacePayloadImage";
|
|
44
|
+
imageUrl: URL;
|
|
45
|
+
altText: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface WorkspaceCheckboxBlock extends WorkspaceMessageBlock {
|
|
49
|
+
_type: "WorkspaceCheckboxBlock";
|
|
50
|
+
label: string;
|
|
51
|
+
blockId: string;
|
|
52
|
+
initialValue?: boolean | undefined;
|
|
53
|
+
description?: string | undefined;
|
|
54
|
+
optional?: boolean | undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface WorkspaceDropdownBlock extends WorkspaceMessageBlock {
|
|
58
|
+
_type: "WorkspaceDropdownBlock";
|
|
59
|
+
label: string;
|
|
60
|
+
blockId: string;
|
|
61
|
+
options: Array<DropdownOption>;
|
|
62
|
+
placeholder: string;
|
|
63
|
+
initialValue?: string | undefined;
|
|
64
|
+
description?: string | undefined;
|
|
65
|
+
multiSelect?: boolean | undefined;
|
|
66
|
+
optional?: boolean | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface WorkspaceModalBlock extends WorkspaceMessageBlock {
|
|
70
|
+
_type: "WorkspaceModalBlock";
|
|
71
|
+
title: string;
|
|
72
|
+
actionId: string;
|
|
73
|
+
actionValue: string;
|
|
74
|
+
submitButtonTitle: string;
|
|
75
|
+
cancelButtonTitle: string;
|
|
76
|
+
blocks: Array<WorkspaceMessageBlock>;
|
|
77
|
+
}
|
|
78
|
+
|
|
16
79
|
export interface WorkspacePayloadMarkdown extends WorkspaceMessageBlock {
|
|
17
80
|
_type: "WorkspacePayloadMarkdown";
|
|
18
81
|
text: string;
|
|
19
82
|
}
|
|
20
83
|
|
|
84
|
+
export interface WorkspacePayloadDivider extends WorkspaceMessageBlock {
|
|
85
|
+
_type: "WorkspacePayloadDivider";
|
|
86
|
+
}
|
|
87
|
+
|
|
21
88
|
export interface WorkspacePayloadButtons extends WorkspaceMessageBlock {
|
|
22
89
|
_type: "WorkspacePayloadButtons";
|
|
23
90
|
buttons: Array<WorkspaceMessagePayloadButton>;
|
|
@@ -26,5 +93,7 @@ export interface WorkspacePayloadButtons extends WorkspaceMessageBlock {
|
|
|
26
93
|
export default interface WorkspaceMessagePayload {
|
|
27
94
|
_type: "WorkspaceMessagePayload";
|
|
28
95
|
channelNames: Array<string>; // Channel ids to send message to.
|
|
96
|
+
channelIds: Array<string>; // Channel ids to send message to.
|
|
29
97
|
messageBlocks: Array<WorkspaceMessageBlock>; // Message to add to blocks.
|
|
98
|
+
workspaceType: WorkspaceType;
|
|
30
99
|
}
|
|
@@ -2,13 +2,23 @@ import EmptyState from "../EmptyState/EmptyState";
|
|
|
2
2
|
import IconProp from "Common/Types/Icon/IconProp";
|
|
3
3
|
import React, { FunctionComponent, ReactElement } from "react";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export interface ComponentProps {
|
|
6
|
+
title?: string | undefined;
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const ComingSoon: FunctionComponent<ComponentProps> = (
|
|
11
|
+
props: ComponentProps,
|
|
12
|
+
): ReactElement => {
|
|
6
13
|
return (
|
|
7
14
|
<EmptyState
|
|
8
15
|
id="coming-soon"
|
|
9
16
|
icon={IconProp.CursorArrowRays}
|
|
10
|
-
title="Coming soon!"
|
|
11
|
-
description=
|
|
17
|
+
title={props.title || "Coming soon!"}
|
|
18
|
+
description={
|
|
19
|
+
props.description ||
|
|
20
|
+
"We will be launching this feature very soon. Stay Tuned!"
|
|
21
|
+
}
|
|
12
22
|
/>
|
|
13
23
|
);
|
|
14
24
|
};
|
|
@@ -394,7 +394,7 @@ const FormField: <T extends GenericObject>(
|
|
|
394
394
|
},
|
|
395
395
|
) || []
|
|
396
396
|
}
|
|
397
|
-
|
|
397
|
+
value={
|
|
398
398
|
props.currentValues &&
|
|
399
399
|
(props.currentValues as any)[props.fieldName]
|
|
400
400
|
? (props.currentValues as any)[props.fieldName]
|
|
@@ -584,7 +584,7 @@ const FormField: <T extends GenericObject>(
|
|
|
584
584
|
props.setFieldTouched(props.fieldName, true);
|
|
585
585
|
}}
|
|
586
586
|
dataTestId={props.field.dataTestId}
|
|
587
|
-
|
|
587
|
+
value={booleanValue}
|
|
588
588
|
/>
|
|
589
589
|
)}
|
|
590
590
|
|