[ML] Anomaly Explorer: Fix view by selection when filter is active. (#55717)
Fixes the view-by selection when a KQL filter gets active and restores previous behavior: - If the filter includes AND view-by switches to Job ID. - Otherwise the view-by selection switches to the first available option present in the KQL filter - Additionally, the view-by dropdown options get filtered down to the options present in the KQL filter
This commit is contained in:
parent
ef4b395873
commit
fee22e8d94
|
@ -23,17 +23,20 @@ export function setInfluencerFilterSettings(
|
|||
|
||||
const { selectedCells, viewBySwimlaneOptions } = state;
|
||||
let selectedViewByFieldName = state.viewBySwimlaneFieldName;
|
||||
const filteredViewBySwimlaneOptions = viewBySwimlaneOptions.filter(d =>
|
||||
filteredFields.includes(d)
|
||||
);
|
||||
|
||||
// if it's an AND filter set view by swimlane to job ID as the others will have no results
|
||||
if (isAndOperator && selectedCells === null) {
|
||||
if (isAndOperator && selectedCells === undefined) {
|
||||
selectedViewByFieldName = VIEW_BY_JOB_LABEL;
|
||||
} else {
|
||||
// Set View by dropdown to first relevant fieldName based on incoming filter if there's no cell selection already
|
||||
// or if selected cell is from overall swimlane as this won't include an additional influencer filter
|
||||
for (let i = 0; i < filteredFields.length; i++) {
|
||||
if (
|
||||
viewBySwimlaneOptions.includes(filteredFields[i]) &&
|
||||
(selectedCells === null || (selectedCells && selectedCells.type === 'overall'))
|
||||
filteredViewBySwimlaneOptions.includes(filteredFields[i]) &&
|
||||
(selectedCells === undefined || (selectedCells && selectedCells.type === 'overall'))
|
||||
) {
|
||||
selectedViewByFieldName = filteredFields[i];
|
||||
break;
|
||||
|
@ -53,5 +56,6 @@ export function setInfluencerFilterSettings(
|
|||
selectedViewByFieldName === VIEW_BY_JOB_LABEL ||
|
||||
filteredFields.includes(selectedViewByFieldName) === false,
|
||||
viewBySwimlaneFieldName: selectedViewByFieldName,
|
||||
viewBySwimlaneOptions: filteredViewBySwimlaneOptions,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue