Skip to content

Commit

Permalink
[Metrics UI] Fix default metric alert interval for new conditions (el…
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed May 14, 2020
1 parent d78d816 commit 10caac0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ export const Expressions: React.FC<Props> = props => {

const addExpression = useCallback(() => {
const exp = alertParams.criteria?.slice() || [];
exp.push(defaultExpression);
exp.push({
...defaultExpression,
timeSize: timeSize ?? defaultExpression.timeSize,
timeUnit: timeUnit ?? defaultExpression.timeUnit,
});
setAlertParams('criteria', exp);
}, [setAlertParams, alertParams.criteria]);
}, [setAlertParams, alertParams.criteria, timeSize, timeUnit]);

const removeExpression = useCallback(
(id: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ export const Expressions: React.FC<Props> = props => {
);

const addExpression = useCallback(() => {
const exp = alertParams.criteria.slice();
exp.push(defaultExpression);
const exp = alertParams.criteria?.slice() || [];
exp.push({
...defaultExpression,
timeSize: timeSize ?? defaultExpression.timeSize,
timeUnit: timeUnit ?? defaultExpression.timeUnit,
});
setAlertParams('criteria', exp);
}, [setAlertParams, alertParams.criteria]);
}, [setAlertParams, alertParams.criteria, timeSize, timeUnit]);

const removeExpression = useCallback(
(id: number) => {
Expand Down

0 comments on commit 10caac0

Please sign in to comment.