Skip to content

Commit

Permalink
Merge pull request #4968 from kyoto/monitoring-alert-list-filter-non-…
Browse files Browse the repository at this point in the history
…fuzzy

Bug 1821990: Monitoring: Change text filter by alert description to not use fuzzy
  • Loading branch information
openshift-merge-robot committed Apr 13, 2020
2 parents 70ae2b7 + b76227d commit 743bafe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/integration-tests/tests/monitoring.scenario.ts
Expand Up @@ -38,7 +38,7 @@ describe('Monitoring: Alerts', () => {

it('filters Alerts by name', async () => {
await monitoringView.wait(until.elementToBeClickable(crudView.nameFilter));
await crudView.nameFilter.sendKeys(`${testAlertName} PagerDuty`);
await crudView.nameFilter.sendKeys(testAlertName);
expect(firstElementByTestID('alert-resource-link').getText()).toContain(testAlertName);
});

Expand Down
14 changes: 11 additions & 3 deletions frontend/public/components/factory/table-filters.ts
Expand Up @@ -32,9 +32,17 @@ export const tableFilters: TableFilterMap = {

'catalog-source-name': (filter, obj) => fuzzyCaseInsensitive(filter, obj.name),

'alert-list-text': (filter, alert) =>
fuzzyCaseInsensitive(filter, alert.labels?.alertname) ||
fuzzyCaseInsensitive(filter, alertDescription(alert)),
'alert-list-text': (filter, alert) => {
if (fuzzyCaseInsensitive(filter, alert.labels?.alertname)) {
return true;
}

// Search in alert description. Ignore case and whitespace, but don't use fuzzy since the
// description can be long and will often match fuzzy searches that are not really relevant.
const needle = _.toLower(filter.replace(/\s/g, ''));
const haystack = _.toLower(alertDescription(alert).replace(/\s/g, ''));
return haystack.includes(needle);
},

'alert-state': (filter, alert) => filter.selected.has(alertState(alert)),

Expand Down

0 comments on commit 743bafe

Please sign in to comment.