Skip to content

Commit

Permalink
[7.7] [Metrics UI]Fix editing alert filter query
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed May 4, 2020
1 parent 2f74672 commit 5ae7295
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const Expressions: React.FC<Props> = props => {
[setAlertParams, alertParams.criteria]
);

const onFilterQuerySubmit = useCallback(
const onFilterChange = useCallback(
(filter: any) => {
setAlertParams('filterQuery', filter);
},
Expand Down Expand Up @@ -222,8 +222,8 @@ export const Expressions: React.FC<Props> = props => {
}, [alertsContext.metadata, defaultExpression, source]); // eslint-disable-line react-hooks/exhaustive-deps

const handleFieldSearchChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => onFilterQuerySubmit(e.target.value),
[onFilterQuerySubmit]
(e: ChangeEvent<HTMLInputElement>) => onFilterChange(e.target.value),
[onFilterChange]
);

return (
Expand Down Expand Up @@ -293,7 +293,8 @@ export const Expressions: React.FC<Props> = props => {
{(alertsContext.metadata && (
<MetricsExplorerKueryBar
derivedIndexPattern={derivedIndexPattern}
onSubmit={onFilterQuerySubmit}
onChange={onFilterChange}
onSubmit={onFilterChange}
value={alertParams.filterQuery}
/>
)) || (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { esKuery, IIndexPattern } from '../../../../../../src/plugins/data/publi
interface Props {
derivedIndexPattern: IIndexPattern;
onSubmit: (query: string) => void;
onChange?: (query: string) => void;
value?: string | null;
placeholder?: string;
}
Expand All @@ -30,6 +31,7 @@ function validateQuery(query: string) {
export const MetricsExplorerKueryBar = ({
derivedIndexPattern,
onSubmit,
onChange,
value,
placeholder,
}: Props) => {
Expand All @@ -46,6 +48,9 @@ export const MetricsExplorerKueryBar = ({
const handleChange = (query: string) => {
setValidation(validateQuery(query));
setDraftQuery(query);
if (onChange) {
onChange(query);
}
};

const filteredDerivedIndexPattern = {
Expand Down

0 comments on commit 5ae7295

Please sign in to comment.