[ML] Add links to rule editor for quick edit of value or filter#22990
[ML] Add links to rule editor for quick edit of value or filter#22990peteharverson merged 2 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/ml-ui |
jgowdyelastic
left a comment
There was a problem hiding this comment.
Added a few comments, but LGTM
| return null; | ||
| const detector = job.analysis_config.detectors[anomaly.detectorIndex]; | ||
| const rules = detector.custom_rules; | ||
| if (rules !== undefined && ruleIndex <= rules.length) { |
There was a problem hiding this comment.
is there a risk of an overflow here?
does the ruleIndex start at 0?
| if (scope !== undefined && Object.keys(scope).length === 1) { | ||
| const partitionFieldName = Object.keys(scope)[0]; | ||
| const partitionFieldValue = this.props.anomaly.source[partitionFieldName]; | ||
| const filterId = scope[partitionFieldName].filter_id; |
There was a problem hiding this comment.
is there a risk that scope[partitionFieldName] could be undefined?
a check might be good here, just to be defensive.
| updateRuleAtIndex } = this.props; | ||
|
|
||
| const detector = job.analysis_config.detectors[anomaly.detectorIndex]; | ||
| const editedRule = cloneDeep(detector.custom_rules[ruleIndex]); |
There was a problem hiding this comment.
custom_rules doesn't always exist in the job config.
unless it's being manually added in a step i've missed or perhaps this code will never be reached if it doesn't exist?
There was a problem hiding this comment.
The updateConditionValue function is only called from the EditConditionLink component which is only available for editing an existing rule. So yes, this code will only ever be called for a detector which already has a custom_rules property.
|
|
||
| // Updates an ML filter used in the scope part of a rule, | ||
| // adding an item to the filter with the specified ID. | ||
| export function updateFilterAddItem(item, filterId) { |
There was a problem hiding this comment.
a clearer name for this function might be addItemToFilter
💔 Build Failed |
💚 Build Succeeded |
|
|
||
| .select-rule-action-panel { | ||
| padding-top:10px; | ||
| padding:10px 0px; |
There was a problem hiding this comment.
uber nit: could have a space after padding:.
…tic#22990) * [ML] Add links to rule editor for quick edit of value or filter * [ML] Updates to rule editor quick links following review
…) (#22997) * [ML] Add links to rule editor for quick edit of value or filter * [ML] Updates to rule editor quick links following review
Adds functionality to the rule editor flyout for quick edits to the numeric value of a condition, or to add the partitioning field value of the selected anomaly to the filter list used in the scope.
The numeric link is available if the rule has a single numeric condition. It is not displayed if the rule has multiple conditions to avoid presenting the user with a long list of options with potential confusion as to exactly which value is being edited. The full editor can continue to be used for editing rules with multiple conditions.
The 'add to filter list' link is shown if the rule has a scope section with a single partitioning field key, andf the partitioning field value is not already in the filter list. As above it is not displayed if the scope has multiple partitioning field keys to simplify the edit options available.
The PR also adds the display of the
actualandtypicalvalues of the selected anomaly to the top of flyout, to help guide the user in selecting a suitable condition value (the edit condition value link defaults to the value of the selected anomaly). Also adds tests for the rule_editorutils.jsfile, and extra Jest tests for the new and edited components.Addresses the first two items in #21843