From fb9c97d5d02924ce5a9bbc4cae83956de209a5ef Mon Sep 17 00:00:00 2001 From: Alexandra Doak Date: Tue, 19 Mar 2024 09:57:22 -0700 Subject: [PATCH 1/7] Changing from alert to rule --- x-pack/plugins/alerting/common/index.ts | 2 +- .../public/hooks/use_get_rule_types.ts | 2 +- x-pack/plugins/alerting/public/plugin.ts | 2 +- .../{alert_api.test.ts => rule_api.test.ts} | 2 +- .../services/{alert_api.ts => rule_api.ts} | 0 .../rule/methods/create/create_rule.test.ts | 38 ++--- .../rule/methods/create/create_rule.ts | 6 +- .../rule/methods/mute_alert/mute_instance.ts | 13 +- ...rule_type_registry_deprecated_consumers.ts | 138 +++++++++--------- .../rules_client_conflict_retries.test.ts | 40 ++--- 10 files changed, 122 insertions(+), 121 deletions(-) rename x-pack/plugins/alerting/public/services/{alert_api.test.ts => rule_api.test.ts} (99%) rename x-pack/plugins/alerting/public/services/{alert_api.ts => rule_api.ts} (100%) diff --git a/x-pack/plugins/alerting/common/index.ts b/x-pack/plugins/alerting/common/index.ts index f9c9724fbb3b2..365715e729f2a 100644 --- a/x-pack/plugins/alerting/common/index.ts +++ b/x-pack/plugins/alerting/common/index.ts @@ -90,6 +90,6 @@ export const INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH = export const INTERNAL_ALERTING_API_GET_ACTIVE_MAINTENANCE_WINDOWS_PATH = `${INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH}/_active` as const; -export const ALERTS_FEATURE_ID = 'alerts'; +export const RULES_FEATURE_ID = 'alerts'; export const MONITORING_HISTORY_LIMIT = 200; export const ENABLE_MAINTENANCE_WINDOWS = true; diff --git a/x-pack/plugins/alerting/public/hooks/use_get_rule_types.ts b/x-pack/plugins/alerting/public/hooks/use_get_rule_types.ts index b0871f89cc5df..d7fdd51bd1132 100644 --- a/x-pack/plugins/alerting/public/hooks/use_get_rule_types.ts +++ b/x-pack/plugins/alerting/public/hooks/use_get_rule_types.ts @@ -8,7 +8,7 @@ import { useQuery } from '@tanstack/react-query'; import { i18n } from '@kbn/i18n'; import { useKibana } from '../utils/kibana_react'; -import { loadRuleTypes } from '../services/alert_api'; +import { loadRuleTypes } from '../services/rule_api'; export const useGetRuleTypes = () => { const { diff --git a/x-pack/plugins/alerting/public/plugin.ts b/x-pack/plugins/alerting/public/plugin.ts index d044919ea293e..5d2f96680ca90 100644 --- a/x-pack/plugins/alerting/public/plugin.ts +++ b/x-pack/plugins/alerting/public/plugin.ts @@ -14,7 +14,7 @@ import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import { AlertNavigationRegistry, AlertNavigationHandler } from './alert_navigation_registry'; -import { loadRule, loadRuleType } from './services/alert_api'; +import { loadRule, loadRuleType } from './services/rule_api'; import { ENABLE_MAINTENANCE_WINDOWS, Rule, MAINTENANCE_WINDOWS_APP_ID } from '../common'; export interface PluginSetupContract { diff --git a/x-pack/plugins/alerting/public/services/alert_api.test.ts b/x-pack/plugins/alerting/public/services/rule_api.test.ts similarity index 99% rename from x-pack/plugins/alerting/public/services/alert_api.test.ts rename to x-pack/plugins/alerting/public/services/rule_api.test.ts index 13c118bb1e78f..d9131221be11a 100644 --- a/x-pack/plugins/alerting/public/services/alert_api.test.ts +++ b/x-pack/plugins/alerting/public/services/rule_api.test.ts @@ -7,7 +7,7 @@ import { Rule, RuleType } from '../../common'; import { httpServiceMock } from '@kbn/core/public/mocks'; -import { loadRule, loadRuleType, loadRuleTypes } from './alert_api'; +import { loadRule, loadRuleType, loadRuleTypes } from './rule_api'; const http = httpServiceMock.createStartContract(); diff --git a/x-pack/plugins/alerting/public/services/alert_api.ts b/x-pack/plugins/alerting/public/services/rule_api.ts similarity index 100% rename from x-pack/plugins/alerting/public/services/alert_api.ts rename to x-pack/plugins/alerting/public/services/rule_api.ts diff --git a/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.test.ts b/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.test.ts index 21a7b170e2871..07063b4fee4af 100644 --- a/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.test.ts +++ b/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.test.ts @@ -226,7 +226,7 @@ describe('create()', () => { return rulesClient.create(options); } - test('ensures user is authorised to create this type of alert under the consumer', async () => { + test('ensures user is authorised to create this type of rule under the consumer', async () => { const data = getMockData({ alertTypeId: 'myType', consumer: 'myApp', @@ -242,18 +242,18 @@ describe('create()', () => { }); }); - test('throws when user is not authorised to create this type of alert', async () => { + test('throws when user is not authorised to create this type of rule', async () => { const data = getMockData({ alertTypeId: 'myType', consumer: 'myApp', }); authorization.ensureAuthorized.mockRejectedValue( - new Error(`Unauthorized to create a "myType" alert for "myApp"`) + new Error(`Unauthorized to create a "myType" rule for "myApp"`) ); await expect(tryToExecuteOperation({ data })).rejects.toMatchInlineSnapshot( - `[Error: Unauthorized to create a "myType" alert for "myApp"]` + `[Error: Unauthorized to create a "myType" rule for "myApp"]` ); expect(authorization.ensureAuthorized).toHaveBeenCalledWith({ @@ -325,7 +325,7 @@ describe('create()', () => { }); }); - test('creates an alert', async () => { + test('creates an rule', async () => { const data = getMockData(); const createdAttributes = { ...data, @@ -556,7 +556,7 @@ describe('create()', () => { expect(actionsClient.isActionTypeEnabled).toHaveBeenCalledWith('test', { notifyUsage: true }); }); - test('creates an alert with a custom id', async () => { + test('creates an rule with a custom id', async () => { const data = getMockData(); const createdAttributes = { ...data, @@ -736,7 +736,7 @@ describe('create()', () => { `); }); - test('creates an alert with multiple actions', async () => { + test('creates an rule with multiple actions', async () => { const data = getMockData({ actions: [ { @@ -1443,7 +1443,7 @@ describe('create()', () => { expect(actionsClient.isSystemAction).toHaveBeenCalledTimes(3); }); - test('creates a disabled alert', async () => { + test('creates a disabled rule', async () => { const data = getMockData({ enabled: false }); unsecuredSavedObjectsClient.create.mockResolvedValueOnce({ id: '1', @@ -1893,14 +1893,14 @@ describe('create()', () => { `); }); - test('should trim alert name when creating API key', async () => { - const data = getMockData({ name: ' my alert name ' }); + test('should trim rule name when creating API key', async () => { + const data = getMockData({ name: ' my rule name ' }); unsecuredSavedObjectsClient.create.mockResolvedValueOnce({ id: '1', type: RULE_SAVED_OBJECT_TYPE, attributes: { enabled: false, - name: ' my alert name ', + name: ' my rule name ', alertTypeId: '123', schedule: { interval: 10000 }, params: { @@ -1931,10 +1931,10 @@ describe('create()', () => { }); await rulesClient.create({ data }); - expect(rulesClientParams.createAPIKey).toHaveBeenCalledWith('Alerting: 123/my alert name'); + expect(rulesClientParams.createAPIKey).toHaveBeenCalledWith('Alerting: 123/my rule name'); }); - test('should create alert with given notifyWhen value if notifyWhen is not null', async () => { + test('should create rule with given notifyWhen value if notifyWhen is not null', async () => { const data = getMockData({ notifyWhen: 'onActionGroupChange', throttle: '10m' }); const createdAttributes = { ...data, @@ -2075,7 +2075,7 @@ describe('create()', () => { `); }); - test('should create alert with notifyWhen = onThrottleInterval if notifyWhen is null and throttle is set', async () => { + test('should create rule with notifyWhen = onThrottleInterval if notifyWhen is null and throttle is set', async () => { const data = getMockData({ throttle: '10m' }); const createdAttributes = { ...data, @@ -2216,7 +2216,7 @@ describe('create()', () => { `); }); - test('should create alert with notifyWhen = onActiveAlert if notifyWhen is null and throttle is null', async () => { + test('should create rule with notifyWhen = onActiveAlert if notifyWhen is null and throttle is null', async () => { const data = getMockData(); const createdAttributes = { ...data, @@ -2357,7 +2357,7 @@ describe('create()', () => { `); }); - test('should create alerts with mapped_params', async () => { + test('should create rules with mapped_params', async () => { const data = getMockData({ params: { bar: true, @@ -2742,11 +2742,11 @@ describe('create()', () => { `"Task manager error"` ); expect(rulesClientParams.logger.error).toHaveBeenCalledWith( - 'Failed to cleanup alert "1" after scheduling task failed. Error: Saved object delete error' + 'Failed to cleanup rule "1" after scheduling task failed. Error: Saved object delete error' ); }); - test('throws an error if alert type not registered', async () => { + test('throws an error if rule type not registered', async () => { const data = getMockData(); ruleTypeRegistry.get.mockImplementation(() => { throw new Error('Invalid type'); @@ -2865,7 +2865,7 @@ describe('create()', () => { ); }); - test(`doesn't create API key for disabled alerts`, async () => { + test(`doesn't create API key for disabled rules`, async () => { const data = getMockData({ enabled: false }); unsecuredSavedObjectsClient.create.mockResolvedValueOnce({ id: '1', diff --git a/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.ts b/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.ts index b9e4dedf4d133..ef55b67ef08db 100644 --- a/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.ts +++ b/x-pack/plugins/alerting/server/application/rule/methods/create/create_rule.ts @@ -114,10 +114,10 @@ export async function createRule( context.ruleTypeRegistry.ensureRuleTypeEnabled(data.alertTypeId); - // Throws an error if alert type isn't registered + // Throws an error if rule type isn't registered const ruleType = context.ruleTypeRegistry.get(data.alertTypeId); - const validatedAlertTypeParams = validateRuleTypeParams(data.params, ruleType.validate.params); + const validatedRuleTypeParams = validateRuleTypeParams(data.params, ruleType.validate.params); const username = await context.getUserName(); let createdAPIKey = null; @@ -161,7 +161,7 @@ export async function createRule( params: updatedParams, actions, } = await withSpan({ name: 'extractReferences', type: 'rules' }, () => - extractReferences(context, ruleType, data.actions, validatedAlertTypeParams) + extractReferences(context, ruleType, data.actions, validatedRuleTypeParams) ); const createTime = Date.now(); diff --git a/x-pack/plugins/alerting/server/application/rule/methods/mute_alert/mute_instance.ts b/x-pack/plugins/alerting/server/application/rule/methods/mute_alert/mute_instance.ts index 5758794b550fb..d49af9aba93b6 100644 --- a/x-pack/plugins/alerting/server/application/rule/methods/mute_alert/mute_instance.ts +++ b/x-pack/plugins/alerting/server/application/rule/methods/mute_alert/mute_instance.ts @@ -21,6 +21,7 @@ export async function muteInstance( context: RulesClientContext, params: MuteAlertParams ): Promise { + const ruleId = params.alertId; try { muteAlertParamsSchema.validate(params); } catch (error) { @@ -29,18 +30,18 @@ export async function muteInstance( return await retryIfConflicts( context.logger, - `rulesClient.muteInstance('${params.alertId}')`, + `rulesClient.muteInstance('${ruleId}')`, async () => await muteInstanceWithOCC(context, params) ); } async function muteInstanceWithOCC( context: RulesClientContext, - { alertId, alertInstanceId }: MuteAlertParams + { alertId: ruleId, alertInstanceId }: MuteAlertParams ) { const { attributes, version } = await context.unsecuredSavedObjectsClient.get( RULE_SAVED_OBJECT_TYPE, - alertId + ruleId ); try { @@ -58,7 +59,7 @@ async function muteInstanceWithOCC( context.auditLogger?.log( ruleAuditEvent({ action: RuleAuditAction.MUTE_ALERT, - savedObject: { type: RULE_SAVED_OBJECT_TYPE, id: alertId }, + savedObject: { type: RULE_SAVED_OBJECT_TYPE, id: ruleId }, error, }) ); @@ -69,7 +70,7 @@ async function muteInstanceWithOCC( ruleAuditEvent({ action: RuleAuditAction.MUTE_ALERT, outcome: 'unknown', - savedObject: { type: RULE_SAVED_OBJECT_TYPE, id: alertId }, + savedObject: { type: RULE_SAVED_OBJECT_TYPE, id: ruleId }, }) ); @@ -81,7 +82,7 @@ async function muteInstanceWithOCC( await updateRuleSo({ savedObjectsClient: context.unsecuredSavedObjectsClient, savedObjectsUpdateOptions: { version }, - id: alertId, + id: ruleId, updateRuleAttributes: updateMeta(context, { mutedInstanceIds, updatedBy: await context.getUserName(), diff --git a/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts b/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts index ecb96f0248a35..58cbdd49764cf 100644 --- a/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts +++ b/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts @@ -5,77 +5,77 @@ * 2.0. */ -import { ALERTS_FEATURE_ID } from './types'; +import { RULES_FEATURE_ID } from './types'; export const ruleTypeIdWithValidLegacyConsumers: Record = { - 'example.always-firing': [ALERTS_FEATURE_ID], - 'example.people-in-space': [ALERTS_FEATURE_ID], - transform_health: [ALERTS_FEATURE_ID], - '.index-threshold': [ALERTS_FEATURE_ID], - '.geo-containment': [ALERTS_FEATURE_ID], - '.es-query': [ALERTS_FEATURE_ID, 'discover'], - 'xpack.ml.anomaly_detection_alert': [ALERTS_FEATURE_ID], - 'xpack.ml.anomaly_detection_jobs_health': [ALERTS_FEATURE_ID], - 'xpack.synthetics.alerts.monitorStatus': [ALERTS_FEATURE_ID], - 'xpack.synthetics.alerts.tls': [ALERTS_FEATURE_ID], - 'xpack.uptime.alerts.monitorStatus': [ALERTS_FEATURE_ID], - 'xpack.uptime.alerts.tlsCertificate': [ALERTS_FEATURE_ID], - 'xpack.uptime.alerts.durationAnomaly': [ALERTS_FEATURE_ID], - 'xpack.uptime.alerts.tls': [ALERTS_FEATURE_ID], - 'siem.eqlRule': [ALERTS_FEATURE_ID], - 'siem.savedQueryRule': [ALERTS_FEATURE_ID], - 'siem.indicatorRule': [ALERTS_FEATURE_ID], - 'siem.mlRule': [ALERTS_FEATURE_ID], - 'siem.queryRule': [ALERTS_FEATURE_ID], - 'siem.thresholdRule': [ALERTS_FEATURE_ID], - 'siem.newTermsRule': [ALERTS_FEATURE_ID], - 'siem.notifications': [ALERTS_FEATURE_ID], - 'slo.rules.burnRate': [ALERTS_FEATURE_ID], - 'logs.alert.document.count': [ALERTS_FEATURE_ID], - 'metrics.alert.inventory.threshold': [ALERTS_FEATURE_ID], - 'metrics.alert.threshold': [ALERTS_FEATURE_ID], - monitoring_alert_cluster_health: [ALERTS_FEATURE_ID], - monitoring_alert_license_expiration: [ALERTS_FEATURE_ID], - monitoring_alert_cpu_usage: [ALERTS_FEATURE_ID], - monitoring_alert_missing_monitoring_data: [ALERTS_FEATURE_ID], - monitoring_alert_disk_usage: [ALERTS_FEATURE_ID], - monitoring_alert_thread_pool_search_rejections: [ALERTS_FEATURE_ID], - monitoring_alert_thread_pool_write_rejections: [ALERTS_FEATURE_ID], - monitoring_alert_jvm_memory_usage: [ALERTS_FEATURE_ID], - monitoring_alert_nodes_changed: [ALERTS_FEATURE_ID], - monitoring_alert_logstash_version_mismatch: [ALERTS_FEATURE_ID], - monitoring_alert_kibana_version_mismatch: [ALERTS_FEATURE_ID], - monitoring_alert_elasticsearch_version_mismatch: [ALERTS_FEATURE_ID], - monitoring_ccr_read_exceptions: [ALERTS_FEATURE_ID], - monitoring_shard_size: [ALERTS_FEATURE_ID], - 'apm.transaction_duration': [ALERTS_FEATURE_ID], - 'apm.anomaly': [ALERTS_FEATURE_ID], - 'apm.error_rate': [ALERTS_FEATURE_ID], - 'apm.transaction_error_rate': [ALERTS_FEATURE_ID], - 'test.always-firing': [ALERTS_FEATURE_ID], - 'test.always-firing-alert-as-data': [ALERTS_FEATURE_ID], - 'test.authorization': [ALERTS_FEATURE_ID], - 'test.cancellableRule': [ALERTS_FEATURE_ID], - 'test.cumulative-firing': [ALERTS_FEATURE_ID], - 'test.exceedsAlertLimit': [ALERTS_FEATURE_ID], - 'test.failing': [ALERTS_FEATURE_ID], - 'test.gold.noop': [ALERTS_FEATURE_ID], - 'test.longRunning': [ALERTS_FEATURE_ID], - 'test.multipleSearches': [ALERTS_FEATURE_ID], - 'test.never-firing': [ALERTS_FEATURE_ID], - 'test.noop': [ALERTS_FEATURE_ID], - 'test.onlyContextVariables': [ALERTS_FEATURE_ID], - 'test.onlyStateVariables': [ALERTS_FEATURE_ID], - 'test.patternFiring': [ALERTS_FEATURE_ID], - 'test.patternFiringAad': [ALERTS_FEATURE_ID], - 'test.patternFiringAutoRecoverFalse': [ALERTS_FEATURE_ID], - 'test.patternLongRunning': [ALERTS_FEATURE_ID], - 'test.patternLongRunning.cancelAlertsOnRuleTimeout': [ALERTS_FEATURE_ID], - 'test.patternSuccessOrFailure': [ALERTS_FEATURE_ID], - 'test.restricted-noop': [ALERTS_FEATURE_ID], - 'test.throw': [ALERTS_FEATURE_ID], - 'test.unrestricted-noop': [ALERTS_FEATURE_ID], - 'test.validation': [ALERTS_FEATURE_ID], + 'example.always-firing': [RULES_FEATURE_ID], + 'example.people-in-space': [RULES_FEATURE_ID], + transform_health: [RULES_FEATURE_ID], + '.index-threshold': [RULES_FEATURE_ID], + '.geo-containment': [RULES_FEATURE_ID], + '.es-query': [RULES_FEATURE_ID, 'discover'], + 'xpack.ml.anomaly_detection_alert': [RULES_FEATURE_ID], + 'xpack.ml.anomaly_detection_jobs_health': [RULES_FEATURE_ID], + 'xpack.synthetics.alerts.monitorStatus': [RULES_FEATURE_ID], + 'xpack.synthetics.alerts.tls': [RULES_FEATURE_ID], + 'xpack.uptime.alerts.monitorStatus': [RULES_FEATURE_ID], + 'xpack.uptime.alerts.tlsCertificate': [RULES_FEATURE_ID], + 'xpack.uptime.alerts.durationAnomaly': [RULES_FEATURE_ID], + 'xpack.uptime.alerts.tls': [RULES_FEATURE_ID], + 'siem.eqlRule': [RULES_FEATURE_ID], + 'siem.savedQueryRule': [RULES_FEATURE_ID], + 'siem.indicatorRule': [RULES_FEATURE_ID], + 'siem.mlRule': [RULES_FEATURE_ID], + 'siem.queryRule': [RULES_FEATURE_ID], + 'siem.thresholdRule': [RULES_FEATURE_ID], + 'siem.newTermsRule': [RULES_FEATURE_ID], + 'siem.notifications': [RULES_FEATURE_ID], + 'slo.rules.burnRate': [RULES_FEATURE_ID], + 'logs.alert.document.count': [RULES_FEATURE_ID], + 'metrics.alert.inventory.threshold': [RULES_FEATURE_ID], + 'metrics.alert.threshold': [RULES_FEATURE_ID], + monitoring_alert_cluster_health: [RULES_FEATURE_ID], + monitoring_alert_license_expiration: [RULES_FEATURE_ID], + monitoring_alert_cpu_usage: [RULES_FEATURE_ID], + monitoring_alert_missing_monitoring_data: [RULES_FEATURE_ID], + monitoring_alert_disk_usage: [RULES_FEATURE_ID], + monitoring_alert_thread_pool_search_rejections: [RULES_FEATURE_ID], + monitoring_alert_thread_pool_write_rejections: [RULES_FEATURE_ID], + monitoring_alert_jvm_memory_usage: [RULES_FEATURE_ID], + monitoring_alert_nodes_changed: [RULES_FEATURE_ID], + monitoring_alert_logstash_version_mismatch: [RULES_FEATURE_ID], + monitoring_alert_kibana_version_mismatch: [RULES_FEATURE_ID], + monitoring_alert_elasticsearch_version_mismatch: [RULES_FEATURE_ID], + monitoring_ccr_read_exceptions: [RULES_FEATURE_ID], + monitoring_shard_size: [RULES_FEATURE_ID], + 'apm.transaction_duration': [RULES_FEATURE_ID], + 'apm.anomaly': [RULES_FEATURE_ID], + 'apm.error_rate': [RULES_FEATURE_ID], + 'apm.transaction_error_rate': [RULES_FEATURE_ID], + 'test.always-firing': [RULES_FEATURE_ID], + 'test.always-firing-alert-as-data': [RULES_FEATURE_ID], + 'test.authorization': [RULES_FEATURE_ID], + 'test.cancellableRule': [RULES_FEATURE_ID], + 'test.cumulative-firing': [RULES_FEATURE_ID], + 'test.exceedsAlertLimit': [RULES_FEATURE_ID], + 'test.failing': [RULES_FEATURE_ID], + 'test.gold.noop': [RULES_FEATURE_ID], + 'test.longRunning': [RULES_FEATURE_ID], + 'test.multipleSearches': [RULES_FEATURE_ID], + 'test.never-firing': [RULES_FEATURE_ID], + 'test.noop': [RULES_FEATURE_ID], + 'test.onlyContextVariables': [RULES_FEATURE_ID], + 'test.onlyStateVariables': [RULES_FEATURE_ID], + 'test.patternFiring': [RULES_FEATURE_ID], + 'test.patternFiringAad': [RULES_FEATURE_ID], + 'test.patternFiringAutoRecoverFalse': [RULES_FEATURE_ID], + 'test.patternLongRunning': [RULES_FEATURE_ID], + 'test.patternLongRunning.cancelAlertsOnRuleTimeout': [RULES_FEATURE_ID], + 'test.patternSuccessOrFailure': [RULES_FEATURE_ID], + 'test.restricted-noop': [RULES_FEATURE_ID], + 'test.throw': [RULES_FEATURE_ID], + 'test.unrestricted-noop': [RULES_FEATURE_ID], + 'test.validation': [RULES_FEATURE_ID], }; const getRuleTypeIdValidLegacyConsumers = (ruleTypeId: string): string[] => { diff --git a/x-pack/plugins/alerting/server/rules_client_conflict_retries.test.ts b/x-pack/plugins/alerting/server/rules_client_conflict_retries.test.ts index 579eacdca377b..d94e402a4e528 100644 --- a/x-pack/plugins/alerting/server/rules_client_conflict_retries.test.ts +++ b/x-pack/plugins/alerting/server/rules_client_conflict_retries.test.ts @@ -33,7 +33,7 @@ jest.mock('./application/rule/methods/get_schedule_frequency', () => ({ let rulesClient: RulesClient; -const MockAlertId = 'alert-id'; +const MockRuleId = 'rule-id'; const ConflictAfterRetries = RetryForConflictsAttempts + 1; @@ -120,7 +120,7 @@ async function update(success: boolean) { rulesClientParams.uiSettings.asScopedToClient = uiSettingsServiceMock.createStartContract().asScopedToClient; await rulesClient.update({ - id: MockAlertId, + id: MockRuleId, data: { schedule: { interval: '1m' }, name: 'cba', @@ -133,18 +133,18 @@ async function update(success: boolean) { }); } catch (err) { // only checking the warn messages in this test - expect(logger.warn).lastCalledWith(`rulesClient.update('alert-id') conflict, exceeded retries`); + expect(logger.warn).lastCalledWith(`rulesClient.update('rule-id') conflict, exceeded retries`); return expectConflict(success, err, 'create'); } expectSuccess(success, 2, 'create'); // only checking the debug messages in this test - expect(logger.debug).nthCalledWith(1, `rulesClient.update('alert-id') conflict, retrying ...`); + expect(logger.debug).nthCalledWith(1, `rulesClient.update('rule-id') conflict, retrying ...`); } async function updateApiKey(success: boolean) { try { - await rulesClient.updateApiKey({ id: MockAlertId }); + await rulesClient.updateApiKey({ id: MockRuleId }); } catch (err) { return expectConflict(success, err); } @@ -153,10 +153,10 @@ async function updateApiKey(success: boolean) { } async function enable(success: boolean) { - setupRawAlertMocks({}, { enabled: false }); + setupRawRuleMocks({}, { enabled: false }); try { - await rulesClient.enable({ id: MockAlertId }); + await rulesClient.enable({ id: MockRuleId }); } catch (err) { return expectConflict(success, err); } @@ -168,7 +168,7 @@ async function enable(success: boolean) { async function disable(success: boolean) { try { - await rulesClient.disable({ id: MockAlertId }); + await rulesClient.disable({ id: MockRuleId }); } catch (err) { return expectConflict(success, err); } @@ -178,7 +178,7 @@ async function disable(success: boolean) { async function muteAll(success: boolean) { try { - await rulesClient.muteAll({ id: MockAlertId }); + await rulesClient.muteAll({ id: MockRuleId }); } catch (err) { return expectConflict(success, err); } @@ -188,7 +188,7 @@ async function muteAll(success: boolean) { async function unmuteAll(success: boolean) { try { - await rulesClient.unmuteAll({ id: MockAlertId }); + await rulesClient.unmuteAll({ id: MockRuleId }); } catch (err) { return expectConflict(success, err); } @@ -198,7 +198,7 @@ async function unmuteAll(success: boolean) { async function muteInstance(success: boolean) { try { - await rulesClient.muteInstance({ alertId: MockAlertId, alertInstanceId: 'instance-id' }); + await rulesClient.muteInstance({ alertId: MockRuleId, alertInstanceId: 'instance-id' }); } catch (err) { return expectConflict(success, err); } @@ -207,9 +207,9 @@ async function muteInstance(success: boolean) { } async function unmuteInstance(success: boolean) { - setupRawAlertMocks({}, { mutedInstanceIds: ['instance-id'] }); + setupRawRuleMocks({}, { mutedInstanceIds: ['instance-id'] }); try { - await rulesClient.unmuteInstance({ alertId: MockAlertId, alertInstanceId: 'instance-id' }); + await rulesClient.unmuteInstance({ alertId: MockRuleId, alertInstanceId: 'instance-id' }); } catch (err) { return expectConflict(success, err); } @@ -233,7 +233,7 @@ function expectSuccess( function expectConflict(success: boolean, err: Error, method: 'update' | 'create' = 'update') { const conflictErrorMessage = SavedObjectsErrorHelpers.createConflictError( RULE_SAVED_OBJECT_TYPE, - MockAlertId + MockRuleId ).message; expect(`${err}`).toBe(`Error: ${conflictErrorMessage}`); @@ -253,7 +253,7 @@ function testFn(fn: (success: boolean) => unknown, success: boolean) { function mockSavedObjectUpdateConflictErrorTimes(times: number) { // default success value const mockUpdateValue = { - id: MockAlertId, + id: MockRuleId, type: RULE_SAVED_OBJECT_TYPE, attributes: { actions: [], @@ -268,21 +268,21 @@ function mockSavedObjectUpdateConflictErrorTimes(times: number) { // queue up specified number of errors before a success call for (let i = 0; i < times; i++) { unsecuredSavedObjectsClient.update.mockRejectedValueOnce( - SavedObjectsErrorHelpers.createConflictError(RULE_SAVED_OBJECT_TYPE, MockAlertId) + SavedObjectsErrorHelpers.createConflictError(RULE_SAVED_OBJECT_TYPE, MockRuleId) ); unsecuredSavedObjectsClient.create.mockRejectedValueOnce( - SavedObjectsErrorHelpers.createConflictError(RULE_SAVED_OBJECT_TYPE, MockAlertId) + SavedObjectsErrorHelpers.createConflictError(RULE_SAVED_OBJECT_TYPE, MockRuleId) ); } } // set up mocks needed to get the tested methods to run -function setupRawAlertMocks( +function setupRawRuleMocks( overrides: Record = {}, attributeOverrides: Record = {} ) { const rawRule = { - id: MockAlertId, + id: MockRuleId, type: RULE_SAVED_OBJECT_TYPE, attributes: { enabled: true, @@ -405,5 +405,5 @@ beforeEach(() => { rulesClient = new RulesClient(rulesClientParams); - setupRawAlertMocks(); + setupRawRuleMocks(); }); From 1a271fa5efb31a55e02fa0659c323fa26dc2a4b7 Mon Sep 17 00:00:00 2001 From: Alexandra Doak Date: Tue, 19 Mar 2024 10:45:58 -0700 Subject: [PATCH 2/7] Fixing type check --- .../server/authorization/alerting_authorization.ts | 8 ++++---- x-pack/plugins/alerting/server/plugin.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts b/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts index 90f4b189b1197..e0e7430aa6156 100644 --- a/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts +++ b/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts @@ -14,7 +14,7 @@ import { SecurityPluginSetup } from '@kbn/security-plugin/server'; import { PluginStartContract as FeaturesPluginStart } from '@kbn/features-plugin/server'; import { Space } from '@kbn/spaces-plugin/server'; import { RegistryRuleType } from '../rule_type_registry'; -import { ALERTS_FEATURE_ID, RuleTypeRegistry } from '../types'; +import { RULES_FEATURE_ID, RuleTypeRegistry } from '../types'; import { asFiltersByRuleTypeAndConsumer, asFiltersBySpaceId, @@ -130,7 +130,7 @@ export class AlertingAuthorization { this.allPossibleConsumers = this.featuresIds.then((featuresIds) => { return featuresIds.size - ? asAuthorizedConsumers([ALERTS_FEATURE_ID, ...featuresIds], { + ? asAuthorizedConsumers([RULES_FEATURE_ID, ...featuresIds], { read: true, all: true, }) @@ -338,7 +338,7 @@ export class AlertingAuthorization { >(); const allPossibleConsumers = await this.allPossibleConsumers; const addLegacyConsumerPrivileges = (legacyConsumer: string) => - legacyConsumer === ALERTS_FEATURE_ID || isEmpty(featuresIds); + legacyConsumer === RULES_FEATURE_ID || isEmpty(featuresIds); for (const feature of fIds) { const featureDef = this.features .getKibanaFeatures() @@ -504,6 +504,6 @@ export const getValidConsumer = ({ legacyConsumer: string; producer: string; }): string => - legacyConsumer === ALERTS_FEATURE_ID || validLegacyConsumers.includes(legacyConsumer) + legacyConsumer === RULES_FEATURE_ID || validLegacyConsumers.includes(legacyConsumer) ? producer : legacyConsumer; diff --git a/x-pack/plugins/alerting/server/plugin.ts b/x-pack/plugins/alerting/server/plugin.ts index 34472ed6066d9..af1c06284659c 100644 --- a/x-pack/plugins/alerting/server/plugin.ts +++ b/x-pack/plugins/alerting/server/plugin.ts @@ -64,7 +64,7 @@ import { RulesClientFactory } from './rules_client_factory'; import { RulesSettingsClientFactory } from './rules_settings_client_factory'; import { MaintenanceWindowClientFactory } from './maintenance_window_client_factory'; import { ILicenseState, LicenseState } from './lib/license_state'; -import { AlertingRequestHandlerContext, ALERTS_FEATURE_ID, RuleAlertData } from './types'; +import { AlertingRequestHandlerContext, RULES_FEATURE_ID, RuleAlertData } from './types'; import { defineRoutes } from './routes'; import { AlertInstanceContext, @@ -320,7 +320,7 @@ export class AlertingPlugin { } // Usage counter for telemetry - this.usageCounter = plugins.usageCollection?.createUsageCounter(ALERTS_FEATURE_ID); + this.usageCounter = plugins.usageCollection?.createUsageCounter(RULES_FEATURE_ID); const getSearchSourceMigrations = plugins.data.search.searchSource.getAllMigrations.bind( plugins.data.search.searchSource From b8f3960904e674a3c88d22d538eb7bcb6c6c13f1 Mon Sep 17 00:00:00 2001 From: Alexandra Doak Date: Tue, 19 Mar 2024 12:12:52 -0700 Subject: [PATCH 3/7] Fixing test failures --- .../src/alerts_search_bar/constants.ts | 2 +- .../hooks/use_load_rule_types_query.ts | 6 +-- .../public/alerts/alert_form.test.tsx | 6 +-- .../pages/rule_details/rule_details.tsx | 4 +- .../public/pages/rules/rules.test.tsx | 26 ++++++------ .../public/pages/rules/rules.tsx | 6 +-- .../hooks/use_load_rule_types_query.ts | 6 +-- .../application/lib/action_variables.test.ts | 4 +- .../lib/rule_api/rule_types.test.ts | 4 +- .../sections/rule_details/components/rule.tsx | 4 +- .../components/rule_definition.test.tsx | 14 +++---- .../components/rule_details.test.tsx | 8 ++-- .../components/rule_event_log_list.test.tsx | 6 +-- .../rule_execution_summary_and_chart.test.tsx | 6 +-- .../sections/rule_form/rule_add.test.tsx | 10 ++--- .../sections/rule_form/rule_edit.test.tsx | 6 +-- .../sections/rule_form/rule_form.test.tsx | 42 +++++++++---------- .../sections/rule_form/rule_form.tsx | 6 +-- .../rule_form/rule_notify_when.test.tsx | 4 +- .../rules_list/components/rules_list.tsx | 4 +- .../rules_list/components/test_helpers.ts | 10 ++--- 21 files changed, 92 insertions(+), 92 deletions(-) diff --git a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts index 5fbdaf4fa7455..d4c2e7a5098d2 100644 --- a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts +++ b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts @@ -10,6 +10,6 @@ import type { DataView, DataViewField } from '@kbn/data-views-plugin/common'; export const NO_INDEX_PATTERNS: DataView[] = []; export const EMPTY_AAD_FIELDS: DataViewField[] = []; -export const ALERTS_FEATURE_ID = 'alerts'; +export const RULES_FEATURE_ID = 'alerts'; export const BASE_ALERTING_API_PATH = '/api/alerting'; export const BASE_RAC_ALERTS_API_PATH = '/internal/rac/alerts'; diff --git a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts index c2396622a6bca..a7a84be96b409 100644 --- a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts +++ b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { useQuery } from '@tanstack/react-query'; import type { RuleType, RuleTypeIndex } from '@kbn/triggers-actions-ui-types'; import type { ToastsStart, HttpStart } from '@kbn/core/public'; -import { ALERTS_FEATURE_ID } from '../constants'; +import { RULES_FEATURE_ID } from '../constants'; import { fetchRuleTypes } from '../apis/fetch_rule_types'; export interface UseLoadRuleTypesQueryProps { @@ -64,11 +64,11 @@ export const useLoadRuleTypesQuery = (props: UseLoadRuleTypesQueryProps) => { const hasAnyAuthorizedRuleType = filteredIndex.size > 0; const authorizedRuleTypes = [...filteredIndex.values()]; const authorizedToCreateAnyRules = authorizedRuleTypes.some( - (ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.all + (ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all ); const authorizedToReadAnyRules = authorizedToCreateAnyRules || - authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.read); + authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.read); return { ruleTypesState: { diff --git a/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx b/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx index 7ac7d435f89d9..89f06f767fe2e 100644 --- a/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx +++ b/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx @@ -70,7 +70,7 @@ const initLegacyShims = () => { } as any); }; -const ALERTS_FEATURE_ID = 'alerts'; +const RULES_FEATURE_ID = 'alerts'; const validationMethod = (): ValidationResult => ({ errors: {} }); const actionTypeRegistry = actionTypeRegistryMock.create(); const ruleTypeRegistry = ruleTypeRegistryMock.create(); @@ -134,7 +134,7 @@ describe('alert_form', () => { name: 'test', ruleTypeId: ruleType.id, params: {}, - consumer: ALERTS_FEATURE_ID, + consumer: RULES_FEATURE_ID, schedule: { interval: '1m', }, @@ -221,7 +221,7 @@ describe('alert_form', () => { name: 'test', alertTypeId: ruleType.id, params: {}, - consumer: ALERTS_FEATURE_ID, + consumer: RULES_FEATURE_ID, schedule: { interval: '1m', }, diff --git a/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx b/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx index 90ed7866a1560..a7a63aca6979c 100644 --- a/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx +++ b/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx @@ -9,7 +9,7 @@ import React, { useState, useEffect, useRef } from 'react'; import { useParams, useLocation } from 'react-router-dom'; import { EuiSpacer, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { ALERTS_FEATURE_ID, RuleExecutionStatusErrorReasons } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID, RuleExecutionStatusErrorReasons } from '@kbn/alerting-plugin/common'; import type { BoolQuery } from '@kbn/es-query'; import type { AlertConsumers } from '@kbn/rule-data-utils'; import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public'; @@ -186,7 +186,7 @@ export function RuleDetailsPage() { const isEditable = isRuleEditable({ capabilities, rule, ruleType, ruleTypeRegistry }); const featureIds = - rule?.consumer === ALERTS_FEATURE_ID && ruleType?.producer + rule?.consumer === RULES_FEATURE_ID && ruleType?.producer ? [ruleType.producer as AlertConsumers] : rule ? [rule.consumer as AlertConsumers] diff --git a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx index b7652dbe3422a..c6fd7fab709d7 100644 --- a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx +++ b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { AppMountParameters, CoreStart } from '@kbn/core/public'; import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; import { observabilityAIAssistantPluginMock } from '@kbn/observability-ai-assistant-plugin/public/mock'; @@ -85,10 +85,10 @@ describe('RulesPage with all capabilities', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { all: true }, + [RULES_FEATURE_ID]: { all: true }, }, ruleTaskTimeout: '1m', }, @@ -100,10 +100,10 @@ describe('RulesPage with all capabilities', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { all: true }, + [RULES_FEATURE_ID]: { all: true }, }, ruleTaskTimeout: '1m', }, @@ -115,10 +115,10 @@ describe('RulesPage with all capabilities', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { all: true }, + [RULES_FEATURE_ID]: { all: true }, }, ruleTaskTimeout: '1m', }, @@ -166,10 +166,10 @@ describe('RulesPage with show only capability', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: false }, + [RULES_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, @@ -179,10 +179,10 @@ describe('RulesPage with show only capability', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: false }, + [RULES_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', id: '2', @@ -196,10 +196,10 @@ describe('RulesPage with show only capability', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: false }, + [RULES_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, diff --git a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx index 1b8d20d580d30..04f74297ec332 100644 --- a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx +++ b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx @@ -6,7 +6,7 @@ */ import { EuiButton, EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public'; @@ -64,7 +64,7 @@ export function RulesPage({ activeTab = RULES_TAB_NAME }: RulesPageProps) { const authorizedRuleTypes = [...ruleTypes.values()]; const authorizedToCreateAnyRules = authorizedRuleTypes.some( - (ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.all + (ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all ); const tabs = [ @@ -143,7 +143,7 @@ export function RulesPage({ activeTab = RULES_TAB_NAME }: RulesPageProps) { {addRuleFlyoutVisibility && ( 0; const authorizedRuleTypes = useMemo(() => [...filteredIndex.values()], [filteredIndex]); const authorizedToCreateAnyRules = authorizedRuleTypes.some( - (ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.all + (ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all ); const authorizedToReadAnyRules = authorizedToCreateAnyRules || - authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.read); + authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.read); return { ruleTypesState: { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts index 04ecb66e1692e..6280cee8323b9 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts @@ -7,7 +7,7 @@ import { RuleType, ActionVariables } from '../../types'; import { transformActionVariables } from './action_variables'; -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; beforeEach(() => jest.resetAllMocks()); @@ -325,7 +325,7 @@ function getAlertType(actionVariables: ActionVariables): RuleType { defaultActionGroupId: 'default', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, authorizedConsumers: {}, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', enabledInLicense: true, }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts index 05f21f9a53231..87a8dd0b711d4 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts @@ -8,7 +8,7 @@ import { RuleType } from '../../../types'; import { httpServiceMock } from '@kbn/core/public/mocks'; import { loadRuleTypes } from './rule_types'; -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; const http = httpServiceMock.createStartContract(); @@ -23,7 +23,7 @@ describe('loadRuleTypes', () => { state: [{ name: 'var2', description: 'val2' }], params: [{ name: 'var3', description: 'val3' }], }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, actionGroups: [{ id: 'default', name: 'Default' }], recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, defaultActionGroupId: 'default', diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx index b80a158ae9828..864bc73cef62d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx @@ -8,7 +8,7 @@ import React, { lazy, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiTabbedContent } from '@elastic/eui'; -import { AlertStatusValues, ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { AlertStatusValues, RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { ALERT_RULE_UUID, AlertConsumers } from '@kbn/rule-data-utils'; import { ALERT_TABLE_GENERIC_CONFIG_ID } from '../../../constants'; import { AlertTableConfigRegistry } from '../../../alert_table_config_registry'; @@ -104,7 +104,7 @@ export function RuleComponent({ alertsTableConfigurationRegistry as AlertTableConfigRegistry } featureIds={ - (rule.consumer === ALERTS_FEATURE_ID + (rule.consumer === RULES_FEATURE_ID ? [ruleType.producer] : [rule.consumer]) as AlertConsumers[] } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx index 49c07a698c6b3..cd89a712460c0 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { mount, ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { nextTick } from '@kbn/test-jest-helpers'; import { RuleDefinition } from './rule_definition'; import { actionTypeRegistryMock } from '../../../action_type_registry.mock'; @@ -44,10 +44,10 @@ const mockedRuleTypeIndex = new Map( recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: false }, + [RULES_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, @@ -59,10 +59,10 @@ const mockedRuleTypeIndex = new Map( recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: false }, + [RULES_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, @@ -74,10 +74,10 @@ const mockedRuleTypeIndex = new Map( recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: false }, + [RULES_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx index 7d292c5dee3cb..dd6a4c8aefb72 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx @@ -17,7 +17,7 @@ import { ActionGroup, RuleExecutionStatusErrorReasons, RuleExecutionStatusWarningReasons, - ALERTS_FEATURE_ID, + RULES_FEATURE_ID, } from '@kbn/alerting-plugin/common'; import { useKibana } from '../../../../common/lib/kibana'; import { ruleTypeRegistryMock } from '../../../rule_type_registry.mock'; @@ -70,7 +70,7 @@ const mockRuleApis = { }; const authorizedConsumers = { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, }; const recoveryActionGroup: ActionGroup<'recovered'> = { id: 'recovered', name: 'Recovered' }; @@ -82,7 +82,7 @@ const ruleType: RuleType = { actionVariables: { context: [], state: [], params: [] }, defaultActionGroupId: 'default', minimumLicenseRequired: 'basic', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers, enabledInLicense: true, }; @@ -821,7 +821,7 @@ describe('rule_details', () => { name: `rule-${uuidv4()}`, tags: [], ruleTypeId: '.noop', - consumer: ALERTS_FEATURE_ID, + consumer: RULES_FEATURE_ID, schedule: { interval: '1m' }, actions: [], params: {}, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx index ee860db2de387..18f8a30daf071 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { render, screen, waitFor, cleanup } from '@testing-library/react'; import { useKibana } from '../../../../common/lib/kibana'; -import { ActionGroup, ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ActionGroup, RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; import { RuleEventLogList, RuleEventLogListProps } from './rule_event_log_list'; import { mockRule, mockRuleType, mockRuleSummary, mockLogResponse } from './test_helpers'; @@ -50,13 +50,13 @@ const loadActionErrorLogMock = loadActionErrorLog as unknown as jest.MockedFunct const ruleMock = mockRule(); const authorizedConsumers = { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, }; const recoveryActionGroup: ActionGroup<'recovered'> = { id: 'recovered', name: 'Recovered' }; const ruleType: RuleType = mockRuleType({ - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers, recoveryActionGroup, }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx index 89f330515091e..5518696a3187b 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; -import { ActionGroup, ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ActionGroup, RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { RuleExecutionSummaryAndChart } from './rule_execution_summary_and_chart'; import { useKibana } from '../../../../common/lib/kibana'; import { mockRule, mockRuleType, mockRuleSummary } from './test_helpers'; @@ -24,13 +24,13 @@ const onChangeDurationMock = jest.fn(); const ruleMock = mockRule(); const authorizedConsumers = { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, }; const recoveryActionGroup: ActionGroup<'recovered'> = { id: 'recovered', name: 'Recovered' }; const ruleType: RuleType = mockRuleType({ - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers, recoveryActionGroup, }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx index 5458f03ebeaad..fcdf6d3cc526f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx @@ -29,7 +29,7 @@ import { } from '../../../types'; import { ruleTypeRegistryMock } from '../../rule_type_registry.mock'; import { ReactWrapper } from 'enzyme'; -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { useKibana } from '../../../common/lib/kibana'; import { triggersActionsUiConfig } from '../../../common/lib/config_api'; import { triggersActionsUiHealth } from '../../../common/lib/health_api'; @@ -127,9 +127,9 @@ describe.skip('rule_add', () => { defaultScheduleInterval, minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -196,7 +196,7 @@ describe.skip('rule_add', () => { wrapper = mountWithIntl( { @@ -407,7 +407,7 @@ describe.skip('rule_add', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { logs: { read: true, all: true }, }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx index ee64a408dcb37..b9cd3d9ff8dda 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx @@ -15,7 +15,7 @@ import { ruleTypeRegistryMock } from '../../rule_type_registry.mock'; import { ReactWrapper } from 'enzyme'; import RuleEdit from './rule_edit'; import { useKibana } from '../../../common/lib/kibana'; -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; jest.mock('../../../common/lib/kibana'); const actionTypeRegistry = actionTypeRegistryMock.create(); @@ -102,9 +102,9 @@ describe('rule_edit', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx index e050e7746008f..321997d19d064 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx @@ -26,7 +26,7 @@ import { } from '../../../types'; import { RuleForm } from './rule_form'; import { coreMock } from '@kbn/core/public/mocks'; -import { ALERTS_FEATURE_ID, RecoveredActionGroup } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID, RecoveredActionGroup } from '@kbn/alerting-plugin/common'; import { useKibana } from '../../../common/lib/kibana'; const toMapById = [ @@ -143,9 +143,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: RecoveredActionGroup, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -166,9 +166,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'gold', recoveryActionGroup: RecoveredActionGroup, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -212,7 +212,7 @@ describe('rule_form', () => { const initialRule = { name: 'test', params: {}, - consumer: ALERTS_FEATURE_ID, + consumer: RULES_FEATURE_ID, schedule: { interval: schedule, }, @@ -298,9 +298,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: RecoveredActionGroup, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -321,9 +321,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'gold', recoveryActionGroup: RecoveredActionGroup, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -365,7 +365,7 @@ describe('rule_form', () => { const initialRule = { name: 'test', params: {}, - consumer: ALERTS_FEATURE_ID, + consumer: RULES_FEATURE_ID, schedule: { interval: schedule, }, @@ -556,7 +556,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { alerts: { read: true, all: true }, apm: { read: true, all: true }, @@ -629,7 +629,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -707,7 +707,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -766,7 +766,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -825,7 +825,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -943,7 +943,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -1021,9 +1021,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: RecoveredActionGroup, - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, }, @@ -1041,7 +1041,7 @@ describe('rule_form', () => { recoveryActionGroup: RecoveredActionGroup, producer: 'test', authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, }, @@ -1152,7 +1152,7 @@ describe('rule_form', () => { name: 'test', ruleTypeId: ruleType.id, params: {}, - consumer: ALERTS_FEATURE_ID, + consumer: RULES_FEATURE_ID, schedule: { interval: '1m', }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx index 0f200410f7d54..471cf5d3443c2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx @@ -54,7 +54,7 @@ import { } from '@kbn/alerting-plugin/common/parse_duration'; import { RuleActionParam, - ALERTS_FEATURE_ID, + RULES_FEATURE_ID, RecoveredActionGroup, isActionGroupDisabledForActionTypeId, RuleActionAlertsFilterProperty, @@ -262,7 +262,7 @@ export const RuleForm = ({ }) ) .filter((item) => - rule.consumer === ALERTS_FEATURE_ID + rule.consumer === RULES_FEATURE_ID ? !item.ruleTypeModel.requiresAppContext : item.ruleType!.producer === rule.consumer ); @@ -438,7 +438,7 @@ export const RuleForm = ({ const authorizedConsumers = useMemo(() => { // If the app context provides a consumer, we assume that consumer is // is what we set for all rules that is created in that context - if (rule.consumer !== ALERTS_FEATURE_ID) { + if (rule.consumer !== RULES_FEATURE_ID) { return []; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx index f092475b18e08..fc0329cb599a6 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx @@ -10,7 +10,7 @@ import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { Rule } from '../../../types'; -import { ALERTS_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { RuleNotifyWhen } from './rule_notify_when'; describe('rule_notify_when', () => { @@ -28,7 +28,7 @@ describe('rule_notify_when', () => { const initialRule = { name: 'test', params: {}, - consumer: ALERTS_FEATURE_ID, + consumer: RULES_FEATURE_ID, schedule: { interval: '1m', }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx index b381035fbfc61..d512fb536b0ff 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx @@ -36,7 +36,7 @@ import { useHistory } from 'react-router-dom'; import { RuleExecutionStatus, - ALERTS_FEATURE_ID, + RULES_FEATURE_ID, RuleExecutionStatusErrorReasons, RuleLastRunOutcomeValues, } from '@kbn/alerting-plugin/common'; @@ -999,7 +999,7 @@ export const RulesList = ({ {ruleFlyoutVisible && ( }> { setRuleFlyoutVisibility(false); }} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts index 545b7d7141a92..14dfadeba4b77 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts @@ -6,7 +6,7 @@ */ import { - ALERTS_FEATURE_ID, + RULES_FEATURE_ID, RuleExecutionStatusErrorReasons, RuleExecutionStatusWarningReasons, } from '@kbn/alerting-plugin/common'; @@ -262,11 +262,11 @@ export const ruleTypeFromApi = { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'basic', enabledInLicense: true, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: true }, + [RULES_FEATURE_ID]: { read: true, all: true }, }, ruleTaskTimeout: '1m', }; @@ -278,11 +278,11 @@ export const getDisabledByLicenseRuleTypeFromApi = (authorized: boolean = true) recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: ALERTS_FEATURE_ID, + producer: RULES_FEATURE_ID, minimumLicenseRequired: 'platinum', enabledInLicense: false, authorizedConsumers: { - [ALERTS_FEATURE_ID]: { read: true, all: authorized }, + [RULES_FEATURE_ID]: { read: true, all: authorized }, }, }); From 73d00b0f2d01ef8765ca5d86847196cbe8a6d905 Mon Sep 17 00:00:00 2001 From: Alexandra Doak Date: Tue, 19 Mar 2024 12:18:43 -0700 Subject: [PATCH 4/7] Undo some changes --- .../kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts | 2 +- .../alerts_search_bar/hooks/use_load_rule_types_query.ts | 6 +++--- x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts index d4c2e7a5098d2..5fbdaf4fa7455 100644 --- a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts +++ b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/constants.ts @@ -10,6 +10,6 @@ import type { DataView, DataViewField } from '@kbn/data-views-plugin/common'; export const NO_INDEX_PATTERNS: DataView[] = []; export const EMPTY_AAD_FIELDS: DataViewField[] = []; -export const RULES_FEATURE_ID = 'alerts'; +export const ALERTS_FEATURE_ID = 'alerts'; export const BASE_ALERTING_API_PATH = '/api/alerting'; export const BASE_RAC_ALERTS_API_PATH = '/internal/rac/alerts'; diff --git a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts index a7a84be96b409..c2396622a6bca 100644 --- a/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts +++ b/packages/kbn-alerts-ui-shared/src/alerts_search_bar/hooks/use_load_rule_types_query.ts @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { useQuery } from '@tanstack/react-query'; import type { RuleType, RuleTypeIndex } from '@kbn/triggers-actions-ui-types'; import type { ToastsStart, HttpStart } from '@kbn/core/public'; -import { RULES_FEATURE_ID } from '../constants'; +import { ALERTS_FEATURE_ID } from '../constants'; import { fetchRuleTypes } from '../apis/fetch_rule_types'; export interface UseLoadRuleTypesQueryProps { @@ -64,11 +64,11 @@ export const useLoadRuleTypesQuery = (props: UseLoadRuleTypesQueryProps) => { const hasAnyAuthorizedRuleType = filteredIndex.size > 0; const authorizedRuleTypes = [...filteredIndex.values()]; const authorizedToCreateAnyRules = authorizedRuleTypes.some( - (ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all + (ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.all ); const authorizedToReadAnyRules = authorizedToCreateAnyRules || - authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.read); + authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[ALERTS_FEATURE_ID]?.read); return { ruleTypesState: { diff --git a/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx b/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx index 89f06f767fe2e..7ac7d435f89d9 100644 --- a/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx +++ b/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx @@ -70,7 +70,7 @@ const initLegacyShims = () => { } as any); }; -const RULES_FEATURE_ID = 'alerts'; +const ALERTS_FEATURE_ID = 'alerts'; const validationMethod = (): ValidationResult => ({ errors: {} }); const actionTypeRegistry = actionTypeRegistryMock.create(); const ruleTypeRegistry = ruleTypeRegistryMock.create(); @@ -134,7 +134,7 @@ describe('alert_form', () => { name: 'test', ruleTypeId: ruleType.id, params: {}, - consumer: RULES_FEATURE_ID, + consumer: ALERTS_FEATURE_ID, schedule: { interval: '1m', }, @@ -221,7 +221,7 @@ describe('alert_form', () => { name: 'test', alertTypeId: ruleType.id, params: {}, - consumer: RULES_FEATURE_ID, + consumer: ALERTS_FEATURE_ID, schedule: { interval: '1m', }, From 14d56b9d950e975c00605e302fc299efc199fe66 Mon Sep 17 00:00:00 2001 From: Alexandra Doak Date: Tue, 19 Mar 2024 13:30:29 -0700 Subject: [PATCH 5/7] Fixing linting --- .../components/create_maintenance_windows_form.test.tsx | 4 ++-- x-pack/plugins/alerting/public/plugin.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.test.tsx b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.test.tsx index a354e47975baf..acf926ac7ff2d 100644 --- a/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.test.tsx +++ b/x-pack/plugins/alerting/public/pages/maintenance_windows/components/create_maintenance_windows_form.test.tsx @@ -14,11 +14,11 @@ import { } from './create_maintenance_windows_form'; jest.mock('../../../utils/kibana_react'); -jest.mock('../../../services/alert_api', () => ({ +jest.mock('../../../services/rule_api', () => ({ loadRuleTypes: jest.fn(), })); -const { loadRuleTypes } = jest.requireMock('../../../services/alert_api'); +const { loadRuleTypes } = jest.requireMock('../../../services/rule_api'); const { useKibana, useUiSetting } = jest.requireMock('../../../utils/kibana_react'); const formProps: CreateMaintenanceWindowFormProps = { diff --git a/x-pack/plugins/alerting/public/plugin.test.ts b/x-pack/plugins/alerting/public/plugin.test.ts index a37ab89af03c0..3d6165cf18f6e 100644 --- a/x-pack/plugins/alerting/public/plugin.test.ts +++ b/x-pack/plugins/alerting/public/plugin.test.ts @@ -12,7 +12,7 @@ import { managementPluginMock, } from '@kbn/management-plugin/public/mocks'; -jest.mock('./services/alert_api', () => ({ +jest.mock('./services/rule_api', () => ({ loadRule: jest.fn(), loadRuleType: jest.fn(), })); @@ -24,7 +24,7 @@ const mockSection = createManagementSectionMock(); describe('Alerting Public Plugin', () => { describe('start()', () => { it(`should fallback to the viewInAppRelativeUrl part of the rule object if navigation isn't registered`, async () => { - const { loadRule, loadRuleType } = jest.requireMock('./services/alert_api'); + const { loadRule, loadRuleType } = jest.requireMock('./services/rule_api'); loadRule.mockResolvedValue({ alertTypeId: 'foo', consumer: 'abc', From 879913a3dc20a12a7935b1e8ed6556dc82ed3a0f Mon Sep 17 00:00:00 2001 From: Alexandra Doak Date: Tue, 19 Mar 2024 13:35:02 -0700 Subject: [PATCH 6/7] Fixing test failure --- .../server/rules_client/lib/create_rule_saved_object.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/alerting/server/rules_client/lib/create_rule_saved_object.ts b/x-pack/plugins/alerting/server/rules_client/lib/create_rule_saved_object.ts index cc0d6a895dcc0..938d421e79554 100644 --- a/x-pack/plugins/alerting/server/rules_client/lib/create_rule_saved_object.ts +++ b/x-pack/plugins/alerting/server/rules_client/lib/create_rule_saved_object.ts @@ -108,7 +108,7 @@ export async function createRuleSavedObject Date: Wed, 20 Mar 2024 10:50:02 -0700 Subject: [PATCH 7/7] Changing feature id name --- x-pack/plugins/alerting/common/index.ts | 2 +- .../authorization/alerting_authorization.ts | 8 +- x-pack/plugins/alerting/server/plugin.ts | 4 +- ...rule_type_registry_deprecated_consumers.ts | 138 +++++++++--------- .../pages/rule_details/rule_details.tsx | 4 +- .../public/pages/rules/rules.test.tsx | 26 ++-- .../public/pages/rules/rules.tsx | 6 +- .../hooks/use_load_rule_types_query.ts | 6 +- .../application/lib/action_variables.test.ts | 4 +- .../lib/rule_api/rule_types.test.ts | 4 +- .../sections/rule_details/components/rule.tsx | 4 +- .../components/rule_definition.test.tsx | 14 +- .../components/rule_details.test.tsx | 8 +- .../components/rule_event_log_list.test.tsx | 6 +- .../rule_execution_summary_and_chart.test.tsx | 6 +- .../sections/rule_form/rule_add.test.tsx | 10 +- .../sections/rule_form/rule_edit.test.tsx | 6 +- .../sections/rule_form/rule_form.test.tsx | 42 +++--- .../sections/rule_form/rule_form.tsx | 6 +- .../rule_form/rule_notify_when.test.tsx | 4 +- .../rules_list/components/rules_list.tsx | 4 +- .../rules_list/components/test_helpers.ts | 10 +- 22 files changed, 161 insertions(+), 161 deletions(-) diff --git a/x-pack/plugins/alerting/common/index.ts b/x-pack/plugins/alerting/common/index.ts index 365715e729f2a..2c71a3a17379f 100644 --- a/x-pack/plugins/alerting/common/index.ts +++ b/x-pack/plugins/alerting/common/index.ts @@ -90,6 +90,6 @@ export const INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH = export const INTERNAL_ALERTING_API_GET_ACTIVE_MAINTENANCE_WINDOWS_PATH = `${INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH}/_active` as const; -export const RULES_FEATURE_ID = 'alerts'; +export const ALERTING_FEATURE_ID = 'alerts'; export const MONITORING_HISTORY_LIMIT = 200; export const ENABLE_MAINTENANCE_WINDOWS = true; diff --git a/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts b/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts index e0e7430aa6156..68edc6667aeed 100644 --- a/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts +++ b/x-pack/plugins/alerting/server/authorization/alerting_authorization.ts @@ -14,7 +14,7 @@ import { SecurityPluginSetup } from '@kbn/security-plugin/server'; import { PluginStartContract as FeaturesPluginStart } from '@kbn/features-plugin/server'; import { Space } from '@kbn/spaces-plugin/server'; import { RegistryRuleType } from '../rule_type_registry'; -import { RULES_FEATURE_ID, RuleTypeRegistry } from '../types'; +import { ALERTING_FEATURE_ID, RuleTypeRegistry } from '../types'; import { asFiltersByRuleTypeAndConsumer, asFiltersBySpaceId, @@ -130,7 +130,7 @@ export class AlertingAuthorization { this.allPossibleConsumers = this.featuresIds.then((featuresIds) => { return featuresIds.size - ? asAuthorizedConsumers([RULES_FEATURE_ID, ...featuresIds], { + ? asAuthorizedConsumers([ALERTING_FEATURE_ID, ...featuresIds], { read: true, all: true, }) @@ -338,7 +338,7 @@ export class AlertingAuthorization { >(); const allPossibleConsumers = await this.allPossibleConsumers; const addLegacyConsumerPrivileges = (legacyConsumer: string) => - legacyConsumer === RULES_FEATURE_ID || isEmpty(featuresIds); + legacyConsumer === ALERTING_FEATURE_ID || isEmpty(featuresIds); for (const feature of fIds) { const featureDef = this.features .getKibanaFeatures() @@ -504,6 +504,6 @@ export const getValidConsumer = ({ legacyConsumer: string; producer: string; }): string => - legacyConsumer === RULES_FEATURE_ID || validLegacyConsumers.includes(legacyConsumer) + legacyConsumer === ALERTING_FEATURE_ID || validLegacyConsumers.includes(legacyConsumer) ? producer : legacyConsumer; diff --git a/x-pack/plugins/alerting/server/plugin.ts b/x-pack/plugins/alerting/server/plugin.ts index af1c06284659c..f5850abf5f99f 100644 --- a/x-pack/plugins/alerting/server/plugin.ts +++ b/x-pack/plugins/alerting/server/plugin.ts @@ -64,7 +64,7 @@ import { RulesClientFactory } from './rules_client_factory'; import { RulesSettingsClientFactory } from './rules_settings_client_factory'; import { MaintenanceWindowClientFactory } from './maintenance_window_client_factory'; import { ILicenseState, LicenseState } from './lib/license_state'; -import { AlertingRequestHandlerContext, RULES_FEATURE_ID, RuleAlertData } from './types'; +import { AlertingRequestHandlerContext, ALERTING_FEATURE_ID, RuleAlertData } from './types'; import { defineRoutes } from './routes'; import { AlertInstanceContext, @@ -320,7 +320,7 @@ export class AlertingPlugin { } // Usage counter for telemetry - this.usageCounter = plugins.usageCollection?.createUsageCounter(RULES_FEATURE_ID); + this.usageCounter = plugins.usageCollection?.createUsageCounter(ALERTING_FEATURE_ID); const getSearchSourceMigrations = plugins.data.search.searchSource.getAllMigrations.bind( plugins.data.search.searchSource diff --git a/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts b/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts index 58cbdd49764cf..e91e99203e8d4 100644 --- a/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts +++ b/x-pack/plugins/alerting/server/rule_type_registry_deprecated_consumers.ts @@ -5,77 +5,77 @@ * 2.0. */ -import { RULES_FEATURE_ID } from './types'; +import { ALERTING_FEATURE_ID } from './types'; export const ruleTypeIdWithValidLegacyConsumers: Record = { - 'example.always-firing': [RULES_FEATURE_ID], - 'example.people-in-space': [RULES_FEATURE_ID], - transform_health: [RULES_FEATURE_ID], - '.index-threshold': [RULES_FEATURE_ID], - '.geo-containment': [RULES_FEATURE_ID], - '.es-query': [RULES_FEATURE_ID, 'discover'], - 'xpack.ml.anomaly_detection_alert': [RULES_FEATURE_ID], - 'xpack.ml.anomaly_detection_jobs_health': [RULES_FEATURE_ID], - 'xpack.synthetics.alerts.monitorStatus': [RULES_FEATURE_ID], - 'xpack.synthetics.alerts.tls': [RULES_FEATURE_ID], - 'xpack.uptime.alerts.monitorStatus': [RULES_FEATURE_ID], - 'xpack.uptime.alerts.tlsCertificate': [RULES_FEATURE_ID], - 'xpack.uptime.alerts.durationAnomaly': [RULES_FEATURE_ID], - 'xpack.uptime.alerts.tls': [RULES_FEATURE_ID], - 'siem.eqlRule': [RULES_FEATURE_ID], - 'siem.savedQueryRule': [RULES_FEATURE_ID], - 'siem.indicatorRule': [RULES_FEATURE_ID], - 'siem.mlRule': [RULES_FEATURE_ID], - 'siem.queryRule': [RULES_FEATURE_ID], - 'siem.thresholdRule': [RULES_FEATURE_ID], - 'siem.newTermsRule': [RULES_FEATURE_ID], - 'siem.notifications': [RULES_FEATURE_ID], - 'slo.rules.burnRate': [RULES_FEATURE_ID], - 'logs.alert.document.count': [RULES_FEATURE_ID], - 'metrics.alert.inventory.threshold': [RULES_FEATURE_ID], - 'metrics.alert.threshold': [RULES_FEATURE_ID], - monitoring_alert_cluster_health: [RULES_FEATURE_ID], - monitoring_alert_license_expiration: [RULES_FEATURE_ID], - monitoring_alert_cpu_usage: [RULES_FEATURE_ID], - monitoring_alert_missing_monitoring_data: [RULES_FEATURE_ID], - monitoring_alert_disk_usage: [RULES_FEATURE_ID], - monitoring_alert_thread_pool_search_rejections: [RULES_FEATURE_ID], - monitoring_alert_thread_pool_write_rejections: [RULES_FEATURE_ID], - monitoring_alert_jvm_memory_usage: [RULES_FEATURE_ID], - monitoring_alert_nodes_changed: [RULES_FEATURE_ID], - monitoring_alert_logstash_version_mismatch: [RULES_FEATURE_ID], - monitoring_alert_kibana_version_mismatch: [RULES_FEATURE_ID], - monitoring_alert_elasticsearch_version_mismatch: [RULES_FEATURE_ID], - monitoring_ccr_read_exceptions: [RULES_FEATURE_ID], - monitoring_shard_size: [RULES_FEATURE_ID], - 'apm.transaction_duration': [RULES_FEATURE_ID], - 'apm.anomaly': [RULES_FEATURE_ID], - 'apm.error_rate': [RULES_FEATURE_ID], - 'apm.transaction_error_rate': [RULES_FEATURE_ID], - 'test.always-firing': [RULES_FEATURE_ID], - 'test.always-firing-alert-as-data': [RULES_FEATURE_ID], - 'test.authorization': [RULES_FEATURE_ID], - 'test.cancellableRule': [RULES_FEATURE_ID], - 'test.cumulative-firing': [RULES_FEATURE_ID], - 'test.exceedsAlertLimit': [RULES_FEATURE_ID], - 'test.failing': [RULES_FEATURE_ID], - 'test.gold.noop': [RULES_FEATURE_ID], - 'test.longRunning': [RULES_FEATURE_ID], - 'test.multipleSearches': [RULES_FEATURE_ID], - 'test.never-firing': [RULES_FEATURE_ID], - 'test.noop': [RULES_FEATURE_ID], - 'test.onlyContextVariables': [RULES_FEATURE_ID], - 'test.onlyStateVariables': [RULES_FEATURE_ID], - 'test.patternFiring': [RULES_FEATURE_ID], - 'test.patternFiringAad': [RULES_FEATURE_ID], - 'test.patternFiringAutoRecoverFalse': [RULES_FEATURE_ID], - 'test.patternLongRunning': [RULES_FEATURE_ID], - 'test.patternLongRunning.cancelAlertsOnRuleTimeout': [RULES_FEATURE_ID], - 'test.patternSuccessOrFailure': [RULES_FEATURE_ID], - 'test.restricted-noop': [RULES_FEATURE_ID], - 'test.throw': [RULES_FEATURE_ID], - 'test.unrestricted-noop': [RULES_FEATURE_ID], - 'test.validation': [RULES_FEATURE_ID], + 'example.always-firing': [ALERTING_FEATURE_ID], + 'example.people-in-space': [ALERTING_FEATURE_ID], + transform_health: [ALERTING_FEATURE_ID], + '.index-threshold': [ALERTING_FEATURE_ID], + '.geo-containment': [ALERTING_FEATURE_ID], + '.es-query': [ALERTING_FEATURE_ID, 'discover'], + 'xpack.ml.anomaly_detection_alert': [ALERTING_FEATURE_ID], + 'xpack.ml.anomaly_detection_jobs_health': [ALERTING_FEATURE_ID], + 'xpack.synthetics.alerts.monitorStatus': [ALERTING_FEATURE_ID], + 'xpack.synthetics.alerts.tls': [ALERTING_FEATURE_ID], + 'xpack.uptime.alerts.monitorStatus': [ALERTING_FEATURE_ID], + 'xpack.uptime.alerts.tlsCertificate': [ALERTING_FEATURE_ID], + 'xpack.uptime.alerts.durationAnomaly': [ALERTING_FEATURE_ID], + 'xpack.uptime.alerts.tls': [ALERTING_FEATURE_ID], + 'siem.eqlRule': [ALERTING_FEATURE_ID], + 'siem.savedQueryRule': [ALERTING_FEATURE_ID], + 'siem.indicatorRule': [ALERTING_FEATURE_ID], + 'siem.mlRule': [ALERTING_FEATURE_ID], + 'siem.queryRule': [ALERTING_FEATURE_ID], + 'siem.thresholdRule': [ALERTING_FEATURE_ID], + 'siem.newTermsRule': [ALERTING_FEATURE_ID], + 'siem.notifications': [ALERTING_FEATURE_ID], + 'slo.rules.burnRate': [ALERTING_FEATURE_ID], + 'logs.alert.document.count': [ALERTING_FEATURE_ID], + 'metrics.alert.inventory.threshold': [ALERTING_FEATURE_ID], + 'metrics.alert.threshold': [ALERTING_FEATURE_ID], + monitoring_alert_cluster_health: [ALERTING_FEATURE_ID], + monitoring_alert_license_expiration: [ALERTING_FEATURE_ID], + monitoring_alert_cpu_usage: [ALERTING_FEATURE_ID], + monitoring_alert_missing_monitoring_data: [ALERTING_FEATURE_ID], + monitoring_alert_disk_usage: [ALERTING_FEATURE_ID], + monitoring_alert_thread_pool_search_rejections: [ALERTING_FEATURE_ID], + monitoring_alert_thread_pool_write_rejections: [ALERTING_FEATURE_ID], + monitoring_alert_jvm_memory_usage: [ALERTING_FEATURE_ID], + monitoring_alert_nodes_changed: [ALERTING_FEATURE_ID], + monitoring_alert_logstash_version_mismatch: [ALERTING_FEATURE_ID], + monitoring_alert_kibana_version_mismatch: [ALERTING_FEATURE_ID], + monitoring_alert_elasticsearch_version_mismatch: [ALERTING_FEATURE_ID], + monitoring_ccr_read_exceptions: [ALERTING_FEATURE_ID], + monitoring_shard_size: [ALERTING_FEATURE_ID], + 'apm.transaction_duration': [ALERTING_FEATURE_ID], + 'apm.anomaly': [ALERTING_FEATURE_ID], + 'apm.error_rate': [ALERTING_FEATURE_ID], + 'apm.transaction_error_rate': [ALERTING_FEATURE_ID], + 'test.always-firing': [ALERTING_FEATURE_ID], + 'test.always-firing-alert-as-data': [ALERTING_FEATURE_ID], + 'test.authorization': [ALERTING_FEATURE_ID], + 'test.cancellableRule': [ALERTING_FEATURE_ID], + 'test.cumulative-firing': [ALERTING_FEATURE_ID], + 'test.exceedsAlertLimit': [ALERTING_FEATURE_ID], + 'test.failing': [ALERTING_FEATURE_ID], + 'test.gold.noop': [ALERTING_FEATURE_ID], + 'test.longRunning': [ALERTING_FEATURE_ID], + 'test.multipleSearches': [ALERTING_FEATURE_ID], + 'test.never-firing': [ALERTING_FEATURE_ID], + 'test.noop': [ALERTING_FEATURE_ID], + 'test.onlyContextVariables': [ALERTING_FEATURE_ID], + 'test.onlyStateVariables': [ALERTING_FEATURE_ID], + 'test.patternFiring': [ALERTING_FEATURE_ID], + 'test.patternFiringAad': [ALERTING_FEATURE_ID], + 'test.patternFiringAutoRecoverFalse': [ALERTING_FEATURE_ID], + 'test.patternLongRunning': [ALERTING_FEATURE_ID], + 'test.patternLongRunning.cancelAlertsOnRuleTimeout': [ALERTING_FEATURE_ID], + 'test.patternSuccessOrFailure': [ALERTING_FEATURE_ID], + 'test.restricted-noop': [ALERTING_FEATURE_ID], + 'test.throw': [ALERTING_FEATURE_ID], + 'test.unrestricted-noop': [ALERTING_FEATURE_ID], + 'test.validation': [ALERTING_FEATURE_ID], }; const getRuleTypeIdValidLegacyConsumers = (ruleTypeId: string): string[] => { diff --git a/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx b/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx index a7a63aca6979c..23d93b35ad330 100644 --- a/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx +++ b/x-pack/plugins/observability_solution/observability/public/pages/rule_details/rule_details.tsx @@ -9,7 +9,7 @@ import React, { useState, useEffect, useRef } from 'react'; import { useParams, useLocation } from 'react-router-dom'; import { EuiSpacer, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { RULES_FEATURE_ID, RuleExecutionStatusErrorReasons } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID, RuleExecutionStatusErrorReasons } from '@kbn/alerting-plugin/common'; import type { BoolQuery } from '@kbn/es-query'; import type { AlertConsumers } from '@kbn/rule-data-utils'; import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public'; @@ -186,7 +186,7 @@ export function RuleDetailsPage() { const isEditable = isRuleEditable({ capabilities, rule, ruleType, ruleTypeRegistry }); const featureIds = - rule?.consumer === RULES_FEATURE_ID && ruleType?.producer + rule?.consumer === ALERTING_FEATURE_ID && ruleType?.producer ? [ruleType.producer as AlertConsumers] : rule ? [rule.consumer as AlertConsumers] diff --git a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx index c6fd7fab709d7..9fe1f6030d239 100644 --- a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx +++ b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { AppMountParameters, CoreStart } from '@kbn/core/public'; import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; import { observabilityAIAssistantPluginMock } from '@kbn/observability-ai-assistant-plugin/public/mock'; @@ -85,10 +85,10 @@ describe('RulesPage with all capabilities', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { all: true }, + [ALERTING_FEATURE_ID]: { all: true }, }, ruleTaskTimeout: '1m', }, @@ -100,10 +100,10 @@ describe('RulesPage with all capabilities', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { all: true }, + [ALERTING_FEATURE_ID]: { all: true }, }, ruleTaskTimeout: '1m', }, @@ -115,10 +115,10 @@ describe('RulesPage with all capabilities', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { all: true }, + [ALERTING_FEATURE_ID]: { all: true }, }, ruleTaskTimeout: '1m', }, @@ -166,10 +166,10 @@ describe('RulesPage with show only capability', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: false }, + [ALERTING_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, @@ -179,10 +179,10 @@ describe('RulesPage with show only capability', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: false }, + [ALERTING_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', id: '2', @@ -196,10 +196,10 @@ describe('RulesPage with show only capability', () => { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: false }, + [ALERTING_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, diff --git a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx index 04f74297ec332..e15818e8ea3ae 100644 --- a/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx +++ b/x-pack/plugins/observability_solution/observability/public/pages/rules/rules.tsx @@ -6,7 +6,7 @@ */ import { EuiButton, EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public'; @@ -64,7 +64,7 @@ export function RulesPage({ activeTab = RULES_TAB_NAME }: RulesPageProps) { const authorizedRuleTypes = [...ruleTypes.values()]; const authorizedToCreateAnyRules = authorizedRuleTypes.some( - (ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all + (ruleType) => ruleType.authorizedConsumers[ALERTING_FEATURE_ID]?.all ); const tabs = [ @@ -143,7 +143,7 @@ export function RulesPage({ activeTab = RULES_TAB_NAME }: RulesPageProps) { {addRuleFlyoutVisibility && ( 0; const authorizedRuleTypes = useMemo(() => [...filteredIndex.values()], [filteredIndex]); const authorizedToCreateAnyRules = authorizedRuleTypes.some( - (ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all + (ruleType) => ruleType.authorizedConsumers[ALERTING_FEATURE_ID]?.all ); const authorizedToReadAnyRules = authorizedToCreateAnyRules || - authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.read); + authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[ALERTING_FEATURE_ID]?.read); return { ruleTypesState: { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts index 6280cee8323b9..ac9f64ee7eae7 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.test.ts @@ -7,7 +7,7 @@ import { RuleType, ActionVariables } from '../../types'; import { transformActionVariables } from './action_variables'; -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; beforeEach(() => jest.resetAllMocks()); @@ -325,7 +325,7 @@ function getAlertType(actionVariables: ActionVariables): RuleType { defaultActionGroupId: 'default', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, authorizedConsumers: {}, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', enabledInLicense: true, }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts index 87a8dd0b711d4..cd9e829c8045e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/rule_api/rule_types.test.ts @@ -8,7 +8,7 @@ import { RuleType } from '../../../types'; import { httpServiceMock } from '@kbn/core/public/mocks'; import { loadRuleTypes } from './rule_types'; -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; const http = httpServiceMock.createStartContract(); @@ -23,7 +23,7 @@ describe('loadRuleTypes', () => { state: [{ name: 'var2', description: 'val2' }], params: [{ name: 'var3', description: 'val3' }], }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, actionGroups: [{ id: 'default', name: 'Default' }], recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, defaultActionGroupId: 'default', diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx index 864bc73cef62d..c6598becec313 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule.tsx @@ -8,7 +8,7 @@ import React, { lazy, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiTabbedContent } from '@elastic/eui'; -import { AlertStatusValues, RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { AlertStatusValues, ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { ALERT_RULE_UUID, AlertConsumers } from '@kbn/rule-data-utils'; import { ALERT_TABLE_GENERIC_CONFIG_ID } from '../../../constants'; import { AlertTableConfigRegistry } from '../../../alert_table_config_registry'; @@ -104,7 +104,7 @@ export function RuleComponent({ alertsTableConfigurationRegistry as AlertTableConfigRegistry } featureIds={ - (rule.consumer === RULES_FEATURE_ID + (rule.consumer === ALERTING_FEATURE_ID ? [ruleType.producer] : [rule.consumer]) as AlertConsumers[] } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx index cd89a712460c0..91a77d18009c5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { mount, ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { nextTick } from '@kbn/test-jest-helpers'; import { RuleDefinition } from './rule_definition'; import { actionTypeRegistryMock } from '../../../action_type_registry.mock'; @@ -44,10 +44,10 @@ const mockedRuleTypeIndex = new Map( recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: false }, + [ALERTING_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, @@ -59,10 +59,10 @@ const mockedRuleTypeIndex = new Map( recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: false }, + [ALERTING_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, @@ -74,10 +74,10 @@ const mockedRuleTypeIndex = new Map( recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: false }, + [ALERTING_FEATURE_ID]: { read: true, all: false }, }, ruleTaskTimeout: '1m', }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx index dd6a4c8aefb72..8a54ba8e4a8e3 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_details.test.tsx @@ -17,7 +17,7 @@ import { ActionGroup, RuleExecutionStatusErrorReasons, RuleExecutionStatusWarningReasons, - RULES_FEATURE_ID, + ALERTING_FEATURE_ID, } from '@kbn/alerting-plugin/common'; import { useKibana } from '../../../../common/lib/kibana'; import { ruleTypeRegistryMock } from '../../../rule_type_registry.mock'; @@ -70,7 +70,7 @@ const mockRuleApis = { }; const authorizedConsumers = { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, }; const recoveryActionGroup: ActionGroup<'recovered'> = { id: 'recovered', name: 'Recovered' }; @@ -82,7 +82,7 @@ const ruleType: RuleType = { actionVariables: { context: [], state: [], params: [] }, defaultActionGroupId: 'default', minimumLicenseRequired: 'basic', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers, enabledInLicense: true, }; @@ -821,7 +821,7 @@ describe('rule_details', () => { name: `rule-${uuidv4()}`, tags: [], ruleTypeId: '.noop', - consumer: RULES_FEATURE_ID, + consumer: ALERTING_FEATURE_ID, schedule: { interval: '1m' }, actions: [], params: {}, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx index 18f8a30daf071..151a5805835fb 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_event_log_list.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { render, screen, waitFor, cleanup } from '@testing-library/react'; import { useKibana } from '../../../../common/lib/kibana'; -import { ActionGroup, RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ActionGroup, ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; import { RuleEventLogList, RuleEventLogListProps } from './rule_event_log_list'; import { mockRule, mockRuleType, mockRuleSummary, mockLogResponse } from './test_helpers'; @@ -50,13 +50,13 @@ const loadActionErrorLogMock = loadActionErrorLog as unknown as jest.MockedFunct const ruleMock = mockRule(); const authorizedConsumers = { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, }; const recoveryActionGroup: ActionGroup<'recovered'> = { id: 'recovered', name: 'Recovered' }; const ruleType: RuleType = mockRuleType({ - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers, recoveryActionGroup, }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx index 5518696a3187b..54390adae41cf 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_details/components/rule_execution_summary_and_chart.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; -import { ActionGroup, RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ActionGroup, ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { RuleExecutionSummaryAndChart } from './rule_execution_summary_and_chart'; import { useKibana } from '../../../../common/lib/kibana'; import { mockRule, mockRuleType, mockRuleSummary } from './test_helpers'; @@ -24,13 +24,13 @@ const onChangeDurationMock = jest.fn(); const ruleMock = mockRule(); const authorizedConsumers = { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, }; const recoveryActionGroup: ActionGroup<'recovered'> = { id: 'recovered', name: 'Recovered' }; const ruleType: RuleType = mockRuleType({ - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers, recoveryActionGroup, }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx index fcdf6d3cc526f..93de0a6aafdbc 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_add.test.tsx @@ -29,7 +29,7 @@ import { } from '../../../types'; import { ruleTypeRegistryMock } from '../../rule_type_registry.mock'; import { ReactWrapper } from 'enzyme'; -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { useKibana } from '../../../common/lib/kibana'; import { triggersActionsUiConfig } from '../../../common/lib/config_api'; import { triggersActionsUiHealth } from '../../../common/lib/health_api'; @@ -127,9 +127,9 @@ describe.skip('rule_add', () => { defaultScheduleInterval, minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -196,7 +196,7 @@ describe.skip('rule_add', () => { wrapper = mountWithIntl( { @@ -407,7 +407,7 @@ describe.skip('rule_add', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { logs: { read: true, all: true }, }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx index b9cd3d9ff8dda..f202a98a8cc96 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.test.tsx @@ -15,7 +15,7 @@ import { ruleTypeRegistryMock } from '../../rule_type_registry.mock'; import { ReactWrapper } from 'enzyme'; import RuleEdit from './rule_edit'; import { useKibana } from '../../../common/lib/kibana'; -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; jest.mock('../../../common/lib/kibana'); const actionTypeRegistry = actionTypeRegistryMock.create(); @@ -102,9 +102,9 @@ describe('rule_edit', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx index 321997d19d064..8b12245f0599b 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.test.tsx @@ -26,7 +26,7 @@ import { } from '../../../types'; import { RuleForm } from './rule_form'; import { coreMock } from '@kbn/core/public/mocks'; -import { RULES_FEATURE_ID, RecoveredActionGroup } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID, RecoveredActionGroup } from '@kbn/alerting-plugin/common'; import { useKibana } from '../../../common/lib/kibana'; const toMapById = [ @@ -143,9 +143,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: RecoveredActionGroup, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -166,9 +166,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'gold', recoveryActionGroup: RecoveredActionGroup, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -212,7 +212,7 @@ describe('rule_form', () => { const initialRule = { name: 'test', params: {}, - consumer: RULES_FEATURE_ID, + consumer: ALERTING_FEATURE_ID, schedule: { interval: schedule, }, @@ -298,9 +298,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: RecoveredActionGroup, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -321,9 +321,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'gold', recoveryActionGroup: RecoveredActionGroup, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, actionVariables: { @@ -365,7 +365,7 @@ describe('rule_form', () => { const initialRule = { name: 'test', params: {}, - consumer: RULES_FEATURE_ID, + consumer: ALERTING_FEATURE_ID, schedule: { interval: schedule, }, @@ -556,7 +556,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { alerts: { read: true, all: true }, apm: { read: true, all: true }, @@ -629,7 +629,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -707,7 +707,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -766,7 +766,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -825,7 +825,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -943,7 +943,7 @@ describe('rule_form', () => { defaultActionGroupId: 'threshold.fired', minimumLicenseRequired: 'basic', recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { infrastructure: { read: true, all: true }, logs: { read: true, all: true }, @@ -1021,9 +1021,9 @@ describe('rule_form', () => { defaultActionGroupId: 'testActionGroup', minimumLicenseRequired: 'basic', recoveryActionGroup: RecoveredActionGroup, - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, }, @@ -1041,7 +1041,7 @@ describe('rule_form', () => { recoveryActionGroup: RecoveredActionGroup, producer: 'test', authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, test: { read: true, all: true }, }, }, @@ -1152,7 +1152,7 @@ describe('rule_form', () => { name: 'test', ruleTypeId: ruleType.id, params: {}, - consumer: RULES_FEATURE_ID, + consumer: ALERTING_FEATURE_ID, schedule: { interval: '1m', }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx index 471cf5d3443c2..83035607cb725 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx @@ -54,7 +54,7 @@ import { } from '@kbn/alerting-plugin/common/parse_duration'; import { RuleActionParam, - RULES_FEATURE_ID, + ALERTING_FEATURE_ID, RecoveredActionGroup, isActionGroupDisabledForActionTypeId, RuleActionAlertsFilterProperty, @@ -262,7 +262,7 @@ export const RuleForm = ({ }) ) .filter((item) => - rule.consumer === RULES_FEATURE_ID + rule.consumer === ALERTING_FEATURE_ID ? !item.ruleTypeModel.requiresAppContext : item.ruleType!.producer === rule.consumer ); @@ -438,7 +438,7 @@ export const RuleForm = ({ const authorizedConsumers = useMemo(() => { // If the app context provides a consumer, we assume that consumer is // is what we set for all rules that is created in that context - if (rule.consumer !== RULES_FEATURE_ID) { + if (rule.consumer !== ALERTING_FEATURE_ID) { return []; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx index fc0329cb599a6..f5f2509f570fd 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_notify_when.test.tsx @@ -10,7 +10,7 @@ import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { Rule } from '../../../types'; -import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common'; +import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common'; import { RuleNotifyWhen } from './rule_notify_when'; describe('rule_notify_when', () => { @@ -28,7 +28,7 @@ describe('rule_notify_when', () => { const initialRule = { name: 'test', params: {}, - consumer: RULES_FEATURE_ID, + consumer: ALERTING_FEATURE_ID, schedule: { interval: '1m', }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx index d512fb536b0ff..b1cdc5330401f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx @@ -36,7 +36,7 @@ import { useHistory } from 'react-router-dom'; import { RuleExecutionStatus, - RULES_FEATURE_ID, + ALERTING_FEATURE_ID, RuleExecutionStatusErrorReasons, RuleLastRunOutcomeValues, } from '@kbn/alerting-plugin/common'; @@ -999,7 +999,7 @@ export const RulesList = ({ {ruleFlyoutVisible && ( }> { setRuleFlyoutVisibility(false); }} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts index 14dfadeba4b77..17ebb4c78b9f1 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/test_helpers.ts @@ -6,7 +6,7 @@ */ import { - RULES_FEATURE_ID, + ALERTING_FEATURE_ID, RuleExecutionStatusErrorReasons, RuleExecutionStatusWarningReasons, } from '@kbn/alerting-plugin/common'; @@ -262,11 +262,11 @@ export const ruleTypeFromApi = { recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'basic', enabledInLicense: true, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: true }, + [ALERTING_FEATURE_ID]: { read: true, all: true }, }, ruleTaskTimeout: '1m', }; @@ -278,11 +278,11 @@ export const getDisabledByLicenseRuleTypeFromApi = (authorized: boolean = true) recoveryActionGroup: { id: 'recovered', name: 'Recovered' }, actionVariables: { context: [], state: [] }, defaultActionGroupId: 'default', - producer: RULES_FEATURE_ID, + producer: ALERTING_FEATURE_ID, minimumLicenseRequired: 'platinum', enabledInLicense: false, authorizedConsumers: { - [RULES_FEATURE_ID]: { read: true, all: authorized }, + [ALERTING_FEATURE_ID]: { read: true, all: authorized }, }, });