Skip to content

Commit

Permalink
[ML] Anomaly Explorer: Fix view by selection when filter is active. (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
walterra authored Jan 24, 2020
1 parent ef4b395 commit fee22e8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -53,5 +56,6 @@ export function setInfluencerFilterSettings(
selectedViewByFieldName === VIEW_BY_JOB_LABEL ||
filteredFields.includes(selectedViewByFieldName) === false,
viewBySwimlaneFieldName: selectedViewByFieldName,
viewBySwimlaneOptions: filteredViewBySwimlaneOptions,
};
}

0 comments on commit fee22e8

Please sign in to comment.