diff --git a/.betterer.results b/.betterer.results
index 5c91eb8941a..6fec6826f22 100644
--- a/.betterer.results
+++ b/.betterer.results
@@ -671,10 +671,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
- "packages/grafana-ui/src/components/Table/TableNG/Filter/FilterList.tsx:5381": [
- [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"],
- [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "1"]
- ],
"packages/grafana-ui/src/components/Table/TableNG/Filter/FilterPopup.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
diff --git a/packages/grafana-ui/src/components/Table/TableNG/Filter/FilterList.tsx b/packages/grafana-ui/src/components/Table/TableNG/Filter/FilterList.tsx
index ae3c4014472..2e8302cde92 100644
--- a/packages/grafana-ui/src/components/Table/TableNG/Filter/FilterList.tsx
+++ b/packages/grafana-ui/src/components/Table/TableNG/Filter/FilterList.tsx
@@ -1,44 +1,28 @@
-import { css, cx } from '@emotion/css';
+import { css } from '@emotion/css';
import { useCallback, useMemo } from 'react';
import * as React from 'react';
import { FixedSizeList as List, ListChildComponentProps } from 'react-window';
import { GrafanaTheme2, formattedValueToString, getValueFormat, SelectableValue } from '@grafana/data';
-import { ButtonSelect, Checkbox, FilterInput, Label, Stack } from '../../..';
+import { Checkbox, Label, Stack } from '../../..';
import { useStyles2, useTheme2 } from '../../../../themes';
import { Trans } from '../../../../utils/i18n';
+import { operatorSelectableValues } from './FilterPopup';
+
interface Props {
values: SelectableValue[];
options: SelectableValue[];
onChange: (options: SelectableValue[]) => void;
caseSensitive?: boolean;
- showOperators?: boolean;
searchFilter: string;
- setSearchFilter: (value: string) => void;
operator: SelectableValue;
- setOperator: (item: SelectableValue) => void;
}
const ITEM_HEIGHT = 28;
const MIN_HEIGHT = ITEM_HEIGHT * 5;
-const operatorSelectableValues: { [key: string]: SelectableValue } = {
- Contains: { label: 'Contains', value: 'Contains', description: 'Contains' },
- '=': { label: '=', value: '=', description: 'Equals' },
- '!=': { label: '!=', value: '!=', description: 'Not equals' },
- '>': { label: '>', value: '>', description: 'Greater' },
- '>=': { label: '>=', value: '>=', description: 'Greater or Equal' },
- '<': { label: '<', value: '<', description: 'Less' },
- '<=': { label: '<=', value: '<=', description: 'Less or Equal' },
- Expression: {
- label: 'Expression',
- value: 'Expression',
- description: 'Bool Expression (Char $ represents the column value in the expression, e.g. "$ >= 10 && $ <= 12")',
- },
-};
-const OPERATORS = Object.values(operatorSelectableValues);
export const REGEX_OPERATOR = operatorSelectableValues['Contains'];
const XPR_OPERATOR = operatorSelectableValues['Expression'];
@@ -67,22 +51,12 @@ const comparableValue = (value: string): string | number | Date | boolean => {
return value;
};
-export const FilterList = ({
- options,
- values,
- caseSensitive,
- showOperators,
- onChange,
- searchFilter,
- setSearchFilter,
- operator,
- setOperator,
-}: Props) => {
+export const FilterList = ({ options, values, caseSensitive, onChange, searchFilter, operator }: Props) => {
const regex = useMemo(() => new RegExp(searchFilter, caseSensitive ? undefined : 'i'), [searchFilter, caseSensitive]);
const items = useMemo(
() =>
options.filter((option) => {
- if (!showOperators || !searchFilter || operator.value === REGEX_OPERATOR.value) {
+ if (!searchFilter || operator.value === REGEX_OPERATOR.value) {
if (option.label === undefined) {
return false;
}
@@ -123,7 +97,7 @@ export const FilterList = ({
return false;
}
}),
- [options, regex, showOperators, operator, searchFilter]
+ [options, regex, operator, searchFilter]
);
const selectedItems = useMemo(() => items.filter((item) => values.includes(item)), [items, values]);
@@ -171,20 +145,7 @@ export const FilterList = ({
}, [onChange, values, items, selectedItems]);
return (
-
- {!showOperators && }
- {showOperators && (
-
-
-
-
- )}
+
{items.length > 0 ? (
<>
{ItemRenderer}
-
-
-
-
-
-
+
+
+
>
) : (