diff --git a/public/app/features/explore/AdHocFilter.tsx b/public/app/features/explore/AdHocFilter.tsx deleted file mode 100644 index bec568d580e..00000000000 --- a/public/app/features/explore/AdHocFilter.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import React from 'react'; -import { LegacyForms, useStyles } from '@grafana/ui'; -const { Select } = LegacyForms; -import { css, cx } from '@emotion/css'; -import { GrafanaTheme, SelectableValue } from '@grafana/data'; - -const getStyles = (theme: GrafanaTheme) => ({ - keyValueContainer: css` - label: key-value-container; - display: flex; - flex-flow: row nowrap; - `, -}); - -enum ChangeType { - Key = 'key', - Value = 'value', - Operator = 'operator', -} - -export interface Props { - keys: string[]; - keysPlaceHolder?: string; - initialKey?: string; - initialOperator?: string; - initialValue?: string; - values?: string[]; - valuesPlaceHolder?: string; - onKeyChanged: (key: string) => void; - onValueChanged: (value: string) => void; - onOperatorChanged: (operator: string) => void; -} - -export const AdHocFilter: React.FunctionComponent = (props) => { - const styles = useStyles(getStyles); - - const onChange = (changeType: ChangeType) => (item: SelectableValue) => { - const { onKeyChanged, onValueChanged, onOperatorChanged } = props; - - if (!item.value) { - return; - } - - switch (changeType) { - case ChangeType.Key: - onKeyChanged(item.value); - break; - case ChangeType.Operator: - onOperatorChanged(item.value); - break; - case ChangeType.Value: - onValueChanged(item.value); - break; - } - }; - - const stringToOption = (value: string) => ({ label: value, value: value }); - - const { keys, initialKey, keysPlaceHolder, initialOperator, values, initialValue, valuesPlaceHolder } = props; - const operators = ['=', '!=']; - const keysAsOptions = keys ? keys.map(stringToOption) : []; - const selectedKey = initialKey ? keysAsOptions.filter((option) => option.value === initialKey) : undefined; - const valuesAsOptions = values ? values.map(stringToOption) : []; - const selectedValue = initialValue ? valuesAsOptions.filter((option) => option.value === initialValue) : undefined; - const operatorsAsOptions = operators.map(stringToOption); - const selectedOperator = initialOperator - ? operatorsAsOptions.filter((option) => option.value === initialOperator) - : undefined; - - return ( -
- -