Skip to content

Commit 7061500

Browse files
committed
HARMONY-1998: Allow filtering by message category
1 parent a2e9c73 commit 7061500

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

services/harmony/app/frontends/workflow-ui.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ interface TableQuery {
5353
userValues: string[],
5454
providerValues: string[],
5555
labelValues: string[],
56+
messageCategoryValues: string[],
57+
allowMessageCategoryValues: boolean,
5658
from: Date,
5759
to: Date,
5860
dateKind: 'createdAt' | 'updatedAt',
@@ -85,10 +87,12 @@ function parseQuery( /* eslint-disable @typescript-eslint/no-explicit-any */
8587
userValues: [],
8688
providerValues: [],
8789
labelValues: [],
90+
messageCategoryValues: [],
8891
allowStatuses: true,
8992
allowServices: true,
9093
allowUsers: true,
9194
allowProviders: true,
95+
allowMessageCategoryValues: true,
9296
// date controls
9397
from: undefined,
9498
to: undefined,
@@ -101,6 +105,7 @@ function parseQuery( /* eslint-disable @typescript-eslint/no-explicit-any */
101105
tableQuery.allowServices = !(requestQuery.disallowservice === 'on');
102106
tableQuery.allowUsers = !(requestQuery.disallowuser === 'on');
103107
tableQuery.allowProviders = !(requestQuery.disallowprovider === 'on');
108+
tableQuery.allowMessageCategoryValues = !(requestQuery.disallowmessagecategory === 'on');
104109
const selectedOptions: { field: string, dbValue: string, value: string }[] = JSON.parse(requestQuery.tablefilter);
105110

106111
const validStatusSelections = selectedOptions
@@ -123,19 +128,25 @@ function parseQuery( /* eslint-disable @typescript-eslint/no-explicit-any */
123128
.filter(option => /^provider: [A-Za-z0-9_]{1,100}$/.test(option.value));
124129
const providerValues = validProviderSelections.map(option => option.value.split('provider: ')[1].toLowerCase());
125130

131+
const validMessageCategorySelections = selectedOptions
132+
.filter(option => /^message category: .{1,100}$/.test(option.value));
133+
const messageCategoryValues = validMessageCategorySelections.map(option => option.dbValue || option.value.split('message category: ')[1].toLowerCase());
134+
126135
if ((statusValues.length + serviceValues.length + userValues.length + providerValues.length) > maxFilters) {
127136
throw new RequestValidationError(`Maximum amount of filters (${maxFilters}) was exceeded.`);
128137
}
129138
originalValues = JSON.stringify(validStatusSelections
130139
.concat(validServiceSelections)
131140
.concat(validUserSelections)
132141
.concat(validProviderSelections)
133-
.concat(validLabelSelections));
142+
.concat(validLabelSelections)
143+
.concat(validMessageCategorySelections));
134144
tableQuery.statusValues = statusValues;
135145
tableQuery.serviceValues = serviceValues;
136146
tableQuery.userValues = userValues;
137147
tableQuery.providerValues = providerValues;
138148
tableQuery.labelValues = labelValues;
149+
tableQuery.messageCategoryValues = messageCategoryValues;
139150
}
140151
// everything in the Workflow UI uses the browser timezone, so we need a timezone offset
141152
const offSetMs = parseInt(requestQuery.tzoffsetminutes || 0) * 60 * 1000;
@@ -538,6 +549,12 @@ function tableQueryToWorkItemQuery(tableFilter: TableQuery, jobID: string, id?:
538549
in: tableFilter.allowStatuses,
539550
};
540551
}
552+
if (tableFilter.messageCategoryValues.length) {
553+
itemQuery.whereIn.message_category = {
554+
values: tableFilter.messageCategoryValues,
555+
in: tableFilter.allowMessageCategoryValues,
556+
};
557+
}
541558
if (tableFilter.from || tableFilter.to) {
542559
itemQuery.dates = { field: tableFilter.dateKind };
543560
itemQuery.dates.from = tableFilter.from;

services/harmony/app/models/work-item-interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface WorkItemQuery {
9191
};
9292
whereIn?: {
9393
status?: { in: boolean, values: string[] };
94+
message_category?: { in: boolean, values: string[] };
9495
};
9596
dates?: {
9697
from?: Date;

services/harmony/public/js/workflow-ui/job/work-items-table.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ function initFilter(tableFilter) {
100100
{ value: 'status: warning', dbValue: 'warning', field: 'status' },
101101
];
102102
const allowedValues = allowedList.map((t) => t.value);
103+
allowedList.push({ value: 'message category: no-data', dbValue: 'no-data', field: 'message_category' });
103104
// eslint-disable-next-line no-new
104105
const tagInput = new Tagify(filterInput, {
105106
whitelist: allowedList,
106107
delimiters: null,
107108
validate(tag) {
108-
if (allowedValues.includes(tag.value)) {
109+
if (allowedValues.includes(tag.value)
110+
|| /^message category: .{1,100}$/.test(tag.value)) {
109111
return true;
110112
}
111113
return false;

0 commit comments

Comments
 (0)