Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Query Builder FilterEditor on Alert Rules page #838

Merged
merged 6 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- Fixed `IN` operator escaping the entire string (specifically with `Nullable(String)`), also added `FixedString(N)` (#830)
- Fixed query builder filter editor on alert rules page (#828)

## 4.0.7

Expand Down
22 changes: 22 additions & 0 deletions src/components/queryBuilder/FilterEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,28 @@ describe('FilterEditor', () => {
// type key into the mapKey input
await userEvent.type(result!.getAllByRole('combobox')[1], 'http.status_code');
await userEvent.keyboard('{Enter}');

result.rerender(
<FilterEditor
allColumns={[{ name: 'SpanAttributes', type: 'Map(String, String)', picklistValues: [] }]}
filter={{
key: 'SpanAttributes',
type: 'Map(String, String)',
mapKey: 'http.status_code',
value: '',
operator: FilterOperator.Equals,
condition: 'AND',
filterType: 'custom',
}}
index={0}
onFilterChange={onFilterChange}
removeFilter={() => {}}
datasource={mockDatasource}
database=''
table=''
/>
);

// type value into the input
await userEvent.type(result!.getByTestId('query-builder-filters-single-string-value-input'), '200');
result!.getByTestId('query-builder-filters-single-string-value-input').blur();
Expand Down
6 changes: 3 additions & 3 deletions src/components/queryBuilder/FilterEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ export const FilterEditor = (props: {
onFilterChange(index, newFilter);
};
const onFilterMapKeyChange = (mapKey: string) => {
const newFilter: Filter = filter;
const newFilter: Filter = { ...filter };
newFilter.mapKey = mapKey;
onFilterChange(index, newFilter);
};
const onFilterOperatorChange = (operator: FilterOperator) => {
let newFilter: Filter = filter;
const newFilter: Filter = { ...filter };
newFilter.operator = operator;
if (utils.isMultiFilter(newFilter)) {
if (!Array.isArray(newFilter.value)) {
Expand All @@ -343,7 +343,7 @@ export const FilterEditor = (props: {
onFilterChange(index, newFilter);
};
const onFilterConditionChange = (condition: 'AND' | 'OR') => {
let newFilter: Filter = filter;
const newFilter: Filter = { ...filter };
newFilter.condition = condition;
onFilterChange(index, newFilter);
};
Expand Down
Loading