mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[ResponseOps] Fix editing alerts filter for multi-consumer rule types on serverless (#206848)
## Summary Fixes #206845 Removes a check to see if a rule has a valid consumer before allowing alerts filters to be edited in the rule form. This was breaking editing rules on serverless. With all relevant rule types having added alerts-as-data functionality, this check is no longer necessary. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
b73cb8a31c
commit
d6b6fdc9f9
3 changed files with 2 additions and 50 deletions
|
@ -7,7 +7,7 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { AlertConsumers, ES_QUERY_ID } from '@kbn/rule-data-utils';
|
||||
import { AlertConsumers } from '@kbn/rule-data-utils';
|
||||
import { RuleTypeWithDescription } from '../common/types';
|
||||
import { hasFieldsForAad } from './has_fields_for_aad';
|
||||
|
||||
|
@ -49,30 +49,4 @@ describe('hasFieldsForAad', () => {
|
|||
|
||||
expect(hasFields).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should return true if it is a multi-consumer rule and valid consumer contains it', () => {
|
||||
const hasFields = hasFieldsForAad({
|
||||
ruleType: {
|
||||
hasFieldsForAAD: true,
|
||||
id: ES_QUERY_ID,
|
||||
} as RuleTypeWithDescription,
|
||||
consumer: 'stackAlerts',
|
||||
validConsumers: ['stackAlerts'],
|
||||
});
|
||||
|
||||
expect(hasFields).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should return false if it is a multi-consumer rule and valid consumer does not contain it', () => {
|
||||
const hasFields = hasFieldsForAad({
|
||||
ruleType: {
|
||||
hasFieldsForAAD: true,
|
||||
id: ES_QUERY_ID,
|
||||
} as RuleTypeWithDescription,
|
||||
consumer: 'stackAlerts',
|
||||
validConsumers: ['logs'],
|
||||
});
|
||||
|
||||
expect(hasFields).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
import { AlertConsumers, RuleCreationValidConsumer } from '@kbn/rule-data-utils';
|
||||
import { RuleTypeWithDescription } from '../common/types';
|
||||
import { DEFAULT_VALID_CONSUMERS, MULTI_CONSUMER_RULE_TYPE_IDS } from '../constants';
|
||||
|
||||
export const hasFieldsForAad = ({
|
||||
ruleType,
|
||||
|
@ -26,11 +25,5 @@ export const hasFieldsForAad = ({
|
|||
ruleType.hasAlertsMappings
|
||||
: false;
|
||||
|
||||
if (MULTI_CONSUMER_RULE_TYPE_IDS.includes(ruleType.id)) {
|
||||
return !!(
|
||||
(validConsumers || DEFAULT_VALID_CONSUMERS).includes(consumer as RuleCreationValidConsumer) &&
|
||||
hasAlertHasData
|
||||
);
|
||||
}
|
||||
return !!hasAlertHasData;
|
||||
};
|
||||
|
|
|
@ -671,23 +671,8 @@ export const RuleForm = ({
|
|||
selectedRuleType.hasAlertsMappings
|
||||
: false;
|
||||
|
||||
if (MULTI_CONSUMER_RULE_TYPE_IDS.includes(rule?.ruleTypeId ?? '')) {
|
||||
// Use selectedConsumer when creating a new rule, existing rule consumer when editing
|
||||
const ruleConsumer = initialSelectedConsumer ? selectedConsumer : rule.consumer;
|
||||
return (
|
||||
(validConsumers || VALID_CONSUMERS).includes(ruleConsumer as RuleCreationValidConsumer) &&
|
||||
hasAlertHasData
|
||||
);
|
||||
}
|
||||
return hasAlertHasData;
|
||||
}, [
|
||||
rule?.ruleTypeId,
|
||||
initialSelectedConsumer,
|
||||
rule.consumer,
|
||||
selectedConsumer,
|
||||
selectedRuleType,
|
||||
validConsumers,
|
||||
]);
|
||||
}, [selectedRuleType]);
|
||||
|
||||
const ruleTypeDetails = (
|
||||
<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue