[8.7] [Alerting Flyout] Fix interval parsing while editing (#152459) (#152856)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Alerting Flyout] Fix interval parsing while editing
(#152459)](https://github.com/elastic/kibana/pull/152459)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2023-03-07T21:15:50Z","message":"[Alerting
Flyout] Fix interval parsing while editing (#152459)\n\nCo-authored-by:
Ying Mao
<ying.mao@elastic.co>","sha":"5da80301fcc7876b0828591dcc0d330c05ed7c8c","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.7.0","v8.8.0"],"number":152459,"url":"https://github.com/elastic/kibana/pull/152459","mergeCommit":{"message":"[Alerting
Flyout] Fix interval parsing while editing (#152459)\n\nCo-authored-by:
Ying Mao
<ying.mao@elastic.co>","sha":"5da80301fcc7876b0828591dcc0d330c05ed7c8c"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/152459","number":152459,"mergeCommit":{"message":"[Alerting
Flyout] Fix interval parsing while editing (#152459)\n\nCo-authored-by:
Ying Mao
<ying.mao@elastic.co>","sha":"5da80301fcc7876b0828591dcc0d330c05ed7c8c"}}]}]
BACKPORT-->

Co-authored-by: Shahzad <shahzad31comp@gmail.com>
This commit is contained in:
Kibana Machine 2023-03-07 17:24:00 -05:00 committed by GitHub
parent 9bbc509149
commit 55ece59683
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,9 +61,10 @@ export function validateBaseProperties(
const invalidThrottleActions = ruleObject.actions.filter((a) => {
const throttleDuration = a.frequency?.throttle ? parseDuration(a.frequency.throttle) : 0;
const intervalDuration = ruleObject.schedule.interval
? parseDuration(ruleObject.schedule.interval)
: 0;
const intervalDuration =
ruleObject.schedule.interval && ruleObject.schedule.interval.length > 1
? parseDuration(ruleObject.schedule.interval)
: 0;
return (
a.frequency?.notifyWhen === RuleNotifyWhen.THROTTLE && throttleDuration < intervalDuration
);