[ML] Fix "Exclude jobs or groups" control (#111525)

This commit is contained in:
Dima Arnautov 2021-09-08 17:15:17 +02:00 committed by GitHub
parent eb9a0fcc17
commit d1f2e37902
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,7 @@ import { TestsSelectionControl } from './tests_selection_control';
import { isPopulatedObject } from '../../../common';
import { ALL_JOBS_SELECTION } from '../../../common/constants/alerts';
import { BetaBadge } from '../beta_badge';
import { isDefined } from '../../../common/types/guards';
export type MlAnomalyAlertTriggerProps = AlertTypeParamsExpressionProps<MlAnomalyDetectionJobsHealthRuleParams>;
@ -79,6 +80,19 @@ const AnomalyDetectionJobsHealthRuleTrigger: FC<MlAnomalyAlertTriggerProps> = ({
}),
options: jobs.map((v) => ({ label: v.job_id })),
},
{
label: i18n.translate('xpack.ml.jobSelector.groupOptionsLabel', {
defaultMessage: 'Groups',
}),
options: [
...new Set(
jobs
.map((v) => v.groups)
.flat()
.filter((v) => isDefined(v) && !alertParams.includeJobs.groupIds?.includes(v))
),
].map((v) => ({ label: v! })),
},
]);
});
},