Skip to content

Commit 19736c7

Browse files
authored
[frontend] Change default filter mode
1 parent c48898b commit 19736c7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

openbas-front/src/components/common/queryable/filter/FilterChipValues.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ const FilterChipValues: FunctionComponent<Props> = ({
5454
}
5555
}, [filter]);
5656

57-
const or = (
57+
const i18nMode = (mode: Filter['mode']) => (
5858
<div className={classes.mode}>
59-
{t('OR')}
59+
{t(mode === 'and' ? 'AND' : 'OR')}
6060
</div>
6161
);
6262

63-
const toValues = (opts: Option[]) => opts.map((o, idx) => (
63+
const toValues = (opts: Option[], mode: Filter['mode']) => opts.map((o, idx) => (
6464
<Fragment key={o.id}>
65-
{idx > 0 && or}
65+
{idx > 0 && i18nMode(mode)}
6666
<span>
6767
{' '}
6868
{propertySchema?.schema_property_type.includes('instant') || !o.label ? (o.label) : t(o.label)}
@@ -121,7 +121,7 @@ const FilterChipValues: FunctionComponent<Props> = ({
121121
overflow: 'hidden',
122122
}}
123123
>
124-
{toValues(options)}
124+
{toValues(options, filter.mode)}
125125
</Box>
126126
</span>
127127
)

openbas-front/src/components/common/queryable/filter/FilterUtils.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import * as R from 'ramda';
33
import { type Filter, type FilterGroup, type PropertySchemaDTO } from '../../../../utils/api-types';
44

55
export const emptyFilterGroup: FilterGroup = {
6-
mode: 'and',
6+
mode: 'or',
77
filters: [],
88
};
99

1010
export const buildEmptyFilter = (key: string, operator: Filter['operator']) => {
1111
return {
1212
key,
13-
mode: 'and' as Filter['mode'],
13+
mode: 'or' as Filter['mode'],
1414
values: [],
1515
operator,
1616
};
@@ -19,7 +19,7 @@ export const buildEmptyFilter = (key: string, operator: Filter['operator']) => {
1919
export const buildFilter = (key: string, values: string[], operator: Filter['operator']) => {
2020
return {
2121
key,
22-
mode: 'and' as Filter['mode'],
22+
mode: 'or' as Filter['mode'],
2323
values,
2424
operator,
2525
};

0 commit comments

Comments
 (0)